diff mbox

btrfs-progs: use canonical name for device in btrfs fi show when mounted

Message ID 1415842580-2430-1-git-send-email-guihc.fnst@cn.fujitsu.com (mailing list archive)
State Accepted
Headers show

Commit Message

Gui Hecheng Nov. 13, 2014, 1:36 a.m. UTC
When using lvm volumes to check fstests: btrfs/006, it fails like:
     Label: 'TestLabel.006'  uuid: <UUID>
     	Total devices <EXACTNUM> FS bytes used <SIZE>
     	devid <DEVID> size <SIZE> used <SIZE> path SCRATCH_DEV
    +	devid <DEVID> size <SIZE> used <SIZE> path /dev/dm-4
    +	devid <DEVID> size <SIZE> used <SIZE> path /dev/dm-5
    +	devid <DEVID> size <SIZE> used <SIZE> path /dev/dm-6

The /dev/dm-* points to lvm volumes, use @canonicalize_path() to convert them
and we will make it through. Of course we should do the same thing for dev stat.

Signed-off-by: Gui Hecheng <guihc.fnst@cn.fujitsu.com>
---
 cmds-device.c     | 16 +++++++++++-----
 cmds-filesystem.c |  7 ++++++-
 2 files changed, 17 insertions(+), 6 deletions(-)
diff mbox

Patch

diff --git a/cmds-device.c b/cmds-device.c
index 9323986..6cd41e1 100644
--- a/cmds-device.c
+++ b/cmds-device.c
@@ -408,31 +408,37 @@  static int cmd_dev_stats(int argc, char **argv)
 				path, strerror(errno));
 			err = 1;
 		} else {
+			char *canonical_path;
+
+			canonical_path = canonicalize_path((char *)path);
+
 			if (args.nr_items >= BTRFS_DEV_STAT_WRITE_ERRS + 1)
 				printf("[%s].write_io_errs   %llu\n",
-				       path,
+				       canonical_path,
 				       (unsigned long long) args.values[
 					BTRFS_DEV_STAT_WRITE_ERRS]);
 			if (args.nr_items >= BTRFS_DEV_STAT_READ_ERRS + 1)
 				printf("[%s].read_io_errs    %llu\n",
-				       path,
+				       canonical_path,
 				       (unsigned long long) args.values[
 					BTRFS_DEV_STAT_READ_ERRS]);
 			if (args.nr_items >= BTRFS_DEV_STAT_FLUSH_ERRS + 1)
 				printf("[%s].flush_io_errs   %llu\n",
-				       path,
+				       canonical_path,
 				       (unsigned long long) args.values[
 					BTRFS_DEV_STAT_FLUSH_ERRS]);
 			if (args.nr_items >= BTRFS_DEV_STAT_CORRUPTION_ERRS + 1)
 				printf("[%s].corruption_errs %llu\n",
-				       path,
+				       canonical_path,
 				       (unsigned long long) args.values[
 					BTRFS_DEV_STAT_CORRUPTION_ERRS]);
 			if (args.nr_items >= BTRFS_DEV_STAT_GENERATION_ERRS + 1)
 				printf("[%s].generation_errs %llu\n",
-				       path,
+				       canonical_path,
 				       (unsigned long long) args.values[
 					BTRFS_DEV_STAT_GENERATION_ERRS]);
+
+			free(canonical_path);
 		}
 	}
 
diff --git a/cmds-filesystem.c b/cmds-filesystem.c
index e4b2785..cd6b3c6 100644
--- a/cmds-filesystem.c
+++ b/cmds-filesystem.c
@@ -510,7 +510,10 @@  static int print_one_fs(struct btrfs_ioctl_fs_info_args *fs_info,
 			pretty_size(calc_used_bytes(space_info)));
 
 	for (i = 0; i < fs_info->num_devices; i++) {
+		char *canonical_path;
+
 		tmp_dev_info = (struct btrfs_ioctl_dev_info_args *)&dev_info[i];
+		canonical_path = canonicalize_path((char *)tmp_dev_info->path);
 
 		/* Add check for missing devices even mounted */
 		fd = open((char *)tmp_dev_info->path, O_RDONLY);
@@ -523,7 +526,9 @@  static int print_one_fs(struct btrfs_ioctl_fs_info_args *fs_info,
 			tmp_dev_info->devid,
 			pretty_size(tmp_dev_info->total_bytes),
 			pretty_size(tmp_dev_info->bytes_used),
-			tmp_dev_info->path);
+			canonical_path);
+
+		free(canonical_path);
 	}
 
 	if (missing)