diff options
author | Qu Wenruo <quwenruo@cn.fujitsu.com> | 2014-04-28 16:37:29 +0800 |
---|---|---|
committer | David Sterba <dsterba@suse.cz> | 2014-08-22 14:39:30 +0200 |
commit | b81dd800fccc62754d1801a6c118ec7f629b0355 (patch) | |
tree | 052c574dbb49414078e451a039a8faf0c88a8a2b /cmds-replace.c | |
parent | 24cf4d8c3ee924b474f68514e0167cc2e602a48d (diff) |
btrfs-progs: Improve the errno string about open_path_or_dev_mnt()
open_path_or_dev_mnt() is used to on *mounted* btrfs device or mount
point, when a unmounted btrfs device is passed, errno is set to EINVAL to
info the caller.
If ignore the errno and just print "ERROR: can't access '%s'", end users
will get confused.
This patch will add check for open_path_or_dev_mnt() caller and print
more meaningful error message when a unmounted btrfs device path is
given.
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Diffstat (limited to 'cmds-replace.c')
-rw-r--r-- | cmds-replace.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/cmds-replace.c b/cmds-replace.c index 01ab77c9..645dc988 100644 --- a/cmds-replace.c +++ b/cmds-replace.c @@ -172,8 +172,13 @@ static int cmd_start_replace(int argc, char **argv) fdmnt = open_path_or_dev_mnt(path, &dirstream); if (fdmnt < 0) { - fprintf(stderr, "ERROR: can't access \"%s\": %s\n", - path, strerror(errno)); + 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)); goto leave_with_error; } |