btrfs-progs: qgroup: Check for ENOTCONN error on create/assign/limit

When kernel returns ENOTCONN after the user tries to create a qgroup on
a subvolume without quota enabled, present a meaningful message to the
user. Kernels before 5.5 return EINVAL for that.

Reviewed-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: Marcos Paulo de Souza <mpdesouza@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
master
Marcos Paulo de Souza 2019-11-27 00:48:51 -03:00 committed by David Sterba
parent f0c607a137
commit 6038a5686c
1 changed files with 11 additions and 4 deletions

View File

@ -98,7 +98,9 @@ static int _cmd_qgroup_assign(const struct cmd_struct *cmd, int assign,
ret = ioctl(fd, BTRFS_IOC_QGROUP_ASSIGN, &args);
if (ret < 0) {
error("unable to assign quota group: %m");
error("unable to assign quota group: %s",
errno == ENOTCONN ? "quota not enabled"
: strerror(errno));
close_file_or_dir(fd, dirstream);
return 1;
}
@ -152,8 +154,10 @@ static int _cmd_qgroup_create(int create, int argc, char **argv)
ret = ioctl(fd, BTRFS_IOC_QGROUP_CREATE, &args);
close_file_or_dir(fd, dirstream);
if (ret < 0) {
error("unable to %s quota group: %m",
create ? "create":"destroy");
error("unable to %s quota group: %s",
create ? "create":"destroy",
errno == ENOTCONN ? "quota not enabled"
: strerror(errno));
return 1;
}
return 0;
@ -447,7 +451,10 @@ static int cmd_qgroup_limit(const struct cmd_struct *cmd, int argc, char **argv)
ret = ioctl(fd, BTRFS_IOC_QGROUP_LIMIT, &args);
close_file_or_dir(fd, dirstream);
if (ret < 0) {
error("unable to limit requested quota group: %m");
error("unable to limit requested quota group: %s",
errno == ENOTCONN ? "quota not enabled"
: strerror(errno));
return 1;
}
return 0;