diff options
author | Zhao Lei <zhaolei@cn.fujitsu.com> | 2015-10-12 21:23:02 +0800 |
---|---|---|
committer | David Sterba <dsterba@suse.com> | 2015-11-02 09:35:01 +0100 |
commit | 078618d82220e84609cffd074655faafbada4c24 (patch) | |
tree | bfc17db74656dd73489265f35104e5ea40a946da /cmds-replace.c | |
parent | 5e1a77c45c8447974fe8a315afc0659ce3f64f4c (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-replace.c')
-rw-r--r-- | cmds-replace.c | 13 |
1 files changed, 2 insertions, 11 deletions
diff --git a/cmds-replace.c b/cmds-replace.c index 9ab8438e..385b7640 100644 --- a/cmds-replace.c +++ b/cmds-replace.c @@ -170,18 +170,9 @@ static int cmd_replace_start(int argc, char **argv) usage(cmd_replace_start_usage); path = argv[optind + 2]; - fdmnt = open_path_or_dev_mnt(path, &dirstream); - - if (fdmnt < 0) { - if (errno == EINVAL) - fprintf(stderr, - "ERROR: '%s' is not a mounted btrfs device\n", - path); - else - fprintf(stderr, "ERROR: can't access '%s': %s\n", - path, strerror(errno)); + fdmnt = open_path_or_dev_mnt(path, &dirstream, 1); + if (fdmnt < 0) goto leave_with_error; - } /* check for possible errors before backgrounding */ status_args.cmd = BTRFS_IOCTL_DEV_REPLACE_CMD_STATUS; |