[LTP] [PATCH v1 01/11] syscalls/quotactl01: Also test with vfsv1 format
Yang Xu
xuyang2018.jy@fujitsu.com
Mon Oct 18 15:09:41 CEST 2021
Since usrquota and groupquota supports visible quota files
with two formats(vfsv0 and vfsv1) on ext4, so add a test variants to
test it.
Signed-off-by: Yang Xu <xuyang2018.jy@fujitsu.com>
---
include/lapi/quotactl.h | 8 +++
.../kernel/syscalls/quotactl/quotactl01.c | 67 +++++++++++++++----
2 files changed, 61 insertions(+), 14 deletions(-)
diff --git a/include/lapi/quotactl.h b/include/lapi/quotactl.h
index c1ec9d6e1..348b70b58 100644
--- a/include/lapi/quotactl.h
+++ b/include/lapi/quotactl.h
@@ -75,4 +75,12 @@ struct fs_quota_statv {
# define Q_GETNEXTQUOTA 0x800009 /* get disk limits and usage >= ID */
#endif
+#ifndef QFMT_VFS_V0
+# define QFMT_VFS_V0 2
+#endif
+
+#ifndef QFMT_VFS_V1
+# define QFMT_VFS_V1 4
+#endif
+
#endif /* LAPI_QUOTACTL_H__ */
diff --git a/testcases/kernel/syscalls/quotactl/quotactl01.c b/testcases/kernel/syscalls/quotactl/quotactl01.c
index 56146b595..4b791a03a 100644
--- a/testcases/kernel/syscalls/quotactl/quotactl01.c
+++ b/testcases/kernel/syscalls/quotactl/quotactl01.c
@@ -1,37 +1,60 @@
// SPDX-License-Identifier: GPL-2.0-or-later
/*
* Copyright (c) Crackerjack Project., 2007
- * Copyright (c) 2016-2019 FUJITSU LIMITED. All rights reserved
+ * Copyright (c) 2016-2021 FUJITSU LIMITED. All rights reserved
* Author: Xiao Yang <yangx.jy@cn.fujitsu.com>
+ * Author: Yang Xu <xuyang2018.jy@fujitsu.com>
+ */
+
+/*\
+ * [Description]
+ * This testcase checks the basic flag of quotactl(2) for non-XFS filesystems
+ * with visible quota files(cover two formats, vfsv0 and vfsv1):
*
- * This testcase checks the basic flag of quotactl(2) for non-XFS filesystems:
* 1) quotactl(2) succeeds to turn on quota with Q_QUOTAON flag for user.
- * 2) quotactl(2) succeeds to set disk quota limits with Q_SETQUOTA flag
+ *
+ * 2 quotactl(2) succeeds to set disk quota limits with Q_SETQUOTA flag
* for user.
+ *
* 3) quotactl(2) succeeds to get disk quota limits with Q_GETQUOTA flag
* for user.
+ *
* 4) quotactl(2) succeeds to set information about quotafile with Q_SETINFO
* flag for user.
+ *
* 5) quotactl(2) succeeds to get information about quotafile with Q_GETINFO
* flag for user.
+ *
* 6) quotactl(2) succeeds to get quota format with Q_GETFMT flag for user.
+ *
* 7) quotactl(2) succeeds to update quota usages with Q_SYNC flag for user.
+ *
* 8) quotactl(2) succeeds to get disk quota limit greater than or equal to
* ID with Q_GETNEXTQUOTA flag for user.
+ *
* 9) quotactl(2) succeeds to turn off quota with Q_QUOTAOFF flag for user.
+ *
* 10) quotactl(2) succeeds to turn on quota with Q_QUOTAON flag for group.
+ *
* 11) quotactl(2) succeeds to set disk quota limits with Q_SETQUOTA flag
* for group.
+ *
* 12) quotactl(2) succeeds to get disk quota limits with Q_GETQUOTA flag
* for group.
+ *
* 13) quotactl(2) succeeds to set information about quotafile with Q_SETINFO
* flag for group.
+ *
* 14) quotactl(2) succeeds to get information about quotafile with Q_GETINFO
* flag for group.
+ *
* 15) quotactl(2) succeeds to get quota format with Q_GETFMT flag for group.
+ *
* 16) quotactl(2) succeeds to update quota usages with Q_SYNC flag for group.
+ *
* 17) quotactl(2) succeeds to get disk quota limit greater than or equal to
* ID with Q_GETNEXTQUOTA flag for group.
+ *
* 18) quotactl(2) succeeds to turn off quota with Q_QUOTAOFF flag for group.
*/
@@ -43,16 +66,12 @@
#include "lapi/quotactl.h"
#include "tst_test.h"
-#ifndef QFMT_VFS_V0
-# define QFMT_VFS_V0 2
-#endif
#define USRPATH MNTPOINT "/aquota.user"
#define GRPPATH MNTPOINT "/aquota.group"
-#define FMTID QFMT_VFS_V0
#define MNTPOINT "mntpoint"
-static int32_t fmt_id = FMTID;
-static int test_id;
+static int32_t fmt_id;
+static int test_id, mount_flag;
static char usrpath[] = USRPATH;
static char grppath[] = GRPPATH;
static struct dqblk set_dq = {
@@ -163,9 +182,22 @@ static struct tcase {
static void setup(void)
{
- const char *const cmd[] = {"quotacheck", "-ugF", "vfsv0", MNTPOINT, NULL};
-
- SAFE_CMD(cmd, NULL, NULL);
+ const char *const vfsv0_cmd[] = {"quotacheck", "-ugF", "vfsv0", MNTPOINT, NULL};
+ const char *const vfsv1_cmd[] = {"quotacheck", "-ugF", "vfsv1", MNTPOINT, NULL};
+
+ SAFE_MKFS(tst_device->dev, tst_device->fs_type, NULL, NULL);
+ SAFE_MOUNT(tst_device->dev, MNTPOINT, tst_device->fs_type, 0, "usrquota,grpquota");
+ 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;
+ }
test_id = geteuid();
if (access(USRPATH, F_OK) == -1)
@@ -182,6 +214,12 @@ static void setup(void)
getnextquota_nsup = 1;
}
+static void cleanup(void)
+{
+ if (mount_flag && tst_umount(MNTPOINT))
+ tst_res(TWARN | TERRNO, "umount(%s)", MNTPOINT);
+}
+
static void verify_quota(unsigned int n)
{
struct tcase *tc = &tcases[n];
@@ -222,13 +260,14 @@ static struct tst_test test = {
},
.test = verify_quota,
.tcnt = ARRAY_SIZE(tcases),
- .mount_device = 1,
+ .needs_device = 1,
.dev_fs_type = "ext4",
.mntpoint = MNTPOINT,
- .mnt_data = "usrquota,grpquota",
.needs_cmds = (const char *const []) {
"quotacheck",
NULL
},
.setup = setup,
+ .cleanup = cleanup,
+ .test_variants = 2,
};
--
2.23.0
More information about the ltp
mailing list