@@ -717,7 +717,6 @@ static int cmd_device_stats(const struct cmd_struct *cmd, int argc, char **argv)
bool free_table = false;
bool tabular = false;
__u64 flags = 0;
- DIR *dirstream = NULL;
struct format_ctx fctx;
optind = 0;
@@ -753,7 +752,7 @@ static int cmd_device_stats(const struct cmd_struct *cmd, int argc, char **argv)
dev_path = argv[optind];
- fdmnt = open_path_or_dev_mnt(dev_path, &dirstream, 1);
+ fdmnt = btrfs_open_mnt_fd(dev_path, true);
if (fdmnt < 0)
return 1;
@@ -839,7 +838,7 @@ static int cmd_device_stats(const struct cmd_struct *cmd, int argc, char **argv)
out:
free(di_args);
- close_file_or_dir(fdmnt, dirstream);
+ close(fdmnt);
if (free_table)
table_free(table);
@@ -136,7 +136,6 @@ static int cmd_replace_start(const struct cmd_struct *cmd,
bool force_using_targetdev = false;
u64 dstdev_block_count;
bool do_not_background = false;
- DIR *dirstream = NULL;
u64 srcdev_size;
u64 dstdev_size;
bool enqueue = false;
@@ -184,7 +183,7 @@ static int cmd_replace_start(const struct cmd_struct *cmd,
return 1;
path = argv[optind + 2];
- fdmnt = open_path_or_dev_mnt(path, &dirstream, 1);
+ fdmnt = btrfs_open_mnt_fd(path, true);
if (fdmnt < 0)
goto leave_with_error;
@@ -200,7 +199,7 @@ static int cmd_replace_start(const struct cmd_struct *cmd,
if (ret != 0) {
if (ret < 0)
error("unable to check status of exclusive operation: %m");
- close_file_or_dir(fdmnt, dirstream);
+ close(fdmnt);
goto leave_with_error;
}
@@ -348,7 +347,7 @@ static int cmd_replace_start(const struct cmd_struct *cmd,
goto leave_with_error;
}
}
- close_file_or_dir(fdmnt, dirstream);
+ close(fdmnt);
return 0;
leave_with_error:
@@ -1269,7 +1269,6 @@ static int scrub_start(const struct cmd_struct *cmd, int argc, char **argv,
pthread_mutex_t spc_write_mutex = PTHREAD_MUTEX_INITIALIZER;
void *terr;
u64 devid;
- DIR *dirstream = NULL;
bool force = false;
bool nothing_to_resume = false;
@@ -1326,7 +1325,7 @@ static int scrub_start(const struct cmd_struct *cmd, int argc, char **argv,
path = argv[optind];
- fdmnt = open_path_or_dev_mnt(path, &dirstream, !do_quiet);
+ fdmnt = btrfs_open_mnt_fd(path, !do_quiet);
if (fdmnt < 0)
return 1;
@@ -1698,7 +1697,7 @@ out:
if (sock_path[0])
unlink(sock_path);
}
- close_file_or_dir(fdmnt, dirstream);
+ close(fdmnt);
if (err)
return 1;
@@ -1751,7 +1750,6 @@ static int cmd_scrub_cancel(const struct cmd_struct *cmd, int argc, char **argv)
char *path;
int ret;
int fdmnt = -1;
- DIR *dirstream = NULL;
clean_args_no_options(cmd, argc, argv);
@@ -1760,7 +1758,7 @@ static int cmd_scrub_cancel(const struct cmd_struct *cmd, int argc, char **argv)
path = argv[optind];
- fdmnt = open_path_or_dev_mnt(path, &dirstream, 1);
+ fdmnt = btrfs_open_mnt_fd(path, true);
if (fdmnt < 0) {
ret = 1;
goto out;
@@ -1782,7 +1780,7 @@ static int cmd_scrub_cancel(const struct cmd_struct *cmd, int argc, char **argv)
pr_verbose(LOG_DEFAULT, "scrub cancelled\n");
out:
- close_file_or_dir(fdmnt, dirstream);
+ close(fdmnt);
return ret;
}
static DEFINE_SIMPLE_COMMAND(scrub_cancel, "cancel");
@@ -1841,7 +1839,6 @@ static int cmd_scrub_status(const struct cmd_struct *cmd, int argc, char **argv)
char fsid[BTRFS_UUID_UNPARSED_SIZE];
int fdres = -1;
int err = 0;
- DIR *dirstream = NULL;
unit_mode = get_unit_mode_from_arg(&argc, argv, 0);
@@ -1864,7 +1861,7 @@ static int cmd_scrub_status(const struct cmd_struct *cmd, int argc, char **argv)
path = argv[optind];
- fdmnt = open_path_or_dev_mnt(path, &dirstream, 1);
+ fdmnt = btrfs_open_mnt_fd(path, true);
if (fdmnt < 0)
return 1;
@@ -1978,7 +1975,7 @@ out:
free(si_args);
if (fdres > -1)
close(fdres);
- close_file_or_dir(fdmnt, dirstream);
+ close(fdmnt);
return !!err;
}