diff options
author | David Sterba <dsterba@suse.com> | 2024-02-20 12:05:04 +0100 |
---|---|---|
committer | David Sterba <dsterba@suse.com> | 2024-02-20 12:19:14 +0100 |
commit | 58b1c4de036a400fd979909cae62c0d70116d27d (patch) | |
tree | 5a12c375ed31efdef12b85b66a25a3296f0868d4 | |
parent | 75522225f743888db31254d10d185bf0a92a0846 (diff) | |
download | btrfs-progs-58b1c4de036a400fd979909cae62c0d70116d27d.tar.gz |
btrfs-progs: use btrfs_open_file_or_dir_fd for error verbosity
There are many places that pass false as verbosity argument and then
print an error message, or don't print any message in error cases.
Use btrfs_open_file_or_dir_fd() that will be verbose in case of an error
with the same semantics.
Signed-off-by: David Sterba <dsterba@suse.com>
-rw-r--r-- | cmds/inspect.c | 7 | ||||
-rw-r--r-- | cmds/scrub.c | 2 | ||||
-rw-r--r-- | cmds/subvolume.c | 4 | ||||
-rw-r--r-- | common/utils.c | 4 |
4 files changed, 6 insertions, 11 deletions
diff --git a/cmds/inspect.c b/cmds/inspect.c index 4c311d18..53a1fce5 100644 --- a/cmds/inspect.c +++ b/cmds/inspect.c @@ -1082,12 +1082,9 @@ static int cmd_inspect_list_chunks(const struct cmd_struct *cmd, path = argv[optind]; - fd = btrfs_open_fd2(path, false, true, false); - if (fd < 0) { - errno = -fd; - error("cannot access '%s': %m", path); + fd = btrfs_open_file_or_dir_fd(path); + if (fd < 0) return 1; - } memset(&args, 0, sizeof(args)); sk->tree_id = BTRFS_CHUNK_TREE_OBJECTID; diff --git a/cmds/scrub.c b/cmds/scrub.c index 55dacd57..04b77678 100644 --- a/cmds/scrub.c +++ b/cmds/scrub.c @@ -2059,7 +2059,7 @@ static int cmd_scrub_limit(const struct cmd_struct *cmd, int argc, char **argv) return 1; } - fd = btrfs_open_fd2(argv[optind], false, true, false); + fd = btrfs_open_file_or_dir_fd(argv[optind]); if (fd < 0) return 1; diff --git a/cmds/subvolume.c b/cmds/subvolume.c index 3713915a..5ebe685c 100644 --- a/cmds/subvolume.c +++ b/cmds/subvolume.c @@ -1623,10 +1623,8 @@ static int cmd_subvolume_show(const struct cmd_struct *cmd, int argc, char **arg goto out; } - fd = btrfs_open_fd2(fullpath, false, true, false); + fd = btrfs_open_file_or_dir_fd(fullpath); if (fd < 0) { - errno = -fd; - error("can't access '%s': %m", fullpath); ret = fd; goto out; } diff --git a/common/utils.c b/common/utils.c index 6d829e71..ee9f21b3 100644 --- a/common/utils.c +++ b/common/utils.c @@ -250,9 +250,9 @@ int get_fs_info(const char *path, struct btrfs_ioctl_fs_info_args *fi_args, } /* at this point path must not be for a block device */ - fd = btrfs_open_fd2(path, false, true, false); + fd = btrfs_open_file_or_dir_fd(path); if (fd < 0) { - ret = -fd; + ret = fd; goto out; } |