diff --git a/cmds/balance.c b/cmds/balance.c index 7c15729c..4c73273d 100644 --- a/cmds/balance.c +++ b/cmds/balance.c @@ -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; diff --git a/cmds/device.c b/cmds/device.c index 3895da44..9f272cbd 100644 --- a/cmds/device.c +++ b/cmds/device.c @@ -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; diff --git a/cmds/filesystem-usage.c b/cmds/filesystem-usage.c index eaa732c1..e664ed84 100644 --- a/cmds/filesystem-usage.c +++ b/cmds/filesystem-usage.c @@ -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; diff --git a/cmds/filesystem.c b/cmds/filesystem.c index 8ee17cbe..7ca48dbe 100644 --- a/cmds/filesystem.c +++ b/cmds/filesystem.c @@ -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) { diff --git a/cmds/inspect.c b/cmds/inspect.c index 53a1fce5..9915ecaf 100644 --- a/cmds/inspect.c +++ b/cmds/inspect.c @@ -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; diff --git a/cmds/qgroup.c b/cmds/qgroup.c index 61c6505a..20cc14aa 100644 --- a/cmds/qgroup.c +++ b/cmds/qgroup.c @@ -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; diff --git a/cmds/quota.c b/cmds/quota.c index adf7bf1a..8023e9b2 100644 --- a/cmds/quota.c +++ b/cmds/quota.c @@ -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; diff --git a/cmds/replace.c b/cmds/replace.c index 14c4d174..025fb323 100644 --- a/cmds/replace.c +++ b/cmds/replace.c @@ -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; diff --git a/cmds/subvolume-list.c b/cmds/subvolume-list.c index a26e8b02..c9ad9830 100644 --- a/cmds/subvolume-list.c +++ b/cmds/subvolume-list.c @@ -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); diff --git a/cmds/subvolume.c b/cmds/subvolume.c index 5ebe685c..2b31a436 100644 --- a/cmds/subvolume.c +++ b/cmds/subvolume.c @@ -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; diff --git a/common/open-utils.c b/common/open-utils.c index 55e5d37a..659b7659 100644 --- a/common/open-utils.c +++ b/common/open-utils.c @@ -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; diff --git a/common/open-utils.h b/common/open-utils.h index 249c7fbc..cc22931a 100644 --- a/common/open-utils.h +++ b/common/open-utils.h @@ -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