Skip to contentSkip to conversation

f2fs-tools: move fsck/fibmap.f2fs to tools/

PATCH New Changman Lee 1 participant 2 messages Jan 16, 2014

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 f2fs-tools: move fsck/fibmap.f2fs to tools/

Let's move miscellaneous utilities into tools directory.

---
 fsck/Makefile.am  |    4 +-
 fsck/fibmap.c     |  118 -----------------------------------------------------
 tools/Makefile.am |    4 +-
 tools/fibmap.c    |  118 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 121 insertions(+), 123 deletions(-)
 delete mode 100644 fsck/fibmap.c
 create mode 100644 tools/fibmap.c
fsck/Makefile.am +1 -3
index fc54e91..3258e47 100644
@@ -2,11 +2,9 @@
 
 AM_CPPFLAGS = ${libuuid_CFLAGS} -I$(top_srcdir)/include
 AM_CFLAGS = -Wall
-sbin_PROGRAMS = fsck.f2fs fibmap.f2fs
+sbin_PROGRAMS = fsck.f2fs
 fsck_f2fs_SOURCES = main.c fsck.c dump.c mount.c
 fsck_f2fs_LDADD = ${libuuid_LIBS} $(top_builddir)/lib/libf2fs.la
 
-fibmap_f2fs_SOURCES = fibmap.c
-
 install-data-hook:
 	ln -sf fsck.f2fs $(DESTDIR)/$(sbindir)/dump.f2fs
fsck/fibmap.c deleted +0 -118

118 lines not on this page · raw message

tools/Makefile.am +2 -2
index 8442387..1ead174 100644
@@ -2,6 +2,6 @@
 
 AM_CPPFLAGS = ${libuuid_CFLAGS} -I$(top_srcdir)/include
 AM_CFLAGS = -Wall
-sbin_PROGRAMS = f2fstat
+sbin_PROGRAMS = f2fstat fibmap.f2fs
 f2fstat_SOURCES = f2fstat.c
-f2fstat_LDADD = ${libuuid_LIBS} $(top_builddir)/lib/libf2fs.la
+fibmap_f2fs_SOURCES = fibmap.c
tools/fibmap.c new file +118 -0

118 lines not on this page · raw message

Signature · 9 lines
1.7.9.5


------------------------------------------------------------------------------
CenturyLink Cloud: The Leader in Enterprise Cloud Services.
Learn Why More Businesses Are Choosing CenturyLink Cloud For
Critical Workloads, Development Environments & Everything In Between.
Get a Quote or Start a Free Trial Today. 
http://pubads.g.doubleclick.net/gampad/clk?id=119420431&iu=/4140/ostg.clktrk
#1 lore raw

PATCH 2/2 fibmap.f2fs: add bdev information

This patch shows devname and start_lba based on zero sector. fibmap reports related lba, sometimes we want to know absolute lba of file to compare with blktrace.

---
 tools/fibmap.c |   44 +++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 43 insertions(+), 1 deletion(-)
tools/fibmap.c +43 -1
index 9eb6b90..ed0a08e 100644
@@ -7,6 +7,8 @@
 #include <errno.h>
 #include <sys/ioctl.h>
 #include <sys/stat.h>
+#include <libgen.h>
+#include <linux/hdreg.h>
 #include <linux/types.h>
 #include <linux/fs.h>
 
@@ -41,6 +43,42 @@ void print_stat(struct stat64 *st)
 	printf("--------------------------------------------\n\n");
 }
 
+void stat_bdev(struct stat64 *st, unsigned int *start_lba)
+{
+	struct stat bdev_stat;
+	struct hd_geometry geom;
+	char devname[32] = { 0, };
+	char linkname[32] = { 0, };
+	int fd;
+
+	sprintf(devname, "/dev/block/%d:%d", major(st->st_dev), minor(st->st_dev));
+
+	fd = open(devname, O_RDONLY);
+	if (fd < 0)
+		return;
+
+	if (fstat(fd, &bdev_stat) < 0)
+		goto out;
+
+	if (S_ISBLK(bdev_stat.st_mode)) {
+		if (ioctl(fd, HDIO_GETGEO, &geom) < 0)
+			*start_lba = 0;
+		else
+			*start_lba = geom.start;
+	}
+
+	if (readlink(devname, linkname, sizeof(linkname)) < 0)
+		goto out;
+
+	printf("----------------bdev info-------------------\n");
+	printf("devname = %s\n", basename(linkname));
+	printf("start_lba = %u\n", *start_lba);
+
+out:
+	close(fd);
+
+}
+
 int main(int argc, char *argv[])
 {
 	int fd;
@@ -50,6 +88,7 @@ int main(int argc, char *argv[])
 	int total_blks;
 	unsigned int i;
 	struct file_ext ext;
+	__u32 start_lba;
 	__u32 blknum;
 
 	if (argc != 2) {
@@ -73,9 +112,12 @@ int main(int argc, char *argv[])
 		goto out;
 	}
 
+	stat_bdev(&st, &start_lba);
+
 	total_blks = (st.st_size + st.st_blksize - 1) / st.st_blksize;
 
-	printf("\n%s :\n", filename);
+	printf("\n----------------file info-------------------\n");
+	printf("%s :\n", filename);
 	print_stat(&st);
 	printf("file_pos   start_blk     end_blk        blks\n");
 
Signature · 9 lines
1.7.9.5


------------------------------------------------------------------------------
CenturyLink Cloud: The Leader in Enterprise Cloud Services.
Learn Why More Businesses Are Choosing CenturyLink Cloud For
Critical Workloads, Development Environments & Everything In Between.
Get a Quote or Start a Free Trial Today. 
http://pubads.g.doubleclick.net/gampad/clk?id=119420431&iu=/4140/ostg.clktrk