Message ID | 1634562591-5830-2-git-send-email-xuyang2018.jy@fujitsu.com |
---|---|
State | Changes Requested |
Headers | show |
Series | [v1,01/11] syscalls/quotactl01: Also test with vfsv1 format | expand |
Hi All For this patch, vfsv0 and vfsv1 should have different limit when tesing ERANGE error. vfsv0: 2^42 bytes vfsv11: 2^63 -1 bytes (Also sent a patch to man-pages) after kernel 4.1[1]. --- a/testcases/kernel/syscalls/quotactl/quotactl06.c +++ b/testcases/kernel/syscalls/quotactl/quotactl06.c @@ -175,10 +175,12 @@ static void setup(void) tst_res(TINFO, "quotactl() with vfsv1 format"); SAFE_CMD(vfsv1_cmd, NULL, NULL); fmt_id = QFMT_VFS_V1; + set_dqmax.dqb_bsoftlimit = 0x20000000000000; //2^53 << 10 } else { tst_res(TINFO, "quotactl() with vfsv0 format"); SAFE_CMD(vfsv0_cmd, NULL, NULL); fmt_id = QFMT_VFS_V0; + set_dqmax.dqb_bsoftlimit = 0x100000000; // 2^32 << 10 } if (access(USRPATH, F_OK) == -1) Also for old kernel ie centos7 without patch[2], we can't meet ERANGE error for vfsv1 format because it doesn't use block shift. [1]https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit?id=7e08da50cf [2]https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit?id=14bf61ff Best Regards Yang Xu > Signed-off-by: Yang Xu<xuyang2018.jy@fujitsu.com> > --- > .../kernel/syscalls/quotactl/quotactl06.c | 59 +++++++++++++++---- > 1 file changed, 46 insertions(+), 13 deletions(-) > > diff --git a/testcases/kernel/syscalls/quotactl/quotactl06.c b/testcases/kernel/syscalls/quotactl/quotactl06.c > index a10d1ca07..f53f088d8 100644 > --- a/testcases/kernel/syscalls/quotactl/quotactl06.c > +++ b/testcases/kernel/syscalls/quotactl/quotactl06.c > @@ -1,26 +1,42 @@ > // SPDX-License-Identifier: GPL-2.0-or-later > /* > - * Copyright (c) 2019 FUJITSU LIMITED. All rights reserved. > + * Copyright (c) 2019-2021 FUJITSU LIMITED. All rights reserved. > * Author: Yang Xu<xuyang2018.jy@cn.fujitsu.com> > + */ > + > +/*\ > + * [Description] > + * > + * Tests basic error handling of the quotactl syscall with visible quota files > + * (cover two formats, vfsv0 and vfsv1): > * > - * Tests basic error handling of the quotactl syscall. > * 1) quotactl fails with EACCES when cmd is Q_QUOTAON and addr > * existed but not a regular file. > + * > * 2) quotaclt fails with ENOENT when the file specified by special > * or addr does not exist. > + * > * 3) quotactl fails with EBUSTY when cmd is Q_QUOTAON and another > * Q_QUOTAON had already been performed. > + * > * 4) quotactl fails with EFAULT when addr or special is invalid. > + * > * 5) quotactl fails with EINVAL when cmd or type is invalid. > + * > * 6) quotactl fails with ENOTBLK when special is not a block device. > + * > * 7) quotactl fails with ESRCH when no disk quota is found for the > * indicated user and quotas have not been turned on for this fs. > + * > * 8) quotactl fails with ESRCH when cmd is Q_QUOTAON, but the quota > * format was not found. > + * > * 9) quotactl fails with ESRCH when cmd is Q_GETNEXTQUOTA, but there > * is no ID greater than or equal to id that has an active quota. > + * > * 10) quotactl fails with ERANGE when cmd is Q_SETQUOTA, but the > * specified limits are out of the range allowed by the quota format. > + * > * 11) quotactl fails with EPERM when the caller lacked the required > * privilege (CAP_SYS_ADMIN) for the specified operation. > */ > @@ -32,10 +48,7 @@ > #include "tst_capability.h" > > #define OPTION_INVALID 999 > -#define QFMT_VFS_V0 2 > #define USRPATH MNTPOINT "/aquota.user" > -#define FMTID QFMT_VFS_V0 > - > #define MNTPOINT "mntpoint" > #define TESTDIR1 MNTPOINT "/testdir1" > #define TESTDIR2 MNTPOINT "/testdir2" > @@ -43,10 +56,10 @@ > static char usrpath[] = USRPATH; > static char testdir1[] = TESTDIR1; > static char testdir2[] = TESTDIR2; > -static int32_t fmt_id = FMTID; > +static int32_t fmt_id; > static int32_t fmt_invalid = 999; > static int test_invalid; > -static int test_id; > +static int test_id, mount_flag; > static int getnextquota_nsup; > > static struct if_nextdqblk res_ndq; > @@ -105,7 +118,7 @@ static void verify_quotactl(unsigned int n) > > if (tc->on_flag) { > TEST(quotactl(QCMD(Q_QUOTAON, USRQUOTA), tst_device->dev, > - FMTID, usrpath)); > + fmt_id, usrpath)); > if (TST_RET == -1) > tst_brk(TBROK, > "quotactl with Q_QUOTAON returned %ld", TST_RET); > @@ -135,7 +148,7 @@ static void verify_quotactl(unsigned int n) > > if (quota_on) { > TEST(quotactl(QCMD(Q_QUOTAOFF, USRQUOTA), tst_device->dev, > - FMTID, usrpath)); > + fmt_id, usrpath)); > if (TST_RET == -1) > tst_brk(TBROK, > "quotactl with Q_QUOTAOFF returned %ld", TST_RET); > @@ -150,10 +163,23 @@ static void verify_quotactl(unsigned int n) > > static void setup(void) > { > - const char *const cmd[] = {"quotacheck", "-uF", "vfsv0", MNTPOINT, NULL}; > + const char *const vfsv0_cmd[] = {"quotacheck", "-uF", "vfsv0", MNTPOINT, NULL}; > + const char *const vfsv1_cmd[] = {"quotacheck", "-uF", "vfsv1", MNTPOINT, NULL}; > unsigned int i; > > - SAFE_CMD(cmd, NULL, NULL); > + SAFE_MKFS(tst_device->dev, tst_device->fs_type, NULL, NULL); > + SAFE_MOUNT(tst_device->dev, MNTPOINT, tst_device->fs_type, 0, "usrquota"); > + mount_flag = 1; > + > + if (tst_variant) { > + tst_res(TINFO, "quotactl() with vfsv1 format"); > + SAFE_CMD(vfsv1_cmd, NULL, NULL); > + fmt_id = QFMT_VFS_V1; > + } else { > + tst_res(TINFO, "quotactl() with vfsv0 format"); > + SAFE_CMD(vfsv0_cmd, NULL, NULL); > + fmt_id = QFMT_VFS_V0; > + } > > if (access(USRPATH, F_OK) == -1) > tst_brk(TFAIL | TERRNO, "user quotafile didn't exist"); > @@ -175,8 +201,15 @@ static void setup(void) > } > } > > +static void cleanup(void) > +{ > + if (mount_flag&& tst_umount(MNTPOINT)) > + tst_res(TWARN | TERRNO, "umount(%s)", MNTPOINT); > +} > + > static struct tst_test test = { > .setup = setup, > + .cleanup = cleanup, > .needs_kconfigs = (const char *[]) { > "CONFIG_QFMT_V2", > NULL > @@ -185,11 +218,11 @@ static struct tst_test test = { > .test = verify_quotactl, > .dev_fs_type = "ext4", > .mntpoint = MNTPOINT, > - .mount_device = 1, > - .mnt_data = "usrquota", > + .needs_device = 1, > .needs_cmds = (const char *const []) { > "quotacheck", > NULL > }, > .needs_root = 1, > + .test_variants = 2, > };
Hi! > --- a/testcases/kernel/syscalls/quotactl/quotactl06.c > +++ b/testcases/kernel/syscalls/quotactl/quotactl06.c > @@ -1,26 +1,42 @@ > // SPDX-License-Identifier: GPL-2.0-or-later > /* > - * Copyright (c) 2019 FUJITSU LIMITED. All rights reserved. > + * Copyright (c) 2019-2021 FUJITSU LIMITED. All rights reserved. > * Author: Yang Xu <xuyang2018.jy@cn.fujitsu.com> > + */ > + > +/*\ > + * [Description] > + * > + * Tests basic error handling of the quotactl syscall with visible quota files > + * (cover two formats, vfsv0 and vfsv1): > * > - * Tests basic error handling of the quotactl syscall. > * 1) quotactl fails with EACCES when cmd is Q_QUOTAON and addr > * existed but not a regular file. > + * > * 2) quotaclt fails with ENOENT when the file specified by special > * or addr does not exist. > + * > * 3) quotactl fails with EBUSTY when cmd is Q_QUOTAON and another > * Q_QUOTAON had already been performed. > + * > * 4) quotactl fails with EFAULT when addr or special is invalid. > + * > * 5) quotactl fails with EINVAL when cmd or type is invalid. > + * > * 6) quotactl fails with ENOTBLK when special is not a block device. > + * > * 7) quotactl fails with ESRCH when no disk quota is found for the > * indicated user and quotas have not been turned on for this fs. > + * > * 8) quotactl fails with ESRCH when cmd is Q_QUOTAON, but the quota > * format was not found. > + * > * 9) quotactl fails with ESRCH when cmd is Q_GETNEXTQUOTA, but there > * is no ID greater than or equal to id that has an active quota. > + * > * 10) quotactl fails with ERANGE when cmd is Q_SETQUOTA, but the > * specified limits are out of the range allowed by the quota format. > + * > * 11) quotactl fails with EPERM when the caller lacked the required > * privilege (CAP_SYS_ADMIN) for the specified operation. > */ Same comments apply here as well. > @@ -32,10 +48,7 @@ > #include "tst_capability.h" > > #define OPTION_INVALID 999 > -#define QFMT_VFS_V0 2 > #define USRPATH MNTPOINT "/aquota.user" > -#define FMTID QFMT_VFS_V0 > - > #define MNTPOINT "mntpoint" > #define TESTDIR1 MNTPOINT "/testdir1" > #define TESTDIR2 MNTPOINT "/testdir2" > @@ -43,10 +56,10 @@ > static char usrpath[] = USRPATH; > static char testdir1[] = TESTDIR1; > static char testdir2[] = TESTDIR2; > -static int32_t fmt_id = FMTID; > +static int32_t fmt_id; > static int32_t fmt_invalid = 999; > static int test_invalid; > -static int test_id; > +static int test_id, mount_flag; > static int getnextquota_nsup; > > static struct if_nextdqblk res_ndq; > @@ -105,7 +118,7 @@ static void verify_quotactl(unsigned int n) > > if (tc->on_flag) { > TEST(quotactl(QCMD(Q_QUOTAON, USRQUOTA), tst_device->dev, > - FMTID, usrpath)); > + fmt_id, usrpath)); > if (TST_RET == -1) > tst_brk(TBROK, > "quotactl with Q_QUOTAON returned %ld", TST_RET); > @@ -135,7 +148,7 @@ static void verify_quotactl(unsigned int n) > > if (quota_on) { > TEST(quotactl(QCMD(Q_QUOTAOFF, USRQUOTA), tst_device->dev, > - FMTID, usrpath)); > + fmt_id, usrpath)); > if (TST_RET == -1) > tst_brk(TBROK, > "quotactl with Q_QUOTAOFF returned %ld", TST_RET); > @@ -150,10 +163,23 @@ static void verify_quotactl(unsigned int n) > > static void setup(void) > { > - const char *const cmd[] = {"quotacheck", "-uF", "vfsv0", MNTPOINT, NULL}; > + const char *const vfsv0_cmd[] = {"quotacheck", "-uF", "vfsv0", MNTPOINT, NULL}; > + const char *const vfsv1_cmd[] = {"quotacheck", "-uF", "vfsv1", MNTPOINT, NULL}; If we are going to repeat this snippet in each test it may make sense to put it into a header as we do with variants: static struct quotactl_variant { int32_t fmt_id; const char *fmt_name; } variants[] = { {.fmt_id = QFMT_VFS_V0, .fmt_name = "vfsv0"} {.fmt_id = QFMT_VFS_V1, .fmt_name = "vfsv1"} }; Then we can construct the rest easily from these as: const char *const cmd[] = {"quotacheck", "-uF", variants[variant].fmt_name, MNTPOINT, NULL}; tst_res(TINFO, "quotactl() with %s format", variants[variant].fmt_name); SAFE_CMD(cmd, NULL, NULL); fmt_id = variants[variant].fmt_id; > unsigned int i; > > - SAFE_CMD(cmd, NULL, NULL); > + SAFE_MKFS(tst_device->dev, tst_device->fs_type, NULL, NULL); > + SAFE_MOUNT(tst_device->dev, MNTPOINT, tst_device->fs_type, 0, "usrquota"); > + mount_flag = 1; > + > + if (tst_variant) { > + tst_res(TINFO, "quotactl() with vfsv1 format"); > + SAFE_CMD(vfsv1_cmd, NULL, NULL); > + fmt_id = QFMT_VFS_V1; > + } else { > + tst_res(TINFO, "quotactl() with vfsv0 format"); > + SAFE_CMD(vfsv0_cmd, NULL, NULL); > + fmt_id = QFMT_VFS_V0; > + } > > if (access(USRPATH, F_OK) == -1) > tst_brk(TFAIL | TERRNO, "user quotafile didn't exist"); > @@ -175,8 +201,15 @@ static void setup(void) > } > } > > +static void cleanup(void) > +{ > + if (mount_flag && tst_umount(MNTPOINT)) > + tst_res(TWARN | TERRNO, "umount(%s)", MNTPOINT); > +} > + > static struct tst_test test = { > .setup = setup, > + .cleanup = cleanup, > .needs_kconfigs = (const char *[]) { > "CONFIG_QFMT_V2", > NULL > @@ -185,11 +218,11 @@ static struct tst_test test = { > .test = verify_quotactl, > .dev_fs_type = "ext4", > .mntpoint = MNTPOINT, > - .mount_device = 1, > - .mnt_data = "usrquota", > + .needs_device = 1, > .needs_cmds = (const char *const []) { > "quotacheck", > NULL > }, > .needs_root = 1, > + .test_variants = 2, > }; > -- > 2.23.0 > > > -- > Mailing list info: https://lists.linux.it/listinfo/ltp
Hi Cyril > Hi! >> --- a/testcases/kernel/syscalls/quotactl/quotactl06.c >> +++ b/testcases/kernel/syscalls/quotactl/quotactl06.c >> @@ -1,26 +1,42 @@ >> // SPDX-License-Identifier: GPL-2.0-or-later >> /* >> - * Copyright (c) 2019 FUJITSU LIMITED. All rights reserved. >> + * Copyright (c) 2019-2021 FUJITSU LIMITED. All rights reserved. >> * Author: Yang Xu<xuyang2018.jy@cn.fujitsu.com> >> + */ >> + >> +/*\ >> + * [Description] >> + * >> + * Tests basic error handling of the quotactl syscall with visible quota files >> + * (cover two formats, vfsv0 and vfsv1): >> * >> - * Tests basic error handling of the quotactl syscall. >> * 1) quotactl fails with EACCES when cmd is Q_QUOTAON and addr >> * existed but not a regular file. >> + * >> * 2) quotaclt fails with ENOENT when the file specified by special >> * or addr does not exist. >> + * >> * 3) quotactl fails with EBUSTY when cmd is Q_QUOTAON and another >> * Q_QUOTAON had already been performed. >> + * >> * 4) quotactl fails with EFAULT when addr or special is invalid. >> + * >> * 5) quotactl fails with EINVAL when cmd or type is invalid. >> + * >> * 6) quotactl fails with ENOTBLK when special is not a block device. >> + * >> * 7) quotactl fails with ESRCH when no disk quota is found for the >> * indicated user and quotas have not been turned on for this fs. >> + * >> * 8) quotactl fails with ESRCH when cmd is Q_QUOTAON, but the quota >> * format was not found. >> + * >> * 9) quotactl fails with ESRCH when cmd is Q_GETNEXTQUOTA, but there >> * is no ID greater than or equal to id that has an active quota. >> + * >> * 10) quotactl fails with ERANGE when cmd is Q_SETQUOTA, but the >> * specified limits are out of the range allowed by the quota format. >> + * >> * 11) quotactl fails with EPERM when the caller lacked the required >> * privilege (CAP_SYS_ADMIN) for the specified operation. >> */ > > Same comments apply here as well. Got it. >> @@ -32,10 +48,7 @@ >> #include "tst_capability.h" >> >> #define OPTION_INVALID 999 >> -#define QFMT_VFS_V0 2 >> #define USRPATH MNTPOINT "/aquota.user" >> -#define FMTID QFMT_VFS_V0 >> - >> #define MNTPOINT "mntpoint" >> #define TESTDIR1 MNTPOINT "/testdir1" >> #define TESTDIR2 MNTPOINT "/testdir2" >> @@ -43,10 +56,10 @@ >> static char usrpath[] = USRPATH; >> static char testdir1[] = TESTDIR1; >> static char testdir2[] = TESTDIR2; >> -static int32_t fmt_id = FMTID; >> +static int32_t fmt_id; >> static int32_t fmt_invalid = 999; >> static int test_invalid; >> -static int test_id; >> +static int test_id, mount_flag; >> static int getnextquota_nsup; >> >> static struct if_nextdqblk res_ndq; >> @@ -105,7 +118,7 @@ static void verify_quotactl(unsigned int n) >> >> if (tc->on_flag) { >> TEST(quotactl(QCMD(Q_QUOTAON, USRQUOTA), tst_device->dev, >> - FMTID, usrpath)); >> + fmt_id, usrpath)); >> if (TST_RET == -1) >> tst_brk(TBROK, >> "quotactl with Q_QUOTAON returned %ld", TST_RET); >> @@ -135,7 +148,7 @@ static void verify_quotactl(unsigned int n) >> >> if (quota_on) { >> TEST(quotactl(QCMD(Q_QUOTAOFF, USRQUOTA), tst_device->dev, >> - FMTID, usrpath)); >> + fmt_id, usrpath)); >> if (TST_RET == -1) >> tst_brk(TBROK, >> "quotactl with Q_QUOTAOFF returned %ld", TST_RET); >> @@ -150,10 +163,23 @@ static void verify_quotactl(unsigned int n) >> >> static void setup(void) >> { >> - const char *const cmd[] = {"quotacheck", "-uF", "vfsv0", MNTPOINT, NULL}; >> + const char *const vfsv0_cmd[] = {"quotacheck", "-uF", "vfsv0", MNTPOINT, NULL}; >> + const char *const vfsv1_cmd[] = {"quotacheck", "-uF", "vfsv1", MNTPOINT, NULL}; > > If we are going to repeat this snippet in each test it may make sense to > put it into a header as we do with variants: > > static struct quotactl_variant { > int32_t fmt_id; > const char *fmt_name; > } variants[] = { > {.fmt_id = QFMT_VFS_V0, .fmt_name = "vfsv0"} > {.fmt_id = QFMT_VFS_V1, .fmt_name = "vfsv1"} > }; > > Then we can construct the rest easily from these as: > > const char *const cmd[] = {"quotacheck", "-uF", variants[variant].fmt_name, MNTPOINT, NULL}; > > tst_res(TINFO, "quotactl() with %s format", variants[variant].fmt_name); > > SAFE_CMD(cmd, NULL, NULL); > fmt_id = variants[variant].fmt_id; Sounds great. Best Regards Yang Xu > > >> unsigned int i; >> >> - SAFE_CMD(cmd, NULL, NULL); >> + SAFE_MKFS(tst_device->dev, tst_device->fs_type, NULL, NULL); >> + SAFE_MOUNT(tst_device->dev, MNTPOINT, tst_device->fs_type, 0, "usrquota"); >> + mount_flag = 1; >> + >> + if (tst_variant) { >> + tst_res(TINFO, "quotactl() with vfsv1 format"); >> + SAFE_CMD(vfsv1_cmd, NULL, NULL); >> + fmt_id = QFMT_VFS_V1; >> + } else { >> + tst_res(TINFO, "quotactl() with vfsv0 format"); >> + SAFE_CMD(vfsv0_cmd, NULL, NULL); >> + fmt_id = QFMT_VFS_V0; >> + } >> >> if (access(USRPATH, F_OK) == -1) >> tst_brk(TFAIL | TERRNO, "user quotafile didn't exist"); >> @@ -175,8 +201,15 @@ static void setup(void) >> } >> } >> >> +static void cleanup(void) >> +{ >> + if (mount_flag&& tst_umount(MNTPOINT)) >> + tst_res(TWARN | TERRNO, "umount(%s)", MNTPOINT); >> +} >> + >> static struct tst_test test = { >> .setup = setup, >> + .cleanup = cleanup, >> .needs_kconfigs = (const char *[]) { >> "CONFIG_QFMT_V2", >> NULL >> @@ -185,11 +218,11 @@ static struct tst_test test = { >> .test = verify_quotactl, >> .dev_fs_type = "ext4", >> .mntpoint = MNTPOINT, >> - .mount_device = 1, >> - .mnt_data = "usrquota", >> + .needs_device = 1, >> .needs_cmds = (const char *const []) { >> "quotacheck", >> NULL >> }, >> .needs_root = 1, >> + .test_variants = 2, >> }; >> -- >> 2.23.0 >> >> >> -- >> Mailing list info: https://lists.linux.it/listinfo/ltp >
diff --git a/testcases/kernel/syscalls/quotactl/quotactl06.c b/testcases/kernel/syscalls/quotactl/quotactl06.c index a10d1ca07..f53f088d8 100644 --- a/testcases/kernel/syscalls/quotactl/quotactl06.c +++ b/testcases/kernel/syscalls/quotactl/quotactl06.c @@ -1,26 +1,42 @@ // SPDX-License-Identifier: GPL-2.0-or-later /* - * Copyright (c) 2019 FUJITSU LIMITED. All rights reserved. + * Copyright (c) 2019-2021 FUJITSU LIMITED. All rights reserved. * Author: Yang Xu <xuyang2018.jy@cn.fujitsu.com> + */ + +/*\ + * [Description] + * + * Tests basic error handling of the quotactl syscall with visible quota files + * (cover two formats, vfsv0 and vfsv1): * - * Tests basic error handling of the quotactl syscall. * 1) quotactl fails with EACCES when cmd is Q_QUOTAON and addr * existed but not a regular file. + * * 2) quotaclt fails with ENOENT when the file specified by special * or addr does not exist. + * * 3) quotactl fails with EBUSTY when cmd is Q_QUOTAON and another * Q_QUOTAON had already been performed. + * * 4) quotactl fails with EFAULT when addr or special is invalid. + * * 5) quotactl fails with EINVAL when cmd or type is invalid. + * * 6) quotactl fails with ENOTBLK when special is not a block device. + * * 7) quotactl fails with ESRCH when no disk quota is found for the * indicated user and quotas have not been turned on for this fs. + * * 8) quotactl fails with ESRCH when cmd is Q_QUOTAON, but the quota * format was not found. + * * 9) quotactl fails with ESRCH when cmd is Q_GETNEXTQUOTA, but there * is no ID greater than or equal to id that has an active quota. + * * 10) quotactl fails with ERANGE when cmd is Q_SETQUOTA, but the * specified limits are out of the range allowed by the quota format. + * * 11) quotactl fails with EPERM when the caller lacked the required * privilege (CAP_SYS_ADMIN) for the specified operation. */ @@ -32,10 +48,7 @@ #include "tst_capability.h" #define OPTION_INVALID 999 -#define QFMT_VFS_V0 2 #define USRPATH MNTPOINT "/aquota.user" -#define FMTID QFMT_VFS_V0 - #define MNTPOINT "mntpoint" #define TESTDIR1 MNTPOINT "/testdir1" #define TESTDIR2 MNTPOINT "/testdir2" @@ -43,10 +56,10 @@ static char usrpath[] = USRPATH; static char testdir1[] = TESTDIR1; static char testdir2[] = TESTDIR2; -static int32_t fmt_id = FMTID; +static int32_t fmt_id; static int32_t fmt_invalid = 999; static int test_invalid; -static int test_id; +static int test_id, mount_flag; static int getnextquota_nsup; static struct if_nextdqblk res_ndq; @@ -105,7 +118,7 @@ static void verify_quotactl(unsigned int n) if (tc->on_flag) { TEST(quotactl(QCMD(Q_QUOTAON, USRQUOTA), tst_device->dev, - FMTID, usrpath)); + fmt_id, usrpath)); if (TST_RET == -1) tst_brk(TBROK, "quotactl with Q_QUOTAON returned %ld", TST_RET); @@ -135,7 +148,7 @@ static void verify_quotactl(unsigned int n) if (quota_on) { TEST(quotactl(QCMD(Q_QUOTAOFF, USRQUOTA), tst_device->dev, - FMTID, usrpath)); + fmt_id, usrpath)); if (TST_RET == -1) tst_brk(TBROK, "quotactl with Q_QUOTAOFF returned %ld", TST_RET); @@ -150,10 +163,23 @@ static void verify_quotactl(unsigned int n) static void setup(void) { - const char *const cmd[] = {"quotacheck", "-uF", "vfsv0", MNTPOINT, NULL}; + const char *const vfsv0_cmd[] = {"quotacheck", "-uF", "vfsv0", MNTPOINT, NULL}; + const char *const vfsv1_cmd[] = {"quotacheck", "-uF", "vfsv1", MNTPOINT, NULL}; unsigned int i; - SAFE_CMD(cmd, NULL, NULL); + SAFE_MKFS(tst_device->dev, tst_device->fs_type, NULL, NULL); + SAFE_MOUNT(tst_device->dev, MNTPOINT, tst_device->fs_type, 0, "usrquota"); + mount_flag = 1; + + if (tst_variant) { + tst_res(TINFO, "quotactl() with vfsv1 format"); + SAFE_CMD(vfsv1_cmd, NULL, NULL); + fmt_id = QFMT_VFS_V1; + } else { + tst_res(TINFO, "quotactl() with vfsv0 format"); + SAFE_CMD(vfsv0_cmd, NULL, NULL); + fmt_id = QFMT_VFS_V0; + } if (access(USRPATH, F_OK) == -1) tst_brk(TFAIL | TERRNO, "user quotafile didn't exist"); @@ -175,8 +201,15 @@ static void setup(void) } } +static void cleanup(void) +{ + if (mount_flag && tst_umount(MNTPOINT)) + tst_res(TWARN | TERRNO, "umount(%s)", MNTPOINT); +} + static struct tst_test test = { .setup = setup, + .cleanup = cleanup, .needs_kconfigs = (const char *[]) { "CONFIG_QFMT_V2", NULL @@ -185,11 +218,11 @@ static struct tst_test test = { .test = verify_quotactl, .dev_fs_type = "ext4", .mntpoint = MNTPOINT, - .mount_device = 1, - .mnt_data = "usrquota", + .needs_device = 1, .needs_cmds = (const char *const []) { "quotacheck", NULL }, .needs_root = 1, + .test_variants = 2, };
Signed-off-by: Yang Xu <xuyang2018.jy@fujitsu.com> --- .../kernel/syscalls/quotactl/quotactl06.c | 59 +++++++++++++++---- 1 file changed, 46 insertions(+), 13 deletions(-)