summaryrefslogtreecommitdiff
path: root/utils.c
diff options
context:
space:
mode:
authorSu Yue <suy.fnst@cn.fujitsu.com>2018-08-30 17:08:04 +0800
committerDavid Sterba <dsterba@suse.com>2018-10-23 14:48:39 +0200
commitea18e30d6e4674f7b0c416c8311792d668149455 (patch)
tree710591140232a0d82f06814b31ed1977d229e3ea /utils.c
parent5950bcd1214e91af3fdb618a65e34d7d5360a188 (diff)
btrfs-progs: dump-tree: print invalid argument and strerror
Before this patch: $ ls nothingness ls: cannot access 'nothingness': No such file or directory $ btrfs inspect-internal dump-tree nothingness ERROR: not a block device or regular file: nothingness The confusing error message makes users think that nonexistent file exiss but is of a wrong type. This patch lets check_arg_type return -errno if realpath failed. And print strerror if check_arg_type failed and the returned code is negative. Like: $ btrfs inspect-internal dump-tree nothingness ERROR: invalid argument: nothingness: No such file or directory Signed-off-by: Su Yue <suy.fnst@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'utils.c')
-rw-r--r--utils.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/utils.c b/utils.c
index d4395b1f..785c2022 100644
--- a/utils.c
+++ b/utils.c
@@ -502,6 +502,8 @@ int check_arg_type(const char *input)
return BTRFS_ARG_REG;
return BTRFS_ARG_UNKNOWN;
+ } else {
+ return -errno;
}
if (strlen(input) == (BTRFS_UUID_UNPARSED_SIZE - 1) &&