* [LTP] [PATCH v2 06/13] lapi/quotactl.h: Add fallback for quotactl_fd @ 2021-10-27 12:28 Yang Xu 2021-10-27 12:28 ` [LTP] [PATCH v2 07/13] syscalls/quotactl08: Test quoatctl01 but quota info hidden in filesystem Yang Xu ` (3 more replies) 0 siblings, 4 replies; 6+ messages in thread From: Yang Xu @ 2021-10-27 12:28 UTC (permalink / raw) To: ltp Signed-off-by: Yang Xu <xuyang2018.jy@fujitsu.com> --- configure.ac | 1 + include/lapi/quotactl.h | 12 ++++++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/configure.ac b/configure.ac index 5bf3c52ec..859aa9857 100644 --- a/configure.ac +++ b/configure.ac @@ -122,6 +122,7 @@ AC_CHECK_FUNCS_ONCE([ \ profil \ pwritev \ pwritev2 \ + quotactl_fd \ rand_r \ readlinkat \ recvmmsg \ diff --git a/include/lapi/quotactl.h b/include/lapi/quotactl.h index 8e0315d03..739a85616 100644 --- a/include/lapi/quotactl.h +++ b/include/lapi/quotactl.h @@ -1,8 +1,8 @@ // SPDX-License-Identifier: GPL-2.0-or-later /* - * Copyright (c) 2017-2019 Fujitsu Ltd. + * Copyright (c) 2017-2021 FUJITSU LIMITED. All rights reserved * Author: Xiao Yang <yangx.jy@cn.fujitsu.com> - * Author: Yang Xu <xuyang2018.jy@cn.jujitsu.com> + * Author: Yang Xu <xuyang2018.jy@fujitsu.com> */ #ifndef LAPI_QUOTACTL_H__ @@ -10,6 +10,14 @@ #include "config.h" #include <sys/quota.h> +#include "lapi/syscalls.h" + +#ifndef HAVE_QUOTACTL_FD +static inline int quotactl_fd(int fd, int cmd, int id, caddr_t addr) +{ + return tst_syscall(__NR_quotactl_fd, fd, cmd, id, addr); +} +#endif #ifdef HAVE_STRUCT_IF_NEXTDQBLK # include <linux/quota.h> -- 2.23.0 -- Mailing list info: https://lists.linux.it/listinfo/ltp ^ permalink raw reply related [flat|nested] 6+ messages in thread
* [LTP] [PATCH v2 07/13] syscalls/quotactl08: Test quoatctl01 but quota info hidden in filesystem 2021-10-27 12:28 [LTP] [PATCH v2 06/13] lapi/quotactl.h: Add fallback for quotactl_fd Yang Xu @ 2021-10-27 12:28 ` Yang Xu 2021-10-28 2:11 ` xuyang2018.jy 2021-10-27 12:28 ` [LTP] [PATCH v2 08/13] syscalls/quotactl02, 5: Add quotactl_fd test variant Yang Xu ` (2 subsequent siblings) 3 siblings, 1 reply; 6+ messages in thread From: Yang Xu @ 2021-10-27 12:28 UTC (permalink / raw) To: ltp It uses two variants(quotactl and quotactl_fd). The difference for quotactl01 is that we don't use quotacheck command and quota info hidden in filesystem. It also needs mkfs.ext4 supports quota feature. Signed-off-by: Yang Xu <xuyang2018.jy@fujitsu.com> --- runtest/syscalls | 1 + testcases/kernel/syscalls/quotactl/.gitignore | 1 + .../kernel/syscalls/quotactl/quotactl08.c | 217 ++++++++++++++++++ .../syscalls/quotactl/quotactl_syscall_var.h | 29 +++ 4 files changed, 248 insertions(+) create mode 100644 testcases/kernel/syscalls/quotactl/quotactl08.c create mode 100644 testcases/kernel/syscalls/quotactl/quotactl_syscall_var.h diff --git a/runtest/syscalls b/runtest/syscalls index b19316805..cdeb3e142 100644 --- a/runtest/syscalls +++ b/runtest/syscalls @@ -1073,6 +1073,7 @@ quotactl04 quotactl04 quotactl05 quotactl05 quotactl06 quotactl06 quotactl07 quotactl07 +quotactl08 quotactl08 read01 read01 read02 read02 diff --git a/testcases/kernel/syscalls/quotactl/.gitignore b/testcases/kernel/syscalls/quotactl/.gitignore index 8d2ef94d9..dab9b3420 100644 --- a/testcases/kernel/syscalls/quotactl/.gitignore +++ b/testcases/kernel/syscalls/quotactl/.gitignore @@ -5,3 +5,4 @@ /quotactl05 /quotactl06 /quotactl07 +/quotactl08 diff --git a/testcases/kernel/syscalls/quotactl/quotactl08.c b/testcases/kernel/syscalls/quotactl/quotactl08.c new file mode 100644 index 000000000..6912378f1 --- /dev/null +++ b/testcases/kernel/syscalls/quotactl/quotactl08.c @@ -0,0 +1,217 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * Copyright (c) 2021 FUJITSU LIMITED. All rights reserved + * Author: Yang Xu <xuyang2018.jy@fujitsu.com> + */ + +/*\ + * [Description] + * This testcases checks that quotactl(2) on ext4 filesystem succeeds to: + * + * - turn on quota with Q_QUOTAON flag for user + * - set disk quota limits with Q_SETQUOTA flag for user + * - get disk quota limits with Q_GETQUOTA flag for user + * - set information about quotafile with Q_SETINFO flag for user + * - get information about quotafile with Q_GETINFO flag for user + * - get quota format with Q_GETFMT flag for user + * - update quota usages with Q_SYNC flag for user + * - get disk quota limit greater than or equal to ID with Q_GETNEXTQUOTA flag for user + * - turn off quota with Q_QUOTAOFF flag for user + * - turn on quota with Q_QUOTAON flag for group + * - set disk quota limits with Q_SETQUOTA flag for group + * - get disk quota limits with Q_GETQUOTA flag for group + * - set information about quotafile with Q_SETINFO flag for group + * - get information about quotafile with Q_GETINFO flag for group + * - get quota format with Q_GETFMT flag for group + * - update quota usages with Q_SYNC flag for group + * - get disk quota limit greater than or equal to ID with Q_GETNEXTQUOTA flag for group + * - turn off quota with Q_QUOTAOFF flag for group + * + * It is similar to quotactl01.c, only two difference + * - use new quotactl_fd syscalls if supports + * - quota file hidden in filesystem + */ + +#include <errno.h> +#include <string.h> +#include <unistd.h> +#include <stdio.h> +#include "tst_test.h" +#include "quotactl_syscall_var.h" +#include "tst_safe_stdio.h" + +#define MNTPOINT "mntpoint" +#define TESTFILE MNTPOINT "/testfile" + +static int32_t fmt_id = QFMT_VFS_V1; +static int test_id, fd = -1; +static struct dqblk set_dq = { + .dqb_bsoftlimit = 100, + .dqb_valid = QIF_BLIMITS +}; +static struct dqblk res_dq; + +static struct dqinfo set_qf = { + .dqi_bgrace = 80, + .dqi_valid = IIF_BGRACE +}; +static struct dqinfo res_qf; +static int32_t fmt_buf; +static int getnextquota_nsup; + +static struct if_nextdqblk res_ndq; + +static struct tcase { + int cmd; + int *id; + void *addr; + void *set_data; + void *res_data; + int sz; + char *des; + char *tname; +} tcases[] = { + {QCMD(Q_QUOTAON, USRQUOTA), &fmt_id, NULL, + NULL, NULL, 0, "turn on quota for user", + "QCMD(Q_QUOTAON, USRQUOTA)"}, + + {QCMD(Q_SETQUOTA, USRQUOTA), &test_id, &set_dq, + NULL, NULL, 0, "set disk quota limit for user", + "QCMD(Q_SETQUOTA, USRQUOTA)"}, + + {QCMD(Q_GETQUOTA, USRQUOTA), &test_id, &res_dq, + &set_dq.dqb_bsoftlimit, &res_dq.dqb_bsoftlimit, + sizeof(res_dq.dqb_bsoftlimit), "get disk quota limit for user", + "QCMD(Q_GETQUOTA, USRQUOTA)"}, + + {QCMD(Q_SETINFO, USRQUOTA), &test_id, &set_qf, + NULL, NULL, 0, "set information about quotafile for user", + "QCMD(Q_SETINFO, USRQUOTA)"}, + + {QCMD(Q_GETINFO, USRQUOTA), &test_id, &res_qf, + &set_qf.dqi_bgrace, &res_qf.dqi_bgrace, sizeof(res_qf.dqi_bgrace), + "get information about quotafile for user", + "QCMD(Q_GETINFO, USRQUOTA)"}, + + {QCMD(Q_GETFMT, USRQUOTA), &test_id, &fmt_buf, + &fmt_id, &fmt_buf, sizeof(fmt_buf), + "get quota format for user", + "QCMD(Q_GETFMT, USRQUOTA)"}, + + {QCMD(Q_SYNC, USRQUOTA), &test_id, &res_dq, + NULL, NULL, 0, "update quota usages for user", + "QCMD(Q_SYNC, USRQUOTA)"}, + + {QCMD(Q_GETNEXTQUOTA, USRQUOTA), &test_id, &res_ndq, + &test_id, &res_ndq.dqb_id, sizeof(res_ndq.dqb_id), + "get next disk quota limit for user", + "QCMD(Q_GETNEXTQUOTA, USRQUOTA)"}, + + {QCMD(Q_QUOTAOFF, USRQUOTA), &test_id, NULL, + NULL, NULL, 0, "turn off quota for user", + "QCMD(Q_QUOTAOFF, USRQUOTA)"}, + + {QCMD(Q_QUOTAON, GRPQUOTA), &fmt_id, NULL, + NULL, NULL, 0, "turn on quota for group", + "QCMD(Q_QUOTAON, GRPQUOTA)"}, + + {QCMD(Q_SETQUOTA, GRPQUOTA), &test_id, &set_dq, + NULL, NULL, 0, "set disk quota limit for group", + "QCMD(Q_SETQUOTA, GRPQUOTA)"}, + + {QCMD(Q_GETQUOTA, GRPQUOTA), &test_id, &res_dq, &set_dq.dqb_bsoftlimit, + &res_dq.dqb_bsoftlimit, sizeof(res_dq.dqb_bsoftlimit), + "set disk quota limit for group", + "QCMD(Q_GETQUOTA, GRPQUOTA)"}, + + {QCMD(Q_SETINFO, GRPQUOTA), &test_id, &set_qf, + NULL, NULL, 0, "set information about quotafile for group", + "QCMD(Q_SETINFO, GRPQUOTA)"}, + + {QCMD(Q_GETINFO, GRPQUOTA), &test_id, &res_qf, &set_qf.dqi_bgrace, + &res_qf.dqi_bgrace, sizeof(res_qf.dqi_bgrace), + "get information about quotafile for group", + "QCMD(Q_GETINFO, GRPQUOTA)"}, + + {QCMD(Q_GETFMT, GRPQUOTA), &test_id, &fmt_buf, + &fmt_id, &fmt_buf, sizeof(fmt_buf), "get quota format for group", + "QCMD(Q_GETFMT, GRPQUOTA)"}, + + {QCMD(Q_SYNC, GRPQUOTA), &test_id, &res_dq, + NULL, NULL, 0, "update quota usages for group", + "QCMD(Q_SYNC, GRPQUOTA)"}, + + {QCMD(Q_GETNEXTQUOTA, GRPQUOTA), &test_id, &res_ndq, + &test_id, &res_ndq.dqb_id, sizeof(res_ndq.dqb_id), + "get next disk quota limit for group", + "QCMD(Q_GETNEXTQUOTA, GRPQUOTA)"}, + + {QCMD(Q_QUOTAOFF, GRPQUOTA), &test_id, NULL, + NULL, NULL, 0, "turn off quota for group", + "QCMD(Q_QUOTAOFF, GRPQUOTA)"}, +}; + +static void setup(void) +{ + quotactl_info(); + fd = SAFE_OPEN(TESTFILE, O_RDWR | O_CREAT, 0666); + TEST(do_quotactl(fd, QCMD(Q_GETNEXTQUOTA, USRQUOTA), tst_device->dev, + 0, (void *) &res_ndq)); + if (TST_ERR == EINVAL || TST_ERR == ENOSYS) + getnextquota_nsup = 1; +} + +static void cleanup(void) +{ + if (fd > -1) + SAFE_CLOSE(fd); +} + +static void verify_quota(unsigned int n) +{ + struct tcase *tc = &tcases[n]; + + res_dq.dqb_bsoftlimit = 0; + res_qf.dqi_igrace = 0; + fmt_buf = 0; + res_ndq.dqb_id = -1; + + tst_res(TINFO, "Test #%d: %s", n, tc->tname); + if ((tc->cmd == QCMD(Q_GETNEXTQUOTA, USRQUOTA) || + tc->cmd == QCMD(Q_GETNEXTQUOTA, GRPQUOTA)) && + getnextquota_nsup) { + tst_res(TCONF, "current system doesn't support this cmd"); + return; + } + TEST(do_quotactl(fd, tc->cmd, tst_device->dev, *tc->id, tc->addr)); + if (TST_RET == -1) { + tst_res(TFAIL | TTERRNO, "quotactl failed to %s", tc->des); + return; + } + + if (memcmp(tc->res_data, tc->set_data, tc->sz)) { + tst_res(TFAIL, "quotactl failed to %s", tc->des); + tst_res_hexd(TINFO, tc->res_data, tc->sz, "retval: "); + tst_res_hexd(TINFO, tc->set_data, tc->sz, "expected: "); + return; + } + + tst_res(TPASS, "quotactl succeeded to %s", tc->des); +} + +static struct tst_test test = { + .needs_root = 1, + .needs_kconfigs = (const char *[]) { + "CONFIG_QFMT_V2", + NULL + }, + .test = verify_quota, + .tcnt = ARRAY_SIZE(tcases), + .mntpoint = MNTPOINT, + .dev_fs_type = "ext4", + .dev_fs_opts = (const char *const []){"-O", "quota", NULL}, + .mount_device = 1, + .setup = setup, + .cleanup = cleanup, + .test_variants = QUOTACTL_SYSCALL_VARIANTS, +}; diff --git a/testcases/kernel/syscalls/quotactl/quotactl_syscall_var.h b/testcases/kernel/syscalls/quotactl/quotactl_syscall_var.h new file mode 100644 index 000000000..92a7c45db --- /dev/null +++ b/testcases/kernel/syscalls/quotactl/quotactl_syscall_var.h @@ -0,0 +1,29 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * Copyright (c) 2021 FUJITSU LIMITED. All rights reserved. + * Author: Yang Xu <xuyang2018.jy@fujitsu.com> + */ + +#ifndef LTP_QUOTACTL_SYSCALL_VAR_H +#define LTP_QUOTACTL_SYSCALL_VAR_H + +#include "lapi/quotactl.h" + +#define QUOTACTL_SYSCALL_VARIANTS 2 + +static int do_quotactl(int fd, int cmd, const char *special, int id, caddr_t addr) +{ + if (tst_variant == 0) + return quotactl(cmd, special, id, addr); + return quotactl_fd(fd, cmd, id, addr); +} + +static void quotactl_info(void) +{ + if (tst_variant == 0) + tst_res(TINFO, "Test quotactl()"); + else + tst_res(TINFO, "Test quotactl_fd()"); +} + +#endif /* LTP_QUOTACTL_SYSCALL_VAR_H */ -- 2.23.0 -- Mailing list info: https://lists.linux.it/listinfo/ltp ^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [LTP] [PATCH v2 07/13] syscalls/quotactl08: Test quoatctl01 but quota info hidden in filesystem 2021-10-27 12:28 ` [LTP] [PATCH v2 07/13] syscalls/quotactl08: Test quoatctl01 but quota info hidden in filesystem Yang Xu @ 2021-10-28 2:11 ` xuyang2018.jy 0 siblings, 0 replies; 6+ messages in thread From: xuyang2018.jy @ 2021-10-28 2:11 UTC (permalink / raw) To: Cyril Hrubis; +Cc: ltp Hi Cyril > It uses two variants(quotactl and quotactl_fd). The difference for quotactl01 > is that we don't use quotacheck command and quota info hidden in filesystem. > > It also needs mkfs.ext4 supports quota feature. It seems this feature is disabled[1] before e2fsprog 1.42 when not specifying a --enable-quota option in compile-time and e2fsprog 1.43 remove this disable[2]. ps: I will add this check like quotactl04.c when the previous patches are merged. So it doesn't make much noise instead of sending a v3 now. [1]https://ext4.wiki.kernel.org/index.php/Quota [2]https://git.kernel.org/pub/scm/fs/ext2/e2fsprogs.git/commit/?h=v1.43&id=9e8fcd6e Best Regards Yang Xu > > Signed-off-by: Yang Xu<xuyang2018.jy@fujitsu.com> > --- > runtest/syscalls | 1 + > testcases/kernel/syscalls/quotactl/.gitignore | 1 + > .../kernel/syscalls/quotactl/quotactl08.c | 217 ++++++++++++++++++ > .../syscalls/quotactl/quotactl_syscall_var.h | 29 +++ > 4 files changed, 248 insertions(+) > create mode 100644 testcases/kernel/syscalls/quotactl/quotactl08.c > create mode 100644 testcases/kernel/syscalls/quotactl/quotactl_syscall_var.h > > diff --git a/runtest/syscalls b/runtest/syscalls > index b19316805..cdeb3e142 100644 > --- a/runtest/syscalls > +++ b/runtest/syscalls > @@ -1073,6 +1073,7 @@ quotactl04 quotactl04 > quotactl05 quotactl05 > quotactl06 quotactl06 > quotactl07 quotactl07 > +quotactl08 quotactl08 > > read01 read01 > read02 read02 > diff --git a/testcases/kernel/syscalls/quotactl/.gitignore b/testcases/kernel/syscalls/quotactl/.gitignore > index 8d2ef94d9..dab9b3420 100644 > --- a/testcases/kernel/syscalls/quotactl/.gitignore > +++ b/testcases/kernel/syscalls/quotactl/.gitignore > @@ -5,3 +5,4 @@ > /quotactl05 > /quotactl06 > /quotactl07 > +/quotactl08 > diff --git a/testcases/kernel/syscalls/quotactl/quotactl08.c b/testcases/kernel/syscalls/quotactl/quotactl08.c > new file mode 100644 > index 000000000..6912378f1 > --- /dev/null > +++ b/testcases/kernel/syscalls/quotactl/quotactl08.c > @@ -0,0 +1,217 @@ > +// SPDX-License-Identifier: GPL-2.0-or-later > +/* > + * Copyright (c) 2021 FUJITSU LIMITED. All rights reserved > + * Author: Yang Xu<xuyang2018.jy@fujitsu.com> > + */ > + > +/*\ > + * [Description] > + * This testcases checks that quotactl(2) on ext4 filesystem succeeds to: > + * > + * - turn on quota with Q_QUOTAON flag for user > + * - set disk quota limits with Q_SETQUOTA flag for user > + * - get disk quota limits with Q_GETQUOTA flag for user > + * - set information about quotafile with Q_SETINFO flag for user > + * - get information about quotafile with Q_GETINFO flag for user > + * - get quota format with Q_GETFMT flag for user > + * - update quota usages with Q_SYNC flag for user > + * - get disk quota limit greater than or equal to ID with Q_GETNEXTQUOTA flag for user > + * - turn off quota with Q_QUOTAOFF flag for user > + * - turn on quota with Q_QUOTAON flag for group > + * - set disk quota limits with Q_SETQUOTA flag for group > + * - get disk quota limits with Q_GETQUOTA flag for group > + * - set information about quotafile with Q_SETINFO flag for group > + * - get information about quotafile with Q_GETINFO flag for group > + * - get quota format with Q_GETFMT flag for group > + * - update quota usages with Q_SYNC flag for group > + * - get disk quota limit greater than or equal to ID with Q_GETNEXTQUOTA flag for group > + * - turn off quota with Q_QUOTAOFF flag for group > + * > + * It is similar to quotactl01.c, only two difference > + * - use new quotactl_fd syscalls if supports > + * - quota file hidden in filesystem > + */ > + > +#include<errno.h> > +#include<string.h> > +#include<unistd.h> > +#include<stdio.h> > +#include "tst_test.h" > +#include "quotactl_syscall_var.h" > +#include "tst_safe_stdio.h" > + > +#define MNTPOINT "mntpoint" > +#define TESTFILE MNTPOINT "/testfile" > + > +static int32_t fmt_id = QFMT_VFS_V1; > +static int test_id, fd = -1; > +static struct dqblk set_dq = { > + .dqb_bsoftlimit = 100, > + .dqb_valid = QIF_BLIMITS > +}; > +static struct dqblk res_dq; > + > +static struct dqinfo set_qf = { > + .dqi_bgrace = 80, > + .dqi_valid = IIF_BGRACE > +}; > +static struct dqinfo res_qf; > +static int32_t fmt_buf; > +static int getnextquota_nsup; > + > +static struct if_nextdqblk res_ndq; > + > +static struct tcase { > + int cmd; > + int *id; > + void *addr; > + void *set_data; > + void *res_data; > + int sz; > + char *des; > + char *tname; > +} tcases[] = { > + {QCMD(Q_QUOTAON, USRQUOTA),&fmt_id, NULL, > + NULL, NULL, 0, "turn on quota for user", > + "QCMD(Q_QUOTAON, USRQUOTA)"}, > + > + {QCMD(Q_SETQUOTA, USRQUOTA),&test_id,&set_dq, > + NULL, NULL, 0, "set disk quota limit for user", > + "QCMD(Q_SETQUOTA, USRQUOTA)"}, > + > + {QCMD(Q_GETQUOTA, USRQUOTA),&test_id,&res_dq, > + &set_dq.dqb_bsoftlimit,&res_dq.dqb_bsoftlimit, > + sizeof(res_dq.dqb_bsoftlimit), "get disk quota limit for user", > + "QCMD(Q_GETQUOTA, USRQUOTA)"}, > + > + {QCMD(Q_SETINFO, USRQUOTA),&test_id,&set_qf, > + NULL, NULL, 0, "set information about quotafile for user", > + "QCMD(Q_SETINFO, USRQUOTA)"}, > + > + {QCMD(Q_GETINFO, USRQUOTA),&test_id,&res_qf, > + &set_qf.dqi_bgrace,&res_qf.dqi_bgrace, sizeof(res_qf.dqi_bgrace), > + "get information about quotafile for user", > + "QCMD(Q_GETINFO, USRQUOTA)"}, > + > + {QCMD(Q_GETFMT, USRQUOTA),&test_id,&fmt_buf, > + &fmt_id,&fmt_buf, sizeof(fmt_buf), > + "get quota format for user", > + "QCMD(Q_GETFMT, USRQUOTA)"}, > + > + {QCMD(Q_SYNC, USRQUOTA),&test_id,&res_dq, > + NULL, NULL, 0, "update quota usages for user", > + "QCMD(Q_SYNC, USRQUOTA)"}, > + > + {QCMD(Q_GETNEXTQUOTA, USRQUOTA),&test_id,&res_ndq, > + &test_id,&res_ndq.dqb_id, sizeof(res_ndq.dqb_id), > + "get next disk quota limit for user", > + "QCMD(Q_GETNEXTQUOTA, USRQUOTA)"}, > + > + {QCMD(Q_QUOTAOFF, USRQUOTA),&test_id, NULL, > + NULL, NULL, 0, "turn off quota for user", > + "QCMD(Q_QUOTAOFF, USRQUOTA)"}, > + > + {QCMD(Q_QUOTAON, GRPQUOTA),&fmt_id, NULL, > + NULL, NULL, 0, "turn on quota for group", > + "QCMD(Q_QUOTAON, GRPQUOTA)"}, > + > + {QCMD(Q_SETQUOTA, GRPQUOTA),&test_id,&set_dq, > + NULL, NULL, 0, "set disk quota limit for group", > + "QCMD(Q_SETQUOTA, GRPQUOTA)"}, > + > + {QCMD(Q_GETQUOTA, GRPQUOTA),&test_id,&res_dq,&set_dq.dqb_bsoftlimit, > + &res_dq.dqb_bsoftlimit, sizeof(res_dq.dqb_bsoftlimit), > + "set disk quota limit for group", > + "QCMD(Q_GETQUOTA, GRPQUOTA)"}, > + > + {QCMD(Q_SETINFO, GRPQUOTA),&test_id,&set_qf, > + NULL, NULL, 0, "set information about quotafile for group", > + "QCMD(Q_SETINFO, GRPQUOTA)"}, > + > + {QCMD(Q_GETINFO, GRPQUOTA),&test_id,&res_qf,&set_qf.dqi_bgrace, > + &res_qf.dqi_bgrace, sizeof(res_qf.dqi_bgrace), > + "get information about quotafile for group", > + "QCMD(Q_GETINFO, GRPQUOTA)"}, > + > + {QCMD(Q_GETFMT, GRPQUOTA),&test_id,&fmt_buf, > + &fmt_id,&fmt_buf, sizeof(fmt_buf), "get quota format for group", > + "QCMD(Q_GETFMT, GRPQUOTA)"}, > + > + {QCMD(Q_SYNC, GRPQUOTA),&test_id,&res_dq, > + NULL, NULL, 0, "update quota usages for group", > + "QCMD(Q_SYNC, GRPQUOTA)"}, > + > + {QCMD(Q_GETNEXTQUOTA, GRPQUOTA),&test_id,&res_ndq, > + &test_id,&res_ndq.dqb_id, sizeof(res_ndq.dqb_id), > + "get next disk quota limit for group", > + "QCMD(Q_GETNEXTQUOTA, GRPQUOTA)"}, > + > + {QCMD(Q_QUOTAOFF, GRPQUOTA),&test_id, NULL, > + NULL, NULL, 0, "turn off quota for group", > + "QCMD(Q_QUOTAOFF, GRPQUOTA)"}, > +}; > + > +static void setup(void) > +{ > + quotactl_info(); > + fd = SAFE_OPEN(TESTFILE, O_RDWR | O_CREAT, 0666); > + TEST(do_quotactl(fd, QCMD(Q_GETNEXTQUOTA, USRQUOTA), tst_device->dev, > + 0, (void *)&res_ndq)); > + if (TST_ERR == EINVAL || TST_ERR == ENOSYS) > + getnextquota_nsup = 1; > +} > + > +static void cleanup(void) > +{ > + if (fd> -1) > + SAFE_CLOSE(fd); > +} > + > +static void verify_quota(unsigned int n) > +{ > + struct tcase *tc =&tcases[n]; > + > + res_dq.dqb_bsoftlimit = 0; > + res_qf.dqi_igrace = 0; > + fmt_buf = 0; > + res_ndq.dqb_id = -1; > + > + tst_res(TINFO, "Test #%d: %s", n, tc->tname); > + if ((tc->cmd == QCMD(Q_GETNEXTQUOTA, USRQUOTA) || > + tc->cmd == QCMD(Q_GETNEXTQUOTA, GRPQUOTA))&& > + getnextquota_nsup) { > + tst_res(TCONF, "current system doesn't support this cmd"); > + return; > + } > + TEST(do_quotactl(fd, tc->cmd, tst_device->dev, *tc->id, tc->addr)); > + if (TST_RET == -1) { > + tst_res(TFAIL | TTERRNO, "quotactl failed to %s", tc->des); > + return; > + } > + > + if (memcmp(tc->res_data, tc->set_data, tc->sz)) { > + tst_res(TFAIL, "quotactl failed to %s", tc->des); > + tst_res_hexd(TINFO, tc->res_data, tc->sz, "retval: "); > + tst_res_hexd(TINFO, tc->set_data, tc->sz, "expected: "); > + return; > + } > + > + tst_res(TPASS, "quotactl succeeded to %s", tc->des); > +} > + > +static struct tst_test test = { > + .needs_root = 1, > + .needs_kconfigs = (const char *[]) { > + "CONFIG_QFMT_V2", > + NULL > + }, > + .test = verify_quota, > + .tcnt = ARRAY_SIZE(tcases), > + .mntpoint = MNTPOINT, > + .dev_fs_type = "ext4", > + .dev_fs_opts = (const char *const []){"-O", "quota", NULL}, > + .mount_device = 1, > + .setup = setup, > + .cleanup = cleanup, > + .test_variants = QUOTACTL_SYSCALL_VARIANTS, > +}; > diff --git a/testcases/kernel/syscalls/quotactl/quotactl_syscall_var.h b/testcases/kernel/syscalls/quotactl/quotactl_syscall_var.h > new file mode 100644 > index 000000000..92a7c45db > --- /dev/null > +++ b/testcases/kernel/syscalls/quotactl/quotactl_syscall_var.h > @@ -0,0 +1,29 @@ > +// SPDX-License-Identifier: GPL-2.0-or-later > +/* > + * Copyright (c) 2021 FUJITSU LIMITED. All rights reserved. > + * Author: Yang Xu<xuyang2018.jy@fujitsu.com> > + */ > + > +#ifndef LTP_QUOTACTL_SYSCALL_VAR_H > +#define LTP_QUOTACTL_SYSCALL_VAR_H > + > +#include "lapi/quotactl.h" > + > +#define QUOTACTL_SYSCALL_VARIANTS 2 > + > +static int do_quotactl(int fd, int cmd, const char *special, int id, caddr_t addr) > +{ > + if (tst_variant == 0) > + return quotactl(cmd, special, id, addr); > + return quotactl_fd(fd, cmd, id, addr); > +} > + > +static void quotactl_info(void) > +{ > + if (tst_variant == 0) > + tst_res(TINFO, "Test quotactl()"); > + else > + tst_res(TINFO, "Test quotactl_fd()"); > +} > + > +#endif /* LTP_QUOTACTL_SYSCALL_VAR_H */ -- Mailing list info: https://lists.linux.it/listinfo/ltp ^ permalink raw reply [flat|nested] 6+ messages in thread
* [LTP] [PATCH v2 08/13] syscalls/quotactl02, 5: Add quotactl_fd test variant 2021-10-27 12:28 [LTP] [PATCH v2 06/13] lapi/quotactl.h: Add fallback for quotactl_fd Yang Xu 2021-10-27 12:28 ` [LTP] [PATCH v2 07/13] syscalls/quotactl08: Test quoatctl01 but quota info hidden in filesystem Yang Xu @ 2021-10-27 12:28 ` Yang Xu 2021-10-27 12:28 ` [LTP] [PATCH v2 09/13] syscalls/quotactl03: " Yang Xu 2021-11-08 16:11 ` [LTP] [PATCH v2 06/13] lapi/quotactl.h: Add fallback for quotactl_fd Cyril Hrubis 3 siblings, 0 replies; 6+ messages in thread From: Yang Xu @ 2021-10-27 12:28 UTC (permalink / raw) To: ltp Also remove useless geteuid Signed-off-by: Yang Xu <xuyang2018.jy@fujitsu.com> --- .../kernel/syscalls/quotactl/quotactl02.c | 15 ++++++++++--- .../kernel/syscalls/quotactl/quotactl02.h | 22 ++++++++++--------- .../kernel/syscalls/quotactl/quotactl05.c | 15 ++++++++++--- 3 files changed, 36 insertions(+), 16 deletions(-) diff --git a/testcases/kernel/syscalls/quotactl/quotactl02.c b/testcases/kernel/syscalls/quotactl/quotactl02.c index 55a6a8906..a8d6dea83 100644 --- a/testcases/kernel/syscalls/quotactl/quotactl02.c +++ b/testcases/kernel/syscalls/quotactl/quotactl02.c @@ -99,11 +99,18 @@ static struct t_case { static void setup(void) { - test_id = geteuid(); + quotactl_info(); + fd = SAFE_OPEN(TESTFILE, O_RDWR | O_CREAT, 0666); check_support_cmd(USRQUOTA); check_support_cmd(GRPQUOTA); } +static void cleanup(void) +{ + if (fd > -1) + SAFE_CLOSE(fd); +} + static void verify_quota(unsigned int n) { struct t_case *tc = &tcases[n]; @@ -122,7 +129,7 @@ static void verify_quota(unsigned int n) return; } - TEST(quotactl(tc->cmd, tst_device->dev, test_id, tc->addr)); + TEST(do_quotactl(fd, tc->cmd, tst_device->dev, test_id, tc->addr)); if (TST_RET == -1) { tst_res(TFAIL | TTERRNO, "quotactl() failed to %s", tc->des); return; @@ -144,9 +151,11 @@ static struct tst_test test = { .tcnt = ARRAY_SIZE(tcases), .mount_device = 1, .dev_fs_type = "xfs", - .mntpoint = mntpoint, + .mntpoint = MNTPOINT, .mnt_data = "usrquota,grpquota", .setup = setup, + .cleanup = cleanup, + .test_variants = QUOTACTL_SYSCALL_VARIANTS, }; #else TST_TEST_TCONF("System doesn't have <xfs/xqm.h>"); diff --git a/testcases/kernel/syscalls/quotactl/quotactl02.h b/testcases/kernel/syscalls/quotactl/quotactl02.h index 3351fb578..faee5d282 100644 --- a/testcases/kernel/syscalls/quotactl/quotactl02.h +++ b/testcases/kernel/syscalls/quotactl/quotactl02.h @@ -12,19 +12,21 @@ #include <unistd.h> #include <stdio.h> #include "tst_test.h" -#include "lapi/quotactl.h" +#include "quotactl_syscall_var.h" #ifdef HAVE_XFS_XQM_H # include <xfs/xqm.h> +#define MNTPOINT "mntpoint" +#define TESTFILE MNTPOINT "/testfile" + static struct fs_disk_quota set_dquota = { .d_rtb_softlimit = 1000, .d_fieldmask = FS_DQ_RTBSOFT }; static uint32_t test_id; -static int x_getnextquota_nsup; +static int x_getnextquota_nsup, fd = -1; static int x_getstatv_nsup; -static const char mntpoint[] = "mnt_point"; void check_support_cmd(int quotatype) { @@ -36,12 +38,12 @@ void check_support_cmd(int quotatype) x_getnextquota_nsup = 0; x_getstatv_nsup = 0; - TEST(quotactl(QCMD(Q_XGETNEXTQUOTA, quotatype), tst_device->dev, + TEST(do_quotactl(fd, QCMD(Q_XGETNEXTQUOTA, quotatype), tst_device->dev, test_id, (void *) &resfs_dquota)); if (TST_ERR == EINVAL || TST_ERR == ENOSYS) x_getnextquota_nsup = 1; - TEST(quotactl(QCMD(Q_XGETQSTATV, quotatype), tst_device->dev, test_id, + TEST(do_quotactl(fd, QCMD(Q_XGETQSTATV, quotatype), tst_device->dev, test_id, (void *) &resfs_qstatv)); if (TST_ERR == EINVAL || TST_ERR == ENOSYS) x_getstatv_nsup = 1; @@ -52,7 +54,7 @@ void check_qoff(int subcmd, char *desp, int flag) int res; struct fs_quota_stat res_qstat; - res = quotactl(subcmd, tst_device->dev, test_id, (void *) &res_qstat); + res = do_quotactl(fd, subcmd, tst_device->dev, test_id, (void *) &res_qstat); if (res == -1) { tst_res(TFAIL | TERRNO, "quotactl() failed to get xfs quota off status"); @@ -72,7 +74,7 @@ void check_qon(int subcmd, char *desp, int flag) int res; struct fs_quota_stat res_qstat; - res = quotactl(subcmd, tst_device->dev, test_id, (void *) &res_qstat); + res = do_quotactl(fd, subcmd, tst_device->dev, test_id, (void *) &res_qstat); if (res == -1) { tst_res(TFAIL | TERRNO, "quotactl() failed to get xfs quota on status"); @@ -94,7 +96,7 @@ void check_qoffv(int subcmd, char *desp, int flag) .qs_version = FS_QSTATV_VERSION1, }; - res = quotactl(subcmd, tst_device->dev, test_id, (void *) &res_qstatv); + res = do_quotactl(fd, subcmd, tst_device->dev, test_id, (void *) &res_qstatv); if (res == -1) { tst_res(TFAIL | TERRNO, "quotactl() failed to get xfs quota off stav"); @@ -116,7 +118,7 @@ void check_qonv(int subcmd, char *desp, int flag) .qs_version = FS_QSTATV_VERSION1 }; - res = quotactl(subcmd, tst_device->dev, test_id, (void *) &res_qstatv); + res = do_quotactl(fd, subcmd, tst_device->dev, test_id, (void *) &res_qstatv); if (res == -1) { tst_res(TFAIL | TERRNO, "quotactl() failed to get xfs quota on statv"); @@ -138,7 +140,7 @@ void check_qlim(int subcmd, char *desp) res_dquota.d_rtb_softlimit = 0; - res = quotactl(subcmd, tst_device->dev, test_id, (void *) &res_dquota); + res = do_quotactl(fd, subcmd, tst_device->dev, test_id, (void *) &res_dquota); if (res == -1) { tst_res(TFAIL | TERRNO, "quotactl() failed to get xfs disk quota limits"); diff --git a/testcases/kernel/syscalls/quotactl/quotactl05.c b/testcases/kernel/syscalls/quotactl/quotactl05.c index 15a6c1e67..00a9242bc 100644 --- a/testcases/kernel/syscalls/quotactl/quotactl05.c +++ b/testcases/kernel/syscalls/quotactl/quotactl05.c @@ -62,10 +62,17 @@ static struct t_case { static void setup(void) { - test_id = geteuid(); + quotactl_info(); + fd = SAFE_OPEN(TESTFILE, O_RDWR | O_CREAT, 0666); check_support_cmd(PRJQUOTA); } +static void cleanup(void) +{ + if (fd > -1) + SAFE_CLOSE(fd); +} + static void verify_quota(unsigned int n) { struct t_case *tc = &tcases[n]; @@ -85,7 +92,7 @@ static void verify_quota(unsigned int n) return; } - TEST(quotactl(tc->cmd, tst_device->dev, test_id, tc->addr)); + TEST(do_quotactl(fd, tc->cmd, tst_device->dev, test_id, tc->addr)); if (TST_RET == -1) { tst_res(TFAIL | TTERRNO, "quotactl() failed to %s", tc->des); return; @@ -107,9 +114,11 @@ static struct tst_test test = { .tcnt = ARRAY_SIZE(tcases), .mount_device = 1, .dev_fs_type = "xfs", - .mntpoint = mntpoint, + .mntpoint = MNTPOINT, .mnt_data = "prjquota", .setup = setup, + .cleanup = cleanup, + .test_variants = QUOTACTL_SYSCALL_VARIANTS, }; #else -- 2.23.0 -- Mailing list info: https://lists.linux.it/listinfo/ltp ^ permalink raw reply related [flat|nested] 6+ messages in thread
* [LTP] [PATCH v2 09/13] syscalls/quotactl03: Add quotactl_fd test variant 2021-10-27 12:28 [LTP] [PATCH v2 06/13] lapi/quotactl.h: Add fallback for quotactl_fd Yang Xu 2021-10-27 12:28 ` [LTP] [PATCH v2 07/13] syscalls/quotactl08: Test quoatctl01 but quota info hidden in filesystem Yang Xu 2021-10-27 12:28 ` [LTP] [PATCH v2 08/13] syscalls/quotactl02, 5: Add quotactl_fd test variant Yang Xu @ 2021-10-27 12:28 ` Yang Xu 2021-11-08 16:11 ` [LTP] [PATCH v2 06/13] lapi/quotactl.h: Add fallback for quotactl_fd Cyril Hrubis 3 siblings, 0 replies; 6+ messages in thread From: Yang Xu @ 2021-10-27 12:28 UTC (permalink / raw) To: ltp Also remove dupcliated header file. Signed-off-by: Yang Xu <xuyang2018.jy@fujitsu.com> --- .../kernel/syscalls/quotactl/quotactl03.c | 27 +++++++++++++++---- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/testcases/kernel/syscalls/quotactl/quotactl03.c b/testcases/kernel/syscalls/quotactl/quotactl03.c index e0e4bf5b2..0c4c50b42 100644 --- a/testcases/kernel/syscalls/quotactl/quotactl03.c +++ b/testcases/kernel/syscalls/quotactl/quotactl03.c @@ -23,20 +23,22 @@ */ #define _GNU_SOURCE -#include "config.h" #include <errno.h> #include <unistd.h> #include <stdio.h> #include <sys/quota.h> #include "tst_test.h" -#include "lapi/quotactl.h" +#include "quotactl_syscall_var.h" #ifdef HAVE_XFS_XQM_H # include <xfs/xqm.h> -static const char mntpoint[] = "mnt_point"; +#define MNTPOINT "mnt_point" +#define TESTFILE MNTPOINT "/testfile" + static uint32_t test_id = 0xfffffffc; +static int fd = -1; static void verify_quota(void) { @@ -44,7 +46,7 @@ static void verify_quota(void) res_dquota.d_id = 1; - TEST(quotactl(QCMD(Q_XGETNEXTQUOTA, USRQUOTA), tst_device->dev, + TEST(do_quotactl(fd, QCMD(Q_XGETNEXTQUOTA, USRQUOTA), tst_device->dev, test_id, (void *)&res_dquota)); if (TST_RET != -1) { tst_res(TFAIL, "quotactl() found the next active ID: %u unexpectedly", @@ -63,7 +65,21 @@ static void verify_quota(void) tst_res(TPASS, "quotactl() failed with ENOENT as expected"); } +static void setup(void) +{ + quotactl_info(); + fd = SAFE_OPEN(TESTFILE, O_RDWR | O_CREAT, 0666); +} + +static void cleanup(void) +{ + if (fd > -1) + SAFE_CLOSE(fd); +} + static struct tst_test test = { + .setup = setup, + .cleanup = cleanup, .needs_root = 1, .needs_kconfigs = (const char *[]) { "CONFIG_XFS_QUOTA", @@ -72,8 +88,9 @@ static struct tst_test test = { .test_all = verify_quota, .mount_device = 1, .dev_fs_type = "xfs", - .mntpoint = mntpoint, + .mntpoint = MNTPOINT, .mnt_data = "usrquota", + .test_variants = QUOTACTL_SYSCALL_VARIANTS, .tags = (const struct tst_tag[]) { {"linux-git", "657bdfb7f5e6"}, {} -- 2.23.0 -- Mailing list info: https://lists.linux.it/listinfo/ltp ^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [LTP] [PATCH v2 06/13] lapi/quotactl.h: Add fallback for quotactl_fd 2021-10-27 12:28 [LTP] [PATCH v2 06/13] lapi/quotactl.h: Add fallback for quotactl_fd Yang Xu ` (2 preceding siblings ...) 2021-10-27 12:28 ` [LTP] [PATCH v2 09/13] syscalls/quotactl03: " Yang Xu @ 2021-11-08 16:11 ` Cyril Hrubis 3 siblings, 0 replies; 6+ messages in thread From: Cyril Hrubis @ 2021-11-08 16:11 UTC (permalink / raw) To: Yang Xu; +Cc: ltp Hi! Reviewed-by: Cyril Hrubis <chrubis@suse.cz> -- Cyril Hrubis chrubis@suse.cz -- Mailing list info: https://lists.linux.it/listinfo/ltp ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2021-11-08 16:10 UTC | newest] Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2021-10-27 12:28 [LTP] [PATCH v2 06/13] lapi/quotactl.h: Add fallback for quotactl_fd Yang Xu 2021-10-27 12:28 ` [LTP] [PATCH v2 07/13] syscalls/quotactl08: Test quoatctl01 but quota info hidden in filesystem Yang Xu 2021-10-28 2:11 ` xuyang2018.jy 2021-10-27 12:28 ` [LTP] [PATCH v2 08/13] syscalls/quotactl02, 5: Add quotactl_fd test variant Yang Xu 2021-10-27 12:28 ` [LTP] [PATCH v2 09/13] syscalls/quotactl03: " Yang Xu 2021-11-08 16:11 ` [LTP] [PATCH v2 06/13] lapi/quotactl.h: Add fallback for quotactl_fd Cyril Hrubis
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).