summaryrefslogtreecommitdiff
path: root/cmds-scrub.c
diff options
context:
space:
mode:
authorZhao Lei <zhaolei@cn.fujitsu.com>2015-10-12 21:23:02 +0800
committerDavid Sterba <dsterba@suse.com>2015-11-02 09:35:01 +0100
commit078618d82220e84609cffd074655faafbada4c24 (patch)
treebfc17db74656dd73489265f35104e5ea40a946da /cmds-scrub.c
parent5e1a77c45c8447974fe8a315afc0659ce3f64f4c (diff)
btrfs-progs: use btrfs_open_dir in open_path_or_dev_mnt
Use btrfs_open_dir() in open_path_or_dev_mnt() to make the function return error when target is neither block device nor btrfs mount point. Also add "verbose" argument to let function output common error message instead of putting duplicated lines in caller. Before patch: # ./btrfs device stats /mnt/tmp1 ERROR: getting dev info for devstats failed: Inappropriate ioctl for device # ./btrfs replace start /dev/vdd /dev/vde /mnt/tmp1 ERROR: ioctl(DEV_REPLACE_STATUS) failed on "/mnt/tmp1": Inappropriate ioctl for device After patch: # ./btrfs device stats /mnt/tmp1 ERROR: not a btrfs filesystem: /mnt/tmp1 # ./btrfs replace start /dev/vdd /dev/vde /mnt/tmp1 ERROR: not a btrfs filesystem: /mnt/tmp1 Signed-off-by: Zhao Lei <zhaolei@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'cmds-scrub.c')
-rw-r--r--cmds-scrub.c28
1 files changed, 5 insertions, 23 deletions
diff --git a/cmds-scrub.c b/cmds-scrub.c
index ea6ffc9c..da614f2f 100644
--- a/cmds-scrub.c
+++ b/cmds-scrub.c
@@ -1198,17 +1198,9 @@ static int scrub_start(int argc, char **argv, int resume)
path = argv[optind];
- fdmnt = open_path_or_dev_mnt(path, &dirstream);
-
- if (fdmnt < 0) {
- if (errno == EINVAL)
- error_on(!do_quiet, "'%s' is not a mounted btrfs device",
- path);
- else
- error_on(!do_quiet, "can't access '%s': %s",
- path, strerror(errno));
+ fdmnt = open_path_or_dev_mnt(path, &dirstream, !do_quiet);
+ if (fdmnt < 0)
return 1;
- }
ret = get_fs_info(path, &fi_args, &di_args);
if (ret) {
@@ -1604,12 +1596,8 @@ static int cmd_scrub_cancel(int argc, char **argv)
path = argv[1];
- fdmnt = open_path_or_dev_mnt(path, &dirstream);
+ fdmnt = open_path_or_dev_mnt(path, &dirstream, 1);
if (fdmnt < 0) {
- if (errno == EINVAL)
- error("'%s' is not a mounted btrfs device", path);
- else
- error("can't access '%s': %s", path, strerror(errno));
ret = 1;
goto out;
}
@@ -1705,15 +1693,9 @@ static int cmd_scrub_status(int argc, char **argv)
path = argv[optind];
- fdmnt = open_path_or_dev_mnt(path, &dirstream);
-
- if (fdmnt < 0) {
- if (errno == EINVAL)
- error("'%s' is not a mounted btrfs device", path);
- else
- error("can't access '%s': %s", path, strerror(errno));
+ fdmnt = open_path_or_dev_mnt(path, &dirstream, 1);
+ if (fdmnt < 0)
return 1;
- }
ret = get_fs_info(path, &fi_args, &di_args);
if (ret) {