mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/kdave/btrfs-progs.git
synced 2024-12-12 21:53:43 +08:00
btrfs-progs: qgroup: use btrfs_open_dir for btrfs qgroup command
We can use btrfs_open_dir() to check whether target dir is in btrfs's mount point before open, instead of checking it in kernel space of ioctl, and return fuzzy error message. Before patch: # ./btrfs qgroup create 1/5 /mnt/tmp1 ERROR: unable to create quota group: Inappropriate ioctl for device # # ./btrfs qgroup assign 1/5 2/5 /mnt/tmp1 ERROR: unable to assign quota group: Inappropriate ioctl for device # # ./btrfs qgroup show /mnt/tmp1 ERROR: can't perform the search - Inappropriate ioctl for device ERROR: can't list qgroups: Inappropriate ioctl for device # # ./btrfs qgroup limit 1G 1/5 /mnt/tmp1 ERROR: unable to limit requested quota group: Inappropriate ioctl for device After patch: # ./btrfs qgroup create 1/5 /mnt/tmp1 ERROR: not a btrfs filesystem: /mnt/tmp1 # ./btrfs qgroup assign 1/5 2/5 /mnt/tmp1 ERROR: not a btrfs filesystem: /mnt/tmp1 # ./btrfs qgroup show /mnt/tmp1 ERROR: not a btrfs filesystem: /mnt/tmp1 # ./btrfs qgroup limit 1G 1/5 /mnt/tmp1 ERROR: not a btrfs filesystem: /mnt/tmp1 Signed-off-by: Zhao Lei <zhaolei@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
parent
7c2bad665e
commit
bbbe7fd7d0
@ -79,11 +79,9 @@ static int qgroup_assign(int assign, int argc, char **argv)
|
||||
fprintf(stderr, "ERROR: bad relation requested '%s'\n", path);
|
||||
return 1;
|
||||
}
|
||||
fd = open_file_or_dir(path, &dirstream);
|
||||
if (fd < 0) {
|
||||
fprintf(stderr, "ERROR: can't access '%s'\n", path);
|
||||
fd = btrfs_open_dir(path, &dirstream, 1);
|
||||
if (fd < 0)
|
||||
return 1;
|
||||
}
|
||||
|
||||
ret = ioctl(fd, BTRFS_IOC_QGROUP_ASSIGN, &args);
|
||||
e = errno;
|
||||
@ -137,11 +135,9 @@ static int qgroup_create(int create, int argc, char **argv)
|
||||
args.create = create;
|
||||
args.qgroupid = parse_qgroupid(argv[1]);
|
||||
|
||||
fd = open_file_or_dir(path, &dirstream);
|
||||
if (fd < 0) {
|
||||
fprintf(stderr, "ERROR: can't access '%s'\n", path);
|
||||
fd = btrfs_open_dir(path, &dirstream, 1);
|
||||
if (fd < 0)
|
||||
return 1;
|
||||
}
|
||||
|
||||
ret = ioctl(fd, BTRFS_IOC_QGROUP_CREATE, &args);
|
||||
e = errno;
|
||||
@ -351,11 +347,9 @@ static int cmd_qgroup_show(int argc, char **argv)
|
||||
usage(cmd_qgroup_show_usage);
|
||||
|
||||
path = argv[optind];
|
||||
fd = open_file_or_dir(path, &dirstream);
|
||||
if (fd < 0) {
|
||||
fprintf(stderr, "ERROR: can't access '%s'\n", path);
|
||||
fd = btrfs_open_dir(path, &dirstream, 1);
|
||||
if (fd < 0)
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (filter_flag) {
|
||||
qgroupid = btrfs_get_path_rootid(fd);
|
||||
@ -460,11 +454,9 @@ static int cmd_qgroup_limit(int argc, char **argv)
|
||||
} else
|
||||
usage(cmd_qgroup_limit_usage);
|
||||
|
||||
fd = open_file_or_dir(path, &dirstream);
|
||||
if (fd < 0) {
|
||||
fprintf(stderr, "ERROR: can't access '%s'\n", path);
|
||||
fd = btrfs_open_dir(path, &dirstream, 1);
|
||||
if (fd < 0)
|
||||
return 1;
|
||||
}
|
||||
|
||||
ret = ioctl(fd, BTRFS_IOC_QGROUP_LIMIT, &args);
|
||||
e = errno;
|
||||
|
Loading…
Reference in New Issue
Block a user