diff options
author | Qu Wenruo <quwenruo@cn.fujitsu.com> | 2014-02-07 15:07:19 +0800 |
---|---|---|
committer | Chris Mason <clm@fb.com> | 2014-03-21 06:23:10 -0700 |
commit | 206efb60cbe3049e0d44c6da3c1909aeee18f813 (patch) | |
tree | 497e1abcb27ace78dc84b945125c496085d78192 /cmds-filesystem.c | |
parent | 1484081f6113cd33ad538a4a50f332754dbcc873 (diff) |
btrfs-progs: Add missing devices check for mounted btrfs.
In btrfs/003 of xfstest, it will check whether btrfs fi show can find
missing devices.
But before the patch, btrfs-progs will not check whether device missing
if given a mounted btrfs mountpoint/block device.
This patch fixes the bug and will pass btrfs/003.
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Cc: Anand Jain <anand.jain@oracle.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <clm@fb.com>
Diffstat (limited to 'cmds-filesystem.c')
-rw-r--r-- | cmds-filesystem.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/cmds-filesystem.c b/cmds-filesystem.c index 43e1cf3c..39bd1ad6 100644 --- a/cmds-filesystem.c +++ b/cmds-filesystem.c @@ -364,6 +364,8 @@ static int print_one_fs(struct btrfs_ioctl_fs_info_args *fs_info, char *label, char *path) { int i; + int fd; + int missing = 0; char uuidbuf[BTRFS_UUID_UNPARSED_SIZE]; struct btrfs_ioctl_dev_info_args *tmp_dev_info; int ret; @@ -386,6 +388,14 @@ static int print_one_fs(struct btrfs_ioctl_fs_info_args *fs_info, for (i = 0; i < fs_info->num_devices; i++) { tmp_dev_info = (struct btrfs_ioctl_dev_info_args *)&dev_info[i]; + + /* Add check for missing devices even mounted */ + fd = open((char *)tmp_dev_info->path, O_RDONLY); + if (fd < 0) { + missing = 1; + continue; + } + close(fd); printf("\tdevid %4llu size %s used %s path %s\n", tmp_dev_info->devid, pretty_size(tmp_dev_info->total_bytes), @@ -393,6 +403,8 @@ static int print_one_fs(struct btrfs_ioctl_fs_info_args *fs_info, tmp_dev_info->path); } + if (missing) + printf("\t*** Some devices missing\n"); printf("\n"); return 0; } |