diff --git a/cmds/inspect.c b/cmds/inspect.c index 4d4e24d2..268a902a 100644 --- a/cmds/inspect.c +++ b/cmds/inspect.c @@ -1020,7 +1020,6 @@ static int cmd_inspect_list_chunks(const struct cmd_struct *cmd, int ret; int fd; int i; - DIR *dirstream = NULL; unsigned unit_mode; char *sortmode = NULL; bool with_usage = true; @@ -1083,7 +1082,7 @@ static int cmd_inspect_list_chunks(const struct cmd_struct *cmd, path = argv[optind]; - fd = open_file_or_dir(path, &dirstream); + fd = btrfs_open_fd2(path, false, true, false); if (fd < 0) { error("cannot access '%s': %m", path); return 1; @@ -1187,7 +1186,7 @@ static int cmd_inspect_list_chunks(const struct cmd_struct *cmd, } ret = print_list_chunks(&ctx, sortmode, unit_mode, with_usage, with_empty); - close_file_or_dir(fd, dirstream); + close(fd); out_nomem: free(ctx.stats); diff --git a/cmds/scrub.c b/cmds/scrub.c index 039a67d1..55dacd57 100644 --- a/cmds/scrub.c +++ b/cmds/scrub.c @@ -1999,7 +1999,6 @@ static int cmd_scrub_limit(const struct cmd_struct *cmd, int argc, char **argv) struct string_table *table = NULL; int ret; int fd = -1; - DIR *dirstream = NULL; int cols, idx; u64 opt_devid = 0; bool devid_set = false; @@ -2060,7 +2059,7 @@ static int cmd_scrub_limit(const struct cmd_struct *cmd, int argc, char **argv) return 1; } - fd = open_file_or_dir(argv[optind], &dirstream); + fd = btrfs_open_fd2(argv[optind], false, true, false); if (fd < 0) return 1; @@ -2182,7 +2181,7 @@ static int cmd_scrub_limit(const struct cmd_struct *cmd, int argc, char **argv) out: if (table) table_free(table); - close_file_or_dir(fd, dirstream); + close(fd); return !!ret; } diff --git a/cmds/subvolume.c b/cmds/subvolume.c index 65582f67..a93dd408 100644 --- a/cmds/subvolume.c +++ b/cmds/subvolume.c @@ -1566,7 +1566,6 @@ static int cmd_subvolume_show(const struct cmd_struct *cmd, int argc, char **arg char *fullpath = NULL; int fd = -1; int ret = 1; - DIR *dirstream1 = NULL; int by_rootid = 0; int by_uuid = 0; u64 rootid_arg = 0; @@ -1624,7 +1623,7 @@ static int cmd_subvolume_show(const struct cmd_struct *cmd, int argc, char **arg goto out; } - fd = open_file_or_dir(fullpath, &dirstream1); + fd = btrfs_open_fd2(fullpath, false, true, false); if (fd < 0) { error("can't access '%s'", fullpath); goto out; @@ -1762,7 +1761,7 @@ out2: out: free(subvol_path); - close_file_or_dir(fd, dirstream1); + close(fd); free(fullpath); return !!ret; } diff --git a/common/utils.c b/common/utils.c index eccdd7f1..ff5bf4af 100644 --- a/common/utils.c +++ b/common/utils.c @@ -211,7 +211,6 @@ int get_fs_info(const char *path, struct btrfs_ioctl_fs_info_args *fi_args, struct btrfs_ioctl_dev_info_args *di_args; struct btrfs_ioctl_dev_info_args tmp; char mp[PATH_MAX]; - DIR *dirstream = NULL; memset(fi_args, 0, sizeof(*fi_args)); @@ -251,7 +250,7 @@ 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 = open_file_or_dir(path, &dirstream); + fd = btrfs_open_fd2(path, false, true, false); if (fd < 0) { ret = -errno; goto out; @@ -317,7 +316,7 @@ int get_fs_info(const char *path, struct btrfs_ioctl_fs_info_args *fi_args, } out: - close_file_or_dir(fd, dirstream); + close(fd); return ret; }