btrfs-progs: drop _fd from btrfs_open_dir_fd()

Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
David Sterba 2024-02-20 12:56:24 +01:00
parent 52ea295038
commit 590bcf20bf
12 changed files with 38 additions and 37 deletions

View File

@ -300,7 +300,7 @@ static int do_balance(const char *path, struct btrfs_ioctl_balance_args *args,
int fd;
int ret;
fd = btrfs_open_dir_fd(path);
fd = btrfs_open_dir(path);
if (fd < 0)
return 1;
@ -613,7 +613,7 @@ static int cmd_balance_pause(const struct cmd_struct *cmd,
path = argv[optind];
fd = btrfs_open_dir_fd(path);
fd = btrfs_open_dir(path);
if (fd < 0)
return 1;
@ -653,7 +653,7 @@ static int cmd_balance_cancel(const struct cmd_struct *cmd,
path = argv[optind];
fd = btrfs_open_dir_fd(path);
fd = btrfs_open_dir(path);
if (fd < 0)
return 1;
@ -696,7 +696,7 @@ static int cmd_balance_resume(const struct cmd_struct *cmd,
path = argv[optind];
fd = btrfs_open_dir_fd(path);
fd = btrfs_open_dir(path);
if (fd < 0)
return 1;
@ -785,7 +785,7 @@ static int cmd_balance_status(const struct cmd_struct *cmd,
path = argv[optind];
fd = btrfs_open_dir_fd(path);
fd = btrfs_open_dir(path);
if (fd < 0)
return 2;

View File

@ -104,7 +104,7 @@ static int cmd_device_add(const struct cmd_struct *cmd,
last_dev = argc - 1;
mntpnt = argv[last_dev];
fdmnt = btrfs_open_dir_fd(mntpnt);
fdmnt = btrfs_open_dir(mntpnt);
if (fdmnt < 0)
return 1;
@ -225,7 +225,7 @@ static int _cmd_device_remove(const struct cmd_struct *cmd,
mntpnt = argv[argc - 1];
fdmnt = btrfs_open_dir_fd(mntpnt);
fdmnt = btrfs_open_dir(mntpnt);
if (fdmnt < 0)
return 1;
@ -901,7 +901,7 @@ static int cmd_device_usage(const struct cmd_struct *cmd, int argc, char **argv)
if (i > 1)
pr_verbose(LOG_DEFAULT, "\n");
fd = btrfs_open_dir_fd(argv[i]);
fd = btrfs_open_dir(argv[i]);
if (fd < 0) {
ret = 1;
break;

View File

@ -1235,7 +1235,7 @@ static int cmd_filesystem_usage(const struct cmd_struct *cmd,
struct array chunkinfos = { 0 };
struct array devinfos = { 0 };
fd = btrfs_open_dir_fd(argv[i]);
fd = btrfs_open_dir(argv[i]);
if (fd < 0) {
ret = 1;
goto out;

View File

@ -158,7 +158,7 @@ static int cmd_filesystem_df(const struct cmd_struct *cmd,
path = argv[optind];
fd = btrfs_open_dir_fd(path);
fd = btrfs_open_dir(path);
if (fd < 0)
return 1;
@ -1404,7 +1404,7 @@ static int cmd_filesystem_resize(const struct cmd_struct *cmd,
cancel = (strcmp("cancel", amount) == 0);
fd = btrfs_open_dir_fd(path);
fd = btrfs_open_dir(path);
if (fd < 0) {
/* The path is a directory */
if (fd == -ENOTDIR) {

View File

@ -128,7 +128,7 @@ static int cmd_inspect_inode_resolve(const struct cmd_struct *cmd,
if (check_argc_exact(argc - optind, 2))
return 1;
fd = btrfs_open_dir_fd(argv[optind + 1]);
fd = btrfs_open_dir(argv[optind + 1]);
if (fd < 0)
return 1;
@ -212,7 +212,7 @@ static int cmd_inspect_logical_resolve(const struct cmd_struct *cmd,
loi.flags = flags;
loi.inodes = ptr_to_u64(inodes);
fd = btrfs_open_dir_fd(argv[optind + 1]);
fd = btrfs_open_dir(argv[optind + 1]);
if (fd < 0) {
ret = 12;
goto out;
@ -293,7 +293,7 @@ static int cmd_inspect_logical_resolve(const struct cmd_struct *cmd,
strncpy(mount_path, mounted, PATH_MAX);
free(mounted);
path_fd = btrfs_open_dir_fd(mount_path);
path_fd = btrfs_open_dir(mount_path);
if (path_fd < 0) {
ret = -ENOENT;
goto out;
@ -334,7 +334,7 @@ static int cmd_inspect_subvolid_resolve(const struct cmd_struct *cmd,
if (check_argc_exact(argc - optind, 2))
return 1;
fd = btrfs_open_dir_fd(argv[optind + 1]);
fd = btrfs_open_dir(argv[optind + 1]);
if (fd < 0) {
ret = -ENOENT;
goto out;
@ -676,7 +676,7 @@ static int cmd_inspect_min_dev_size(const struct cmd_struct *cmd,
if (check_argc_exact(argc - optind, 1))
return 1;
fd = btrfs_open_dir_fd(argv[optind]);
fd = btrfs_open_dir(argv[optind]);
if (fd < 0) {
ret = -ENOENT;
goto out;

View File

@ -1785,7 +1785,7 @@ static int _cmd_qgroup_assign(const struct cmd_struct *cmd, int assign,
error("bad relation requested: %s", path);
return 1;
}
fd = btrfs_open_dir_fd(path);
fd = btrfs_open_dir(path);
if (fd < 0)
return 1;
@ -1843,7 +1843,7 @@ static int _cmd_qgroup_create(int create, int argc, char **argv)
}
path = argv[optind + 1];
fd = btrfs_open_dir_fd(path);
fd = btrfs_open_dir(path);
if (fd < 0)
return 1;
@ -2028,7 +2028,7 @@ static int cmd_qgroup_show(const struct cmd_struct *cmd, int argc, char **argv)
return 1;
path = argv[optind];
fd = btrfs_open_dir_fd(path);
fd = btrfs_open_dir(path);
if (fd < 0) {
free(filter_set);
free(comparer_set);
@ -2143,7 +2143,7 @@ static int cmd_qgroup_limit(const struct cmd_struct *cmd, int argc, char **argv)
} else
usage(cmd, 1);
fd = btrfs_open_dir_fd(path);
fd = btrfs_open_dir(path);
if (fd < 0)
return 1;
@ -2185,7 +2185,7 @@ static int cmd_qgroup_clear_stale(const struct cmd_struct *cmd, int argc, char *
path = argv[optind];
fd = btrfs_open_dir_fd(path);
fd = btrfs_open_dir(path);
if (fd < 0)
return 1;

View File

@ -45,7 +45,7 @@ static int quota_ctl(int cmd, char *path)
memset(&args, 0, sizeof(args));
args.cmd = cmd;
fd = btrfs_open_dir_fd(path);
fd = btrfs_open_dir(path);
if (fd < 0)
return 1;
@ -191,7 +191,7 @@ static int cmd_quota_rescan(const struct cmd_struct *cmd, int argc, char **argv)
memset(&args, 0, sizeof(args));
path = argv[optind];
fd = btrfs_open_dir_fd(path);
fd = btrfs_open_dir(path);
if (fd < 0)
return 1;

View File

@ -393,7 +393,7 @@ static int cmd_replace_status(const struct cmd_struct *cmd,
return 1;
path = argv[optind];
fd = btrfs_open_dir_fd(path);
fd = btrfs_open_dir(path);
if (fd < 0)
return 1;
@ -558,7 +558,7 @@ static int cmd_replace_cancel(const struct cmd_struct *cmd,
return 1;
path = argv[optind];
fd = btrfs_open_dir_fd(path);
fd = btrfs_open_dir(path);
if (fd < 0)
return 1;

View File

@ -1688,7 +1688,7 @@ static int cmd_subvolume_list(const struct cmd_struct *cmd, int argc, char **arg
goto out;
subvol = argv[optind];
fd = btrfs_open_dir_fd(subvol);
fd = btrfs_open_dir(subvol);
if (fd < 0) {
ret = -1;
error("can't access '%s'", subvol);

View File

@ -223,7 +223,7 @@ static int create_one_subvolume(const char *dst, struct btrfs_qgroup_inherit *in
}
}
fddst = btrfs_open_dir_fd(dstdir);
fddst = btrfs_open_dir(dstdir);
if (fddst < 0) {
ret = fddst;
goto out;
@ -497,7 +497,7 @@ again:
if (subvolid > 0)
dname = dupvname;
fd = btrfs_open_dir_fd(dname);
fd = btrfs_open_dir(dname);
if (fd < 0) {
ret = 1;
goto out;
@ -767,11 +767,11 @@ static int cmd_subvolume_snapshot(const struct cmd_struct *cmd, int argc, char *
goto out;
}
fddst = btrfs_open_dir_fd(dstdir);
fddst = btrfs_open_dir(dstdir);
if (fddst < 0)
goto out;
fd = btrfs_open_dir_fd(subvol);
fd = btrfs_open_dir(subvol);
if (fd < 0)
goto out;
@ -841,7 +841,7 @@ static int cmd_subvolume_get_default(const struct cmd_struct *cmd, int argc, cha
if (check_argc_exact(argc - optind, 1))
return 1;
fd = btrfs_open_dir_fd(argv[1]);
fd = btrfs_open_dir(argv[1]);
if (fd < 0)
return 1;
@ -1380,7 +1380,7 @@ static int cmd_subvolume_find_new(const struct cmd_struct *cmd, int argc, char *
return 1;
}
fd = btrfs_open_dir_fd(subvol);
fd = btrfs_open_dir(subvol);
if (fd < 0)
return 1;
@ -1817,7 +1817,7 @@ static int cmd_subvolume_sync(const struct cmd_struct *cmd, int argc, char **arg
if (check_argc_min(argc - optind, 1))
return 1;
fd = btrfs_open_dir_fd(argv[optind]);
fd = btrfs_open_dir(argv[optind]);
if (fd < 0) {
ret = 1;
goto out;

View File

@ -232,7 +232,8 @@ int btrfs_open_file_or_dir_fd(const char *path)
return btrfs_open_fd2(path, true, false);
}
int btrfs_open_dir_fd(const char *path)
/* Open the path for write and check that it's a directory. */
int btrfs_open_dir(const char *path)
{
return btrfs_open_fd2(path, true, true);
}
@ -254,9 +255,9 @@ int btrfs_open_mnt_fd(const char *path)
error("'%s' is not a mounted btrfs device", path);
return -EINVAL;
}
ret = btrfs_open_dir_fd(mp);
ret = btrfs_open_dir(mp);
} else {
ret = btrfs_open_dir_fd(path);
ret = btrfs_open_dir(path);
}
return ret;

View File

@ -31,7 +31,7 @@ int get_btrfs_mount(const char *dev, char *mp, size_t mp_size);
int btrfs_open_fd2(const char *path, bool read_write, bool dir_only);
int btrfs_open_file_or_dir_fd(const char *path);
int btrfs_open_dir_fd(const char *path);
int btrfs_open_dir(const char *path);
int btrfs_open_mnt_fd(const char *path);
#endif