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>
This commit is contained in:
David Sterba 2024-02-20 12:05:04 +01:00
parent 75522225f7
commit 58b1c4de03
4 changed files with 6 additions and 11 deletions

View File

@ -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;

View File

@ -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;

View File

@ -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;
}

View File

@ -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;
}