mirror of
https://github.com/kdave/btrfs-progs
synced 2024-12-26 16:12:34 +00:00
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>
This commit is contained in:
parent
5950bcd121
commit
ea18e30d6e
@ -313,7 +313,12 @@ int cmd_inspect_dump_tree(int argc, char **argv)
|
||||
|
||||
ret = check_arg_type(argv[optind]);
|
||||
if (ret != BTRFS_ARG_BLKDEV && ret != BTRFS_ARG_REG) {
|
||||
error("not a block device or regular file: %s", argv[optind]);
|
||||
if (ret < 0)
|
||||
error("invalid argument %s: %s", argv[optind],
|
||||
strerror(-ret));
|
||||
else
|
||||
error("not a block device or regular file: %s",
|
||||
argv[optind]);
|
||||
goto out;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user