All of lore.kernel.org
 help / color / mirror / Atom feed
* [LTP] [PATCH v2 01/13] syscalls/quotactl01: Also test with vfsv1 format
@ 2021-10-27 12:25 Yang Xu
  2021-10-27 12:25 ` [LTP] [PATCH v2 02/13] syscalls/quotactl06: " Yang Xu
                   ` (5 more replies)
  0 siblings, 6 replies; 14+ messages in thread
From: Yang Xu @ 2021-10-27 12:25 UTC (permalink / raw)
  To: ltp

Since usrquota and groupquota supports visible quota files
with two formats(vfsv0 and vfsv1) on ext4, so add a test variants to
test it.

Also fix docparse formatting and move some code to lapi/quotactl.h or
quotactl_var.h for reuse.

Remove useless geteuid.

Signed-off-by: Yang Xu <xuyang2018.jy@fujitsu.com>
---
 include/lapi/quotactl.h                       |  9 +++
 .../kernel/syscalls/quotactl/quotactl01.c     | 79 +++++++++----------
 .../syscalls/quotactl/quotactl_fmt_var.h      | 22 ++++++
 3 files changed, 70 insertions(+), 40 deletions(-)
 create mode 100644 testcases/kernel/syscalls/quotactl/quotactl_fmt_var.h

diff --git a/include/lapi/quotactl.h b/include/lapi/quotactl.h
index c1ec9d6e1..8e0315d03 100644
--- a/include/lapi/quotactl.h
+++ b/include/lapi/quotactl.h
@@ -8,6 +8,7 @@
 #ifndef LAPI_QUOTACTL_H__
 #define LAPI_QUOTACTL_H__
 
+#include "config.h"
 #include <sys/quota.h>
 
 #ifdef HAVE_STRUCT_IF_NEXTDQBLK
@@ -75,4 +76,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..7a71dd5fc 100644
--- a/testcases/kernel/syscalls/quotactl/quotactl01.c
+++ b/testcases/kernel/syscalls/quotactl/quotactl01.c
@@ -1,57 +1,47 @@
 // 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 testcases checks that quotactl(2) on ext4 filesystem succeeds to:
  *
- * 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
- *    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.
+ * - 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
  */
 
-#include "config.h"
 #include <errno.h>
 #include <string.h>
 #include <unistd.h>
 #include <stdio.h>
-#include "lapi/quotactl.h"
 #include "tst_test.h"
+#include "quotactl_fmt_var.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 int32_t fmt_id;
 static int test_id;
 static char usrpath[] = USRPATH;
 static char grppath[] = GRPPATH;
@@ -163,11 +153,12 @@ static struct tcase {
 
 static void setup(void)
 {
-	const char *const cmd[] = {"quotacheck", "-ugF", "vfsv0", MNTPOINT, NULL};
+	const char *const cmd[] = {"quotacheck", "-ugF", fmt_variants[tst_variant].fmt_name, MNTPOINT, NULL};
 
+	tst_res(TINFO, "quotactl() with %s format", fmt_variants[tst_variant].fmt_name);
 	SAFE_CMD(cmd, NULL, NULL);
+	fmt_id = fmt_variants[tst_variant].fmt_id;
 
-	test_id = geteuid();
 	if (access(USRPATH, F_OK) == -1)
 		tst_brk(TFAIL | TERRNO, "user quotafile didn't exist");
 
@@ -182,6 +173,12 @@ static void setup(void)
 		getnextquota_nsup = 1;
 }
 
+static void cleanup(void)
+{
+	SAFE_UNLINK(USRPATH);
+	SAFE_UNLINK(GRPPATH);
+}
+
 static void verify_quota(unsigned int n)
 {
 	struct tcase *tc = &tcases[n];
@@ -223,12 +220,14 @@ static struct tst_test test = {
 	.test = verify_quota,
 	.tcnt = ARRAY_SIZE(tcases),
 	.mount_device = 1,
-	.dev_fs_type = "ext4",
 	.mntpoint = MNTPOINT,
+	.dev_fs_type = "ext4",
 	.mnt_data = "usrquota,grpquota",
 	.needs_cmds = (const char *const []) {
 		"quotacheck",
 		NULL
 	},
 	.setup = setup,
+	.cleanup = cleanup,
+	.test_variants = QUOTACTL_FMT_VARIANTS,
 };
diff --git a/testcases/kernel/syscalls/quotactl/quotactl_fmt_var.h b/testcases/kernel/syscalls/quotactl/quotactl_fmt_var.h
new file mode 100644
index 000000000..cb9fa4625
--- /dev/null
+++ b/testcases/kernel/syscalls/quotactl/quotactl_fmt_var.h
@@ -0,0 +1,22 @@
+// 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_FMT_VAR_H
+#define LTP_QUOTACTL_FMT_VAR_H
+
+#include "lapi/quotactl.h"
+
+#define QUOTACTL_FMT_VARIANTS 2
+
+static struct quotactl_fmt_variant {
+	int32_t fmt_id;
+	const char *fmt_name;
+} fmt_variants[] = {
+	{.fmt_id = QFMT_VFS_V0, .fmt_name = "vfsv0"},
+	{.fmt_id = QFMT_VFS_V1, .fmt_name = "vfsv1"}
+};
+
+#endif /* LAPI_QUOTACTL_FMT_VAR_H__ */
-- 
2.23.0


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [LTP] [PATCH v2 02/13] syscalls/quotactl06: Also test with vfsv1 format
  2021-10-27 12:25 [LTP] [PATCH v2 01/13] syscalls/quotactl01: Also test with vfsv1 format Yang Xu
@ 2021-10-27 12:25 ` Yang Xu
  2021-11-08 15:29   ` Cyril Hrubis
  2021-10-27 12:25 ` [LTP] [PATCH v2 03/13] syscalls/quotactl04: Remove useless mount option Yang Xu
                   ` (4 subsequent siblings)
  5 siblings, 1 reply; 14+ messages in thread
From: Yang Xu @ 2021-10-27 12:25 UTC (permalink / raw)
  To: ltp

Add a linux tag and fix docparse formatting.

Signed-off-by: Yang Xu <xuyang2018.jy@fujitsu.com>
---
 .../kernel/syscalls/quotactl/quotactl06.c     | 90 ++++++++++++-------
 1 file changed, 56 insertions(+), 34 deletions(-)

diff --git a/testcases/kernel/syscalls/quotactl/quotactl06.c b/testcases/kernel/syscalls/quotactl/quotactl06.c
index a10d1ca07..76343adf9 100644
--- a/testcases/kernel/syscalls/quotactl/quotactl06.c
+++ b/testcases/kernel/syscalls/quotactl/quotactl06.c
@@ -1,41 +1,49 @@
 // SPDX-License-Identifier: GPL-2.0-or-later
 /*
- * Copyright (c) 2019 FUJITSU LIMITED. All rights reserved.
- * Author: Yang Xu <xuyang2018.jy@cn.fujitsu.com>
+ * Copyright (c) 2019-2021 FUJITSU LIMITED. All rights reserved.
+ * Author: Yang Xu <xuyang2018.jy@fujitsu.com>
+ */
+
+/*\
+ * [Description]
+ *
+ * Tests basic error handling of the quotactl syscall with visible quota files
+ * (cover two formats, vfsv0 and vfsv1):
+ *
+ * - EACCES when cmd is Q_QUOTAON and addr existed but not a regular file
+ * - ENOENT when the file specified by special or addr does not exist
+ * - EBUSTY when cmd is Q_QUOTAON and another Q_QUOTAON had already been performed
+ * - EFAULT when addr or special is invalid
+ * - EINVAL when cmd or type is invalid
+ * - ENOTBLK when special is not a block device
+ * - ESRCH when no disk quota is found for the indicated user and quotas have not been
+ *   turned on for this fs
+ * - ESRCH when cmd is Q_QUOTAON, but the quota format was not found
+ * - ESRCH when cmd is Q_GETNEXTQUOTA, but there is no ID greater than or equal to id that
+ *   has an active quota
+ * - ERANGE when cmd is Q_SETQUOTA, but the specified limits are out of the range allowed
+ *   by the quota format
+ * - EPERM when the caller lacked the required privilege (CAP_SYS_ADMIN) for the specified
+ *   operation
+ *
+ * For ERANGE error, the vfsv0 and vfsv1 format's maximum quota limit setting have been
+ * fixed since the following kernel patch:
+ *
+ *  commit 7e08da50cf706151f324349f9235ebd311226997
+ *  Author: Jan Kara <jack@suse.cz>
+ *  Date:   Wed Mar 4 14:42:02 2015 +0100
  *
- * 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.
+ *  quota: Fix maximum quota limit settings
  */
 
 #include <errno.h>
 #include <sys/quota.h>
 #include "tst_test.h"
-#include "lapi/quotactl.h"
+#include "quotactl_fmt_var.h"
 #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,9 +51,9 @@
 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_invalid = 1;
 static int test_id;
 static int getnextquota_nsup;
 
@@ -105,7 +113,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 +143,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,19 +158,22 @@ static void verify_quotactl(unsigned int n)
 
 static void setup(void)
 {
-	const char *const cmd[] = {"quotacheck", "-uF", "vfsv0", MNTPOINT, NULL};
 	unsigned int i;
+	const char *const cmd[] = {"quotacheck", "-ugF", fmt_variants[tst_variant].fmt_name, MNTPOINT, NULL};
 
+	tst_res(TINFO, "quotactl() with %s format", fmt_variants[tst_variant].fmt_name);
 	SAFE_CMD(cmd, NULL, NULL);
+	fmt_id = fmt_variants[tst_variant].fmt_id;
+	/* vfsv0 block limit 2^42, vfsv1 block limit 2^63 - 1 */
+	set_dqmax.dqb_bsoftlimit = tst_variant ? 0x20000000000000 : 0x100000000;
 
 	if (access(USRPATH, F_OK) == -1)
 		tst_brk(TFAIL | TERRNO, "user quotafile didn't exist");
 
 	tst_require_quota_support(tst_device->dev, fmt_id, usrpath);
 
-	SAFE_MKDIR(TESTDIR1, 0666);
-	test_id = geteuid();
-	test_invalid = test_id + 1;
+	if (access(TESTDIR1, F_OK) == -1 && errno == ENOENT)
+		SAFE_MKDIR(TESTDIR1, 0666);
 
 	TEST(quotactl(QCMD(Q_GETNEXTQUOTA, USRQUOTA), tst_device->dev,
 		test_id, (void *) &res_ndq));
@@ -175,8 +186,14 @@ static void setup(void)
 	}
 }
 
+static void cleanup(void)
+{
+	SAFE_UNLINK(USRPATH);
+}
+
 static struct tst_test test = {
 	.setup = setup,
+	.cleanup = cleanup,
 	.needs_kconfigs = (const char *[]) {
 		"CONFIG_QFMT_V2",
 		NULL
@@ -192,4 +209,9 @@ static struct tst_test test = {
 		NULL
 	},
 	.needs_root = 1,
+	.test_variants = QUOTACTL_FMT_VARIANTS,
+	.tags = (const struct tst_tag[]) {
+		{"linux-git", "7e08da50cf70"},
+		{}
+	}
 };
-- 
2.23.0


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [LTP] [PATCH v2 03/13] syscalls/quotactl04: Remove useless mount option
  2021-10-27 12:25 [LTP] [PATCH v2 01/13] syscalls/quotactl01: Also test with vfsv1 format Yang Xu
  2021-10-27 12:25 ` [LTP] [PATCH v2 02/13] syscalls/quotactl06: " Yang Xu
@ 2021-10-27 12:25 ` Yang Xu
  2021-11-08 15:40   ` Cyril Hrubis
  2021-10-27 12:26 ` [LTP] [PATCH v2 04/13] syscalls/quotactl:Add docparse formatting Yang Xu
                   ` (3 subsequent siblings)
  5 siblings, 1 reply; 14+ messages in thread
From: Yang Xu @ 2021-10-27 12:25 UTC (permalink / raw)
  To: ltp

When use -O quota options for mkfs.ext4, quota mount option
will be ignored[1]. So remove it.

Also add docparse formatting and remove duplicated header.

Adjust header position.

[1]https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=7c319d3

Signed-off-by: Yang Xu <xuyang2018.jy@fujitsu.com>
---
 .../kernel/syscalls/quotactl/quotactl04.c     | 41 ++++++++-----------
 1 file changed, 17 insertions(+), 24 deletions(-)

diff --git a/testcases/kernel/syscalls/quotactl/quotactl04.c b/testcases/kernel/syscalls/quotactl/quotactl04.c
index fd3afc888..f34050716 100644
--- a/testcases/kernel/syscalls/quotactl/quotactl04.c
+++ b/testcases/kernel/syscalls/quotactl/quotactl04.c
@@ -1,24 +1,22 @@
 // SPDX-License-Identifier: GPL-2.0-or-later
 /*
- * Copyright (c) 2019 FUJITSU LIMITED. All rights reserved.
- * Author: Yang Xu <xuyang2018.jy@cn.fujitsu.com>
+ * Copyright (c) 2019-2021 FUJITSU LIMITED. All rights reserved.
+ * Author: Yang Xu <xuyang2018.jy@fujitsu.com>
+ */
+
+/*\
+ * [Description]
  *
- * This testcase checks the basic flag of quotactl(2) for project quota on
- * non-XFS filesystems.
+ * This testcases checks that quotactl(2) on ext4 filesystem succeeds to:
  *
- * 1) quotactl(2) succeeds to turn on quota with Q_QUOTAON flag for project.
- * 2) quotactl(2) succeeds to set disk quota limits with Q_SETQUOTA flag
- *    for project.
- * 3) quotactl(2) succeeds to get disk quota limits with Q_GETQUOTA flag
- *    for project.
- * 4) quotactl(2) succeeds to set information about quotafile with Q_SETINFO
- *    flag for project.
- * 5) quotactl(2) succeeds to get information about quotafile with Q_GETINFO
- *    flag for project.
- * 6) quotactl(2) succeeds to get quota format with Q_GETFMT flag for project.
- * 7) quotactl(2) succeeds to get disk quota limit greater than or equal to
- *    ID with Q_GETNEXTQUOTA flag for project.
- * 8) quotactl(2) succeeds to turn off quota with Q_QUOTAOFF flag for project.
+ * - turn on quota with Q_QUOTAON flag for project
+ * - set disk quota limits with Q_SETQUOTA flag for project
+ * - get disk quota limits with Q_GETQUOTA flag for project
+ * - set information about quotafile with Q_SETINFO flag for project
+ * - get information about quotafile with Q_GETINFO flag for project
+ * - get quota format with Q_GETFMT flag for project
+ * - get disk quota limit greater than or equal to ID with Q_GETNEXTQUOTA flag for project
+ * - turn off quota with Q_QUOTAOFF flag for project
  *
  * Minimum e2fsprogs version required is 1.43.
  */
@@ -29,14 +27,9 @@
 #include <stdio.h>
 #include <sys/stat.h>
 #include <sys/mount.h>
-#include "config.h"
-#include "lapi/quotactl.h"
 #include "tst_safe_stdio.h"
 #include "tst_test.h"
-
-#ifndef QFMT_VFS_V1
-# define QFMT_VFS_V1 4
-#endif
+#include "lapi/quotactl.h"
 
 #define FMTID QFMT_VFS_V1
 #define MNTPOINT	"mntpoint"
@@ -141,7 +134,7 @@ static void setup(void)
 		tst_brk(TCONF, "Test needs mkfs.ext4 >= 1.43 for quota,project option, test skipped");
 	pclose(f);
 	SAFE_MKFS(tst_device->dev, tst_device->fs_type, fs_opts, NULL);
-	do_mount(tst_device->dev, MNTPOINT, tst_device->fs_type, 0, "quota");
+	do_mount(tst_device->dev, MNTPOINT, tst_device->fs_type, 0, NULL);
 }
 
 static void cleanup(void)
-- 
2.23.0


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [LTP] [PATCH v2 04/13] syscalls/quotactl:Add docparse formatting
  2021-10-27 12:25 [LTP] [PATCH v2 01/13] syscalls/quotactl01: Also test with vfsv1 format Yang Xu
  2021-10-27 12:25 ` [LTP] [PATCH v2 02/13] syscalls/quotactl06: " Yang Xu
  2021-10-27 12:25 ` [LTP] [PATCH v2 03/13] syscalls/quotactl04: Remove useless mount option Yang Xu
@ 2021-10-27 12:26 ` Yang Xu
  2021-11-08 16:08   ` Cyril Hrubis
  2021-10-27 12:26 ` [LTP] [PATCH v2 05/13] lapi/syscalls: Add syscall number for quotactl_fd Yang Xu
                   ` (2 subsequent siblings)
  5 siblings, 1 reply; 14+ messages in thread
From: Yang Xu @ 2021-10-27 12:26 UTC (permalink / raw)
  To: ltp

Also remove useless header files and add linux git in test structure.

Signed-off-by: Yang Xu <xuyang2018.jy@fujitsu.com>
---
 .../kernel/syscalls/quotactl/quotactl02.c     | 54 ++++++-------------
 .../kernel/syscalls/quotactl/quotactl02.h     |  3 +-
 .../kernel/syscalls/quotactl/quotactl03.c     | 17 +++---
 .../kernel/syscalls/quotactl/quotactl05.c     | 32 +++++------
 .../kernel/syscalls/quotactl/quotactl07.c     |  9 ++--
 5 files changed, 49 insertions(+), 66 deletions(-)

diff --git a/testcases/kernel/syscalls/quotactl/quotactl02.c b/testcases/kernel/syscalls/quotactl/quotactl02.c
index ad81ee7e5..55a6a8906 100644
--- a/testcases/kernel/syscalls/quotactl/quotactl02.c
+++ b/testcases/kernel/syscalls/quotactl/quotactl02.c
@@ -1,50 +1,28 @@
 // SPDX-License-Identifier: GPL-2.0-or-later
 /*
- * Copyright (c) 2013-2019 FUJITSU LIMITED. All rights reserved
+ * Copyright (c) 2013-2021 FUJITSU LIMITED. All rights reserved
  * Author: DAN LI <li.dan@cn.fujitsu.com>
- * Author: Yang Xu <xuyang2018.jy@cn.fujitsu.com>
+ * Author: Yang Xu <xuyang2018.jy@fujitsu.com>
  */
 
 /*\
  * [Description]
  *
- * This testcase checks basic flags of quotactl(2) for an XFS file system:
+ * This testcases checks that quotactl(2) on xfs filesystem succeeds to:
  *
- * 1. quotactl(2) succeeds to turn off xfs quota and get xfs quota off status
- *    for user.
- *
- * 2. quotactl(2) succeeds to turn on xfs quota and get xfs quota on status
- *    for user.
- *
- * 3. quotactl(2) succeeds to set and use Q_XGETQUOTA to get xfs disk quota
- *    limits for user.
- *
- * 4. quotactl(2) succeeds to set and use Q_XGETNEXTQUOTA to get xfs disk
- *    quota limits greater than or equal to ID for user.
- *
- * 5. quotactl(2) succeeds to turn off xfs quota and get xfs quota off statv
- *    for user.
- *
- * 6. quotactl(2) succeeds to turn on xfs quota and get xfs quota on statv
- *    for user.
- *
- * 7. quotactl(2) succeeds to turn off xfs quota and get xfs quota off status
- *    for group.
- *
- * 8. quotactl(2) succeeds to turn on xfs quota and get xfs quota on status
- *    for group.
- *
- * 9. quotactl(2) succeeds to set and use Q_XGETQUOTA to get xfs disk quota
- *    limits for group.
- *
- * 10. quotactl(2) succeeds to set and use Q_XGETNEXTQUOTA to get xfs disk
- *     quota limits for group.
- *
- * 11. quotactl(2) succeeds to turn off xfs quota and get xfs quota off statv
- *     for group.
- *
- * 12. quotactl(2) succeeds to turn on xfs quota and get xfs quota on statv
- *     for group.
+ * - turn off xfs quota and get xfs quota off status for user
+ * - turn on xfs quota and get xfs quota on status for user
+ * - set and use Q_XGETQUOTA to get xfs disk quota limits for user
+ * - set and use Q_XGETNEXTQUOTA to get xfs disk quota limits greater than or
+ *   equal to ID for user
+ * - turn off xfs quota and get xfs quota off statv for user
+ * - turn on xfs quota and get xfs quota on statv for user
+ * - turn off xfs quota and get xfs quota off status for group
+ * - turn on xfs quota and get xfs quota on status for group
+ * - set and use Q_XGETQUOTA to get xfs disk quota limits for group
+ * - set and use Q_XGETNEXTQUOTA to get xfs disk quota limits for group
+ * - turn off xfs quota and get xfs quota off statv for group
+ * - turn on xfs quota and get xfs quota on statv for gorup
  */
 
 #include "quotactl02.h"
diff --git a/testcases/kernel/syscalls/quotactl/quotactl02.h b/testcases/kernel/syscalls/quotactl/quotactl02.h
index 37f3d7eb7..3351fb578 100644
--- a/testcases/kernel/syscalls/quotactl/quotactl02.h
+++ b/testcases/kernel/syscalls/quotactl/quotactl02.h
@@ -1,14 +1,13 @@
 // SPDX-License-Identifier: GPL-2.0-or-later
 /*
  * Copyright (c) 2019 FUJITSU LIMITED. All rights reserved.
- * Author: Yang Xu <xuyang2018.jy@cn.fujitsu.com>
+ * Author: Yang Xu <xuyang2018.jy@fujitsu.com>
  */
 
 #ifndef QUOTACTL02_H
 #define QUOTACTL02_H
 
 #define _GNU_SOURCE
-#include "config.h"
 #include <errno.h>
 #include <unistd.h>
 #include <stdio.h>
diff --git a/testcases/kernel/syscalls/quotactl/quotactl03.c b/testcases/kernel/syscalls/quotactl/quotactl03.c
index 3ec931727..e0e4bf5b2 100644
--- a/testcases/kernel/syscalls/quotactl/quotactl03.c
+++ b/testcases/kernel/syscalls/quotactl/quotactl03.c
@@ -4,10 +4,9 @@
  * Author: Xiao Yang <yangx.jy@cn.fujitsu.com>
  */
 
-/*
- * Test Name: quotactl03
+/*\
+ * [Description]
  *
- * Description:
  * quotactl(2) with XGETNEXTQUOTA looks for the next active quota for an user
  * equal or higher to a given ID, in this test the ID is specified to a value
  * close to UINT_MAX(max value of unsigned int). When reaching the upper limit
@@ -16,11 +15,11 @@
  *
  * This kernel bug of xfs has been fixed in:
  *
- * commit 657bdfb7f5e68ca5e2ed009ab473c429b0d6af85
- * Author: Eric Sandeen <sandeen@redhat.com>
- * Date:   Tue Jan 17 11:43:38 2017 -0800
+ *  commit 657bdfb7f5e68ca5e2ed009ab473c429b0d6af85
+ *  Author: Eric Sandeen <sandeen@redhat.com>
+ *  Date:   Tue Jan 17 11:43:38 2017 -0800
  *
- *     xfs: don't wrap ID in xfs_dq_get_next_id
+ *  xfs: don't wrap ID in xfs_dq_get_next_id
  */
 
 #define _GNU_SOURCE
@@ -75,6 +74,10 @@ static struct tst_test test = {
 	.dev_fs_type = "xfs",
 	.mntpoint = mntpoint,
 	.mnt_data = "usrquota",
+	.tags = (const struct tst_tag[]) {
+		{"linux-git", "657bdfb7f5e6"},
+		{}
+	}
 };
 
 #else
diff --git a/testcases/kernel/syscalls/quotactl/quotactl05.c b/testcases/kernel/syscalls/quotactl/quotactl05.c
index e811e47a4..15a6c1e67 100644
--- a/testcases/kernel/syscalls/quotactl/quotactl05.c
+++ b/testcases/kernel/syscalls/quotactl/quotactl05.c
@@ -1,23 +1,23 @@
 // SPDX-License-Identifier: GPL-2.0-or-later
 /*
- * Copyright (c) 2019 FUJITSU LIMITED. All rights reserved.
- * Author: Yang Xu <xuyang2018.jy@cn.fujitsu.com>
+ * Copyright (c) 2019-2021 FUJITSU LIMITED. All rights reserved.
+ * Author: Yang Xu <xuyang2018.jy@.fujitsu.com>
+ */
+
+/*\
+ * [Description]
  *
- * This testcase checks basic flags of quotactl(2) for project on an XFS file
- * system:
- * 1) quotactl(2) succeeds to turn off xfs quota and get xfs quota off status
- *    for project.
- * 2) quotactl(2) succeeds to turn on xfs quota and get xfs quota on status
- *    for project.
- * 3) quotactl(2) succeeds to set and use Q_XGETQUOTA to get xfs disk quota
- *    limits for project.
- * 4) quotactl(2) succeeds to set and use Q_XGETNEXTQUOTA to get xfs disk
- *    quota limits Cgreater than or equal to ID for project.
- * 5) quotactl(2) succeeds to turn off xfs quota and get xfs quota off statv
- *    for project.
- * 6) quotactl(2) succeeds to turn on xfs quota and get xfs quota on statv
- *    for project.
+ * This testcases checks that quotactl(2) on xfs filesystem succeeds to:
+ *
+ * - turn off xfs quota and get xfs quota off status for project
+ * - turn on xfs quota and get xfs quota on status for project
+ * - set and use Q_XGETQUOTA to get xfs disk quota limits for project
+ * - set and use Q_XGETNEXTQUOTA to get xfs disk quota limits greater than or
+ *   equal to ID for project
+ * - turn off xfs quota and get xfs quota off statv for project
+ * - turn on xfs quota and get xfs quota on statvfor project
  */
+
 #include "quotactl02.h"
 #if defined(HAVE_XFS_XQM_H)
 
diff --git a/testcases/kernel/syscalls/quotactl/quotactl07.c b/testcases/kernel/syscalls/quotactl/quotactl07.c
index db477589b..2992a6112 100644
--- a/testcases/kernel/syscalls/quotactl/quotactl07.c
+++ b/testcases/kernel/syscalls/quotactl/quotactl07.c
@@ -1,19 +1,22 @@
 // SPDX-License-Identifier: GPL-2.0-or-later
 /*
  * Copyright (c) 2019 FUJITSU LIMITED. All rights reserved.
- * Author: Yang Xu <xuyang2018.jy@cn.fujitsu.com>
+ * Author: Yang Xu <xuyang2018.jy@fujitsu.com>
+ */
+
+/*\
+ * [Description]
  *
  * This is a regresstion test for kernel commit 3dd4d40b4208
  * ("xfs: Sanity check flags of Q_XQUOTARM call").
  */
 
-#include "config.h"
 #include <errno.h>
 #include <unistd.h>
 #include <stdio.h>
 #include <sys/quota.h>
-#include "lapi/quotactl.h"
 #include "tst_test.h"
+#include "lapi/quotactl.h"
 
 #ifdef HAVE_XFS_XQM_H
 # include <xfs/xqm.h>
-- 
2.23.0


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [LTP] [PATCH v2 05/13] lapi/syscalls: Add syscall number for quotactl_fd
  2021-10-27 12:25 [LTP] [PATCH v2 01/13] syscalls/quotactl01: Also test with vfsv1 format Yang Xu
                   ` (2 preceding siblings ...)
  2021-10-27 12:26 ` [LTP] [PATCH v2 04/13] syscalls/quotactl:Add docparse formatting Yang Xu
@ 2021-10-27 12:26 ` Yang Xu
  2021-11-08 16:09   ` Cyril Hrubis
  2021-11-08  3:27 ` [LTP] [PATCH v2 01/13] syscalls/quotactl01: Also test with vfsv1 format xuyang2018.jy
  2021-11-08 15:25 ` Cyril Hrubis
  5 siblings, 1 reply; 14+ messages in thread
From: Yang Xu @ 2021-10-27 12:26 UTC (permalink / raw)
  To: ltp

Add syscall number for quotactl_fd, refer to glibc's submission[1].

[1]https://sourceware.org/git/?p=glibc.git;a=commitdiff;h=89dc0372a9055e7ef86fe19be6201fa0b16b2f0e

Signed-off-by: Yang Xu <xuyang2018.jy@fujitsu.com>
Reviewed-by: Cyril Hrubis <chrubis@suse.cz>
---
 include/lapi/syscalls/aarch64.in   | 1 +
 include/lapi/syscalls/arc.in       | 1 +
 include/lapi/syscalls/arm.in       | 1 +
 include/lapi/syscalls/hppa.in      | 1 +
 include/lapi/syscalls/i386.in      | 1 +
 include/lapi/syscalls/ia64.in      | 1 +
 include/lapi/syscalls/mips_n32.in  | 1 +
 include/lapi/syscalls/mips_n64.in  | 1 +
 include/lapi/syscalls/mips_o32.in  | 1 +
 include/lapi/syscalls/powerpc.in   | 1 +
 include/lapi/syscalls/powerpc64.in | 1 +
 include/lapi/syscalls/s390.in      | 1 +
 include/lapi/syscalls/s390x.in     | 1 +
 include/lapi/syscalls/sh.in        | 1 +
 include/lapi/syscalls/sparc.in     | 1 +
 include/lapi/syscalls/sparc64.in   | 1 +
 include/lapi/syscalls/x86_64.in    | 1 +
 17 files changed, 17 insertions(+)

diff --git a/include/lapi/syscalls/aarch64.in b/include/lapi/syscalls/aarch64.in
index a47185954..89b63ee4b 100644
--- a/include/lapi/syscalls/aarch64.in
+++ b/include/lapi/syscalls/aarch64.in
@@ -294,4 +294,5 @@ close_range 436
 openat2 437
 pidfd_getfd 438
 epoll_pwait2 441
+quotactl_fd 443
 _sysctl 1078
diff --git a/include/lapi/syscalls/arc.in b/include/lapi/syscalls/arc.in
index 9c1654b0b..72420754a 100644
--- a/include/lapi/syscalls/arc.in
+++ b/include/lapi/syscalls/arc.in
@@ -314,3 +314,4 @@ close_range 436
 openat2 437
 pidfd_getfd 438
 epoll_pwait2 441
+quotactl_fd 443
diff --git a/include/lapi/syscalls/arm.in b/include/lapi/syscalls/arm.in
index ded2f5e03..2a78d7c3c 100644
--- a/include/lapi/syscalls/arm.in
+++ b/include/lapi/syscalls/arm.in
@@ -392,3 +392,4 @@ close_range (__NR_SYSCALL_BASE+436)
 openat2 (__NR_SYSCALL_BASE+437)
 pidfd_getfd (__NR_SYSCALL_BASE+438)
 epoll_pwait2 (__NR_SYSCALL_BASE+441)
+quotactl_fd (__NR_SYSCALL_BASE+443)
diff --git a/include/lapi/syscalls/hppa.in b/include/lapi/syscalls/hppa.in
index d8f142b6a..2f0fc8153 100644
--- a/include/lapi/syscalls/hppa.in
+++ b/include/lapi/syscalls/hppa.in
@@ -41,3 +41,4 @@ fspick 433
 pidfd_open 434
 close_range 436
 epoll_pwait2 441
+quotactl_fd 443
diff --git a/include/lapi/syscalls/i386.in b/include/lapi/syscalls/i386.in
index f69268e10..34a8a621f 100644
--- a/include/lapi/syscalls/i386.in
+++ b/include/lapi/syscalls/i386.in
@@ -428,3 +428,4 @@ close_range 436
 openat2 437
 pidfd_getfd 438
 epoll_pwait2 441
+quotactl_fd 443
diff --git a/include/lapi/syscalls/ia64.in b/include/lapi/syscalls/ia64.in
index 3ba2406c4..b729cd3f0 100644
--- a/include/lapi/syscalls/ia64.in
+++ b/include/lapi/syscalls/ia64.in
@@ -341,3 +341,4 @@ close_range 1460
 openat2 1461
 pidfd_getfd 1462
 epoll_pwait2 1465
+quotactl_fd 1467
diff --git a/include/lapi/syscalls/mips_n32.in b/include/lapi/syscalls/mips_n32.in
index dad8107f4..46098a616 100644
--- a/include/lapi/syscalls/mips_n32.in
+++ b/include/lapi/syscalls/mips_n32.in
@@ -369,3 +369,4 @@ faccessat2 6439
 process_madvise 6440
 epoll_pwait2 6441
 mount_setattr 6442
+quotactl_fd 6443
diff --git a/include/lapi/syscalls/mips_n64.in b/include/lapi/syscalls/mips_n64.in
index a6c0c8cdd..07f96ac5d 100644
--- a/include/lapi/syscalls/mips_n64.in
+++ b/include/lapi/syscalls/mips_n64.in
@@ -345,3 +345,4 @@ faccessat2 5439
 process_madvise 5440
 epoll_pwait2 5441
 mount_setattr 5442
+quotactl_fd 5443
diff --git a/include/lapi/syscalls/mips_o32.in b/include/lapi/syscalls/mips_o32.in
index 238f77009..5e64a4a1c 100644
--- a/include/lapi/syscalls/mips_o32.in
+++ b/include/lapi/syscalls/mips_o32.in
@@ -415,3 +415,4 @@ faccessat2 4439
 process_madvise 4440
 epoll_pwait2 4441
 mount_setattr 4442
+quotactl_fd 4443
diff --git a/include/lapi/syscalls/powerpc.in b/include/lapi/syscalls/powerpc.in
index a4ed2169c..f4e85940c 100644
--- a/include/lapi/syscalls/powerpc.in
+++ b/include/lapi/syscalls/powerpc.in
@@ -421,3 +421,4 @@ close_range 436
 openat2 437
 pidfd_getfd 438
 epoll_pwait2 441
+quotactl_fd 443
diff --git a/include/lapi/syscalls/powerpc64.in b/include/lapi/syscalls/powerpc64.in
index a4ed2169c..f4e85940c 100644
--- a/include/lapi/syscalls/powerpc64.in
+++ b/include/lapi/syscalls/powerpc64.in
@@ -421,3 +421,4 @@ close_range 436
 openat2 437
 pidfd_getfd 438
 epoll_pwait2 441
+quotactl_fd 443
diff --git a/include/lapi/syscalls/s390.in b/include/lapi/syscalls/s390.in
index d99e5fd9e..3e16d8475 100644
--- a/include/lapi/syscalls/s390.in
+++ b/include/lapi/syscalls/s390.in
@@ -408,3 +408,4 @@ close_range 436
 openat2 437
 pidfd_getfd 438
 epoll_pwait2 441
+quotactl_fd 443
diff --git a/include/lapi/syscalls/s390x.in b/include/lapi/syscalls/s390x.in
index f26cdaaae..beb0819af 100644
--- a/include/lapi/syscalls/s390x.in
+++ b/include/lapi/syscalls/s390x.in
@@ -356,3 +356,4 @@ close_range 436
 openat2 437
 pidfd_getfd 438
 epoll_pwait2 441
+quotactl_fd 443
diff --git a/include/lapi/syscalls/sh.in b/include/lapi/syscalls/sh.in
index 20ee61ccc..a81cf8297 100644
--- a/include/lapi/syscalls/sh.in
+++ b/include/lapi/syscalls/sh.in
@@ -402,3 +402,4 @@ close_range 436
 openat2 437
 pidfd_getfd 438
 epoll_pwait2 441
+quotactl_fd 443
diff --git a/include/lapi/syscalls/sparc.in b/include/lapi/syscalls/sparc.in
index 86decdd82..6a7817ae5 100644
--- a/include/lapi/syscalls/sparc.in
+++ b/include/lapi/syscalls/sparc.in
@@ -407,3 +407,4 @@ close_range 436
 openat2 437
 pidfd_getfd 438
 epoll_pwait2 441
+quotactl_fd 443
diff --git a/include/lapi/syscalls/sparc64.in b/include/lapi/syscalls/sparc64.in
index 02dfe473a..d3995181c 100644
--- a/include/lapi/syscalls/sparc64.in
+++ b/include/lapi/syscalls/sparc64.in
@@ -372,3 +372,4 @@ close_range 436
 openat2 437
 pidfd_getfd 438
 epoll_pwait2 441
+quotactl_fd 443
diff --git a/include/lapi/syscalls/x86_64.in b/include/lapi/syscalls/x86_64.in
index cf6d78bf6..a5b2a24fe 100644
--- a/include/lapi/syscalls/x86_64.in
+++ b/include/lapi/syscalls/x86_64.in
@@ -349,6 +349,7 @@ close_range 436
 openat2 437
 pidfd_getfd 438
 epoll_pwait2 441
+quotactl_fd 443
 rt_sigaction 512
 rt_sigreturn 513
 ioctl 514
-- 
2.23.0


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* Re: [LTP] [PATCH v2 01/13] syscalls/quotactl01: Also test with vfsv1 format
  2021-10-27 12:25 [LTP] [PATCH v2 01/13] syscalls/quotactl01: Also test with vfsv1 format Yang Xu
                   ` (3 preceding siblings ...)
  2021-10-27 12:26 ` [LTP] [PATCH v2 05/13] lapi/syscalls: Add syscall number for quotactl_fd Yang Xu
@ 2021-11-08  3:27 ` xuyang2018.jy
  2021-11-08 15:25 ` Cyril Hrubis
  5 siblings, 0 replies; 14+ messages in thread
From: xuyang2018.jy @ 2021-11-08  3:27 UTC (permalink / raw)
  To: ltp

Hi All

ping.

There is no problem with the first six patches and other patches need to
be modified v3(needs mkfs.ext4 supports quota feature when quota info
hidden in filesystem and open mntpoint instead of testfile when using
quotactl_fd).

I guess we can review the first six patches and merged, then I will send
a v3 for others.

ps: Remove testfile for quotactl_fd and use mntpoint directly. See the
discussion in the following url:
https://lore.kernel.org/linux-man/20211105112045.GA26497@quack2.suse.cz/T/#m41a9666d01d43a29973a5a6a61b02b0c4e9f0df1

Best Regards
Yang Xu
> Since usrquota and groupquota supports visible quota files
> with two formats(vfsv0 and vfsv1) on ext4, so add a test variants to
> test it.
> 
> Also fix docparse formatting and move some code to lapi/quotactl.h or
> quotactl_var.h for reuse.
> 
> Remove useless geteuid.
> 
> Signed-off-by: Yang Xu<xuyang2018.jy@fujitsu.com>
> ---
>   include/lapi/quotactl.h                       |  9 +++
>   .../kernel/syscalls/quotactl/quotactl01.c     | 79 +++++++++----------
>   .../syscalls/quotactl/quotactl_fmt_var.h      | 22 ++++++
>   3 files changed, 70 insertions(+), 40 deletions(-)
>   create mode 100644 testcases/kernel/syscalls/quotactl/quotactl_fmt_var.h
> 
> diff --git a/include/lapi/quotactl.h b/include/lapi/quotactl.h
> index c1ec9d6e1..8e0315d03 100644
> --- a/include/lapi/quotactl.h
> +++ b/include/lapi/quotactl.h
> @@ -8,6 +8,7 @@
>   #ifndef LAPI_QUOTACTL_H__
>   #define LAPI_QUOTACTL_H__
> 
> +#include "config.h"
>   #include<sys/quota.h>
> 
>   #ifdef HAVE_STRUCT_IF_NEXTDQBLK
> @@ -75,4 +76,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..7a71dd5fc 100644
> --- a/testcases/kernel/syscalls/quotactl/quotactl01.c
> +++ b/testcases/kernel/syscalls/quotactl/quotactl01.c
> @@ -1,57 +1,47 @@
>   // 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 testcases checks that quotactl(2) on ext4 filesystem succeeds to:
>    *
> - * 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
> - *    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.
> + * - 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
>    */
> 
> -#include "config.h"
>   #include<errno.h>
>   #include<string.h>
>   #include<unistd.h>
>   #include<stdio.h>
> -#include "lapi/quotactl.h"
>   #include "tst_test.h"
> +#include "quotactl_fmt_var.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 int32_t fmt_id;
>   static int test_id;
>   static char usrpath[] = USRPATH;
>   static char grppath[] = GRPPATH;
> @@ -163,11 +153,12 @@ static struct tcase {
> 
>   static void setup(void)
>   {
> -	const char *const cmd[] = {"quotacheck", "-ugF", "vfsv0", MNTPOINT, NULL};
> +	const char *const cmd[] = {"quotacheck", "-ugF", fmt_variants[tst_variant].fmt_name, MNTPOINT, NULL};
> 
> +	tst_res(TINFO, "quotactl() with %s format", fmt_variants[tst_variant].fmt_name);
>   	SAFE_CMD(cmd, NULL, NULL);
> +	fmt_id = fmt_variants[tst_variant].fmt_id;
> 
> -	test_id = geteuid();
>   	if (access(USRPATH, F_OK) == -1)
>   		tst_brk(TFAIL | TERRNO, "user quotafile didn't exist");
> 
> @@ -182,6 +173,12 @@ static void setup(void)
>   		getnextquota_nsup = 1;
>   }
> 
> +static void cleanup(void)
> +{
> +	SAFE_UNLINK(USRPATH);
> +	SAFE_UNLINK(GRPPATH);
> +}
> +
>   static void verify_quota(unsigned int n)
>   {
>   	struct tcase *tc =&tcases[n];
> @@ -223,12 +220,14 @@ static struct tst_test test = {
>   	.test = verify_quota,
>   	.tcnt = ARRAY_SIZE(tcases),
>   	.mount_device = 1,
> -	.dev_fs_type = "ext4",
>   	.mntpoint = MNTPOINT,
> +	.dev_fs_type = "ext4",
>   	.mnt_data = "usrquota,grpquota",
>   	.needs_cmds = (const char *const []) {
>   		"quotacheck",
>   		NULL
>   	},
>   	.setup = setup,
> +	.cleanup = cleanup,
> +	.test_variants = QUOTACTL_FMT_VARIANTS,
>   };
> diff --git a/testcases/kernel/syscalls/quotactl/quotactl_fmt_var.h b/testcases/kernel/syscalls/quotactl/quotactl_fmt_var.h
> new file mode 100644
> index 000000000..cb9fa4625
> --- /dev/null
> +++ b/testcases/kernel/syscalls/quotactl/quotactl_fmt_var.h
> @@ -0,0 +1,22 @@
> +// 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_FMT_VAR_H
> +#define LTP_QUOTACTL_FMT_VAR_H
> +
> +#include "lapi/quotactl.h"
> +
> +#define QUOTACTL_FMT_VARIANTS 2
> +
> +static struct quotactl_fmt_variant {
> +	int32_t fmt_id;
> +	const char *fmt_name;
> +} fmt_variants[] = {
> +	{.fmt_id = QFMT_VFS_V0, .fmt_name = "vfsv0"},
> +	{.fmt_id = QFMT_VFS_V1, .fmt_name = "vfsv1"}
> +};
> +
> +#endif /* LAPI_QUOTACTL_FMT_VAR_H__ */

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [LTP] [PATCH v2 01/13] syscalls/quotactl01: Also test with vfsv1 format
  2021-10-27 12:25 [LTP] [PATCH v2 01/13] syscalls/quotactl01: Also test with vfsv1 format Yang Xu
                   ` (4 preceding siblings ...)
  2021-11-08  3:27 ` [LTP] [PATCH v2 01/13] syscalls/quotactl01: Also test with vfsv1 format xuyang2018.jy
@ 2021-11-08 15:25 ` Cyril Hrubis
  2021-11-09  5:13   ` xuyang2018.jy
  5 siblings, 1 reply; 14+ messages in thread
From: Cyril Hrubis @ 2021-11-08 15:25 UTC (permalink / raw)
  To: Yang Xu; +Cc: ltp

Hi!
>  static void setup(void)
>  {
> -	const char *const cmd[] = {"quotacheck", "-ugF", "vfsv0", MNTPOINT, NULL};
> +	const char *const cmd[] = {"quotacheck", "-ugF", fmt_variants[tst_variant].fmt_name, MNTPOINT, NULL};

I would be inclined to store the variants pointer on a first line in the
setup so that the code gets slightly easier to read as:

	const struct quotactl_fmt_variant *var = &fmt_variants[tst_variant];

Then we can do var->fmt_name and var->fmt_id in the rest of the setup code...

Anyways the code looks good:

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] 14+ messages in thread

* Re: [LTP] [PATCH v2 02/13] syscalls/quotactl06: Also test with vfsv1 format
  2021-10-27 12:25 ` [LTP] [PATCH v2 02/13] syscalls/quotactl06: " Yang Xu
@ 2021-11-08 15:29   ` Cyril Hrubis
  2021-11-09  6:59     ` xuyang2018.jy
  0 siblings, 1 reply; 14+ messages in thread
From: Cyril Hrubis @ 2021-11-08 15:29 UTC (permalink / raw)
  To: Yang Xu; +Cc: ltp

> Add a linux tag and fix docparse formatting.

I guess that the 'remove useless geteuid()' should be in the description
for this patch and not in the previous one.

> Signed-off-by: Yang Xu <xuyang2018.jy@fujitsu.com>
> ---
>  .../kernel/syscalls/quotactl/quotactl06.c     | 90 ++++++++++++-------
>  1 file changed, 56 insertions(+), 34 deletions(-)
> 
> diff --git a/testcases/kernel/syscalls/quotactl/quotactl06.c b/testcases/kernel/syscalls/quotactl/quotactl06.c
> index a10d1ca07..76343adf9 100644
> --- a/testcases/kernel/syscalls/quotactl/quotactl06.c
> +++ b/testcases/kernel/syscalls/quotactl/quotactl06.c
> @@ -1,41 +1,49 @@
>  // SPDX-License-Identifier: GPL-2.0-or-later
>  /*
> - * Copyright (c) 2019 FUJITSU LIMITED. All rights reserved.
> - * Author: Yang Xu <xuyang2018.jy@cn.fujitsu.com>
> + * Copyright (c) 2019-2021 FUJITSU LIMITED. All rights reserved.
> + * Author: Yang Xu <xuyang2018.jy@fujitsu.com>
> + */
> +
> +/*\
> + * [Description]
> + *
> + * Tests basic error handling of the quotactl syscall with visible quota files
> + * (cover two formats, vfsv0 and vfsv1):
> + *
> + * - EACCES when cmd is Q_QUOTAON and addr existed but not a regular file
> + * - ENOENT when the file specified by special or addr does not exist
> + * - EBUSTY when cmd is Q_QUOTAON and another Q_QUOTAON had already been performed
> + * - EFAULT when addr or special is invalid
> + * - EINVAL when cmd or type is invalid
> + * - ENOTBLK when special is not a block device
> + * - ESRCH when no disk quota is found for the indicated user and quotas have not been
> + *   turned on for this fs
> + * - ESRCH when cmd is Q_QUOTAON, but the quota format was not found
> + * - ESRCH when cmd is Q_GETNEXTQUOTA, but there is no ID greater than or equal to id that
> + *   has an active quota
> + * - ERANGE when cmd is Q_SETQUOTA, but the specified limits are out of the range allowed
> + *   by the quota format
> + * - EPERM when the caller lacked the required privilege (CAP_SYS_ADMIN) for the specified
> + *   operation
> + *
> + * For ERANGE error, the vfsv0 and vfsv1 format's maximum quota limit setting have been
> + * fixed since the following kernel patch:
> + *
> + *  commit 7e08da50cf706151f324349f9235ebd311226997
> + *  Author: Jan Kara <jack@suse.cz>
> + *  Date:   Wed Mar 4 14:42:02 2015 +0100
>   *
> - * 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.
> + *  quota: Fix maximum quota limit settings
>   */
>  
>  #include <errno.h>
>  #include <sys/quota.h>
>  #include "tst_test.h"
> -#include "lapi/quotactl.h"
> +#include "quotactl_fmt_var.h"
>  #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,9 +51,9 @@
>  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_invalid = 1;
>  static int test_id;
>  static int getnextquota_nsup;
>  
> @@ -105,7 +113,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 +143,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,19 +158,22 @@ static void verify_quotactl(unsigned int n)
>  
>  static void setup(void)
>  {
> -	const char *const cmd[] = {"quotacheck", "-uF", "vfsv0", MNTPOINT, NULL};
>  	unsigned int i;
> +	const char *const cmd[] = {"quotacheck", "-ugF", fmt_variants[tst_variant].fmt_name, MNTPOINT, NULL};

Here as well, I would consider storing the variants pointer.

> +	tst_res(TINFO, "quotactl() with %s format", fmt_variants[tst_variant].fmt_name);
>  	SAFE_CMD(cmd, NULL, NULL);
> +	fmt_id = fmt_variants[tst_variant].fmt_id;
> +	/* vfsv0 block limit 2^42, vfsv1 block limit 2^63 - 1 */
> +	set_dqmax.dqb_bsoftlimit = tst_variant ? 0x20000000000000 : 0x100000000;
>  
>  	if (access(USRPATH, F_OK) == -1)
>  		tst_brk(TFAIL | TERRNO, "user quotafile didn't exist");
>  
>  	tst_require_quota_support(tst_device->dev, fmt_id, usrpath);
>  
> -	SAFE_MKDIR(TESTDIR1, 0666);
> -	test_id = geteuid();
> -	test_invalid = test_id + 1;
> +	if (access(TESTDIR1, F_OK) == -1 && errno == ENOENT)
> +		SAFE_MKDIR(TESTDIR1, 0666);

Why don't we SAFE_RMDIR() in the test cleanup and create the directory
here unconditionally?

Other than this:

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] 14+ messages in thread

* Re: [LTP] [PATCH v2 03/13] syscalls/quotactl04: Remove useless mount option
  2021-10-27 12:25 ` [LTP] [PATCH v2 03/13] syscalls/quotactl04: Remove useless mount option Yang Xu
@ 2021-11-08 15:40   ` Cyril Hrubis
  2021-11-09  8:14     ` xuyang2018.jy
  0 siblings, 1 reply; 14+ messages in thread
From: Cyril Hrubis @ 2021-11-08 15:40 UTC (permalink / raw)
  To: Yang Xu; +Cc: ltp

Hi!
> Adjust header position.
> 
> [1]https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=7c319d3

So this went in to Linux 3.5 looking at supported versions of SLES and
RHEL it looks that anything older went out of support, so it's likely
that we do not care anymore.

Or does anyone still needs to test quota on kernels older than 3.5?


> Signed-off-by: Yang Xu <xuyang2018.jy@fujitsu.com>
> ---
>  .../kernel/syscalls/quotactl/quotactl04.c     | 41 ++++++++-----------
>  1 file changed, 17 insertions(+), 24 deletions(-)
> 
> diff --git a/testcases/kernel/syscalls/quotactl/quotactl04.c b/testcases/kernel/syscalls/quotactl/quotactl04.c
> index fd3afc888..f34050716 100644
> --- a/testcases/kernel/syscalls/quotactl/quotactl04.c
> +++ b/testcases/kernel/syscalls/quotactl/quotactl04.c
> @@ -1,24 +1,22 @@
>  // SPDX-License-Identifier: GPL-2.0-or-later
>  /*
> - * Copyright (c) 2019 FUJITSU LIMITED. All rights reserved.
> - * Author: Yang Xu <xuyang2018.jy@cn.fujitsu.com>
> + * Copyright (c) 2019-2021 FUJITSU LIMITED. All rights reserved.
> + * Author: Yang Xu <xuyang2018.jy@fujitsu.com>
> + */
> +
> +/*\
> + * [Description]
>   *
> - * This testcase checks the basic flag of quotactl(2) for project quota on
> - * non-XFS filesystems.
> + * This testcases checks that quotactl(2) on ext4 filesystem succeeds to:
>   *
> - * 1) quotactl(2) succeeds to turn on quota with Q_QUOTAON flag for project.
> - * 2) quotactl(2) succeeds to set disk quota limits with Q_SETQUOTA flag
> - *    for project.
> - * 3) quotactl(2) succeeds to get disk quota limits with Q_GETQUOTA flag
> - *    for project.
> - * 4) quotactl(2) succeeds to set information about quotafile with Q_SETINFO
> - *    flag for project.
> - * 5) quotactl(2) succeeds to get information about quotafile with Q_GETINFO
> - *    flag for project.
> - * 6) quotactl(2) succeeds to get quota format with Q_GETFMT flag for project.
> - * 7) quotactl(2) succeeds to get disk quota limit greater than or equal to
> - *    ID with Q_GETNEXTQUOTA flag for project.
> - * 8) quotactl(2) succeeds to turn off quota with Q_QUOTAOFF flag for project.
> + * - turn on quota with Q_QUOTAON flag for project
> + * - set disk quota limits with Q_SETQUOTA flag for project
> + * - get disk quota limits with Q_GETQUOTA flag for project
> + * - set information about quotafile with Q_SETINFO flag for project
> + * - get information about quotafile with Q_GETINFO flag for project
> + * - get quota format with Q_GETFMT flag for project
> + * - get disk quota limit greater than or equal to ID with Q_GETNEXTQUOTA flag for project
> + * - turn off quota with Q_QUOTAOFF flag for project
>   *
>   * Minimum e2fsprogs version required is 1.43.
>   */

It would be cleaner to separate the change to the description from the
possibly functional change that removes the mount option. It would be
much easier to revert the functional change in the very unlikely case
that we ever need it.

> @@ -29,14 +27,9 @@
>  #include <stdio.h>
>  #include <sys/stat.h>
>  #include <sys/mount.h>
> -#include "config.h"
> -#include "lapi/quotactl.h"
>  #include "tst_safe_stdio.h"
>  #include "tst_test.h"
> -
> -#ifndef QFMT_VFS_V1
> -# define QFMT_VFS_V1 4
> -#endif
> +#include "lapi/quotactl.h"
>  
>  #define FMTID QFMT_VFS_V1
>  #define MNTPOINT	"mntpoint"
> @@ -141,7 +134,7 @@ static void setup(void)
>  		tst_brk(TCONF, "Test needs mkfs.ext4 >= 1.43 for quota,project option, test skipped");
>  	pclose(f);
>  	SAFE_MKFS(tst_device->dev, tst_device->fs_type, fs_opts, NULL);
> -	do_mount(tst_device->dev, MNTPOINT, tst_device->fs_type, 0, "quota");
> +	do_mount(tst_device->dev, MNTPOINT, tst_device->fs_type, 0, NULL);
>  }
>  
>  static void cleanup(void)
> -- 
> 2.23.0
> 
> 
> -- 
> Mailing list info: https://lists.linux.it/listinfo/ltp

-- 
Cyril Hrubis
chrubis@suse.cz

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [LTP] [PATCH v2 04/13] syscalls/quotactl:Add docparse formatting
  2021-10-27 12:26 ` [LTP] [PATCH v2 04/13] syscalls/quotactl:Add docparse formatting Yang Xu
@ 2021-11-08 16:08   ` Cyril Hrubis
  0 siblings, 0 replies; 14+ messages in thread
From: Cyril Hrubis @ 2021-11-08 16:08 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] 14+ messages in thread

* Re: [LTP] [PATCH v2 05/13] lapi/syscalls: Add syscall number for quotactl_fd
  2021-10-27 12:26 ` [LTP] [PATCH v2 05/13] lapi/syscalls: Add syscall number for quotactl_fd Yang Xu
@ 2021-11-08 16:09   ` Cyril Hrubis
  0 siblings, 0 replies; 14+ messages in thread
From: Cyril Hrubis @ 2021-11-08 16:09 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] 14+ messages in thread

* Re: [LTP] [PATCH v2 01/13] syscalls/quotactl01: Also test with vfsv1 format
  2021-11-08 15:25 ` Cyril Hrubis
@ 2021-11-09  5:13   ` xuyang2018.jy
  0 siblings, 0 replies; 14+ messages in thread
From: xuyang2018.jy @ 2021-11-09  5:13 UTC (permalink / raw)
  To: Cyril Hrubis; +Cc: ltp

Hi Cyril
> Hi!
>>   static void setup(void)
>>   {
>> -	const char *const cmd[] = {"quotacheck", "-ugF", "vfsv0", MNTPOINT, NULL};
>> +	const char *const cmd[] = {"quotacheck", "-ugF", fmt_variants[tst_variant].fmt_name, MNTPOINT, NULL};
>
> I would be inclined to store the variants pointer on a first line in the
> setup so that the code gets slightly easier to read as:
>
> 	const struct quotactl_fmt_variant *var =&fmt_variants[tst_variant];
>
> Then we can do var->fmt_name and var->fmt_id in the rest of the setup code...
Yes, it looks more easier. Will do it in v3.
>
> Anyways the code looks good:
>
> Reviewed-by: Cyril Hrubis<chrubis@suse.cz>
Thanks for your review.
>

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [LTP] [PATCH v2 02/13] syscalls/quotactl06: Also test with vfsv1 format
  2021-11-08 15:29   ` Cyril Hrubis
@ 2021-11-09  6:59     ` xuyang2018.jy
  0 siblings, 0 replies; 14+ messages in thread
From: xuyang2018.jy @ 2021-11-09  6:59 UTC (permalink / raw)
  To: Cyril Hrubis; +Cc: ltp

Hi Cyril
>> Add a linux tag and fix docparse formatting.
>
> I guess that the 'remove useless geteuid()' should be in the description
> for this patch and not in the previous one.
This patch should add 'remove useless geteuid()' and the previous patch 
also has removed useless geteuid().
>
>> Signed-off-by: Yang Xu<xuyang2018.jy@fujitsu.com>
>> ---
>>   .../kernel/syscalls/quotactl/quotactl06.c     | 90 ++++++++++++-------
>>   1 file changed, 56 insertions(+), 34 deletions(-)
>>
>> diff --git a/testcases/kernel/syscalls/quotactl/quotactl06.c b/testcases/kernel/syscalls/quotactl/quotactl06.c
>> index a10d1ca07..76343adf9 100644
>> --- a/testcases/kernel/syscalls/quotactl/quotactl06.c
>> +++ b/testcases/kernel/syscalls/quotactl/quotactl06.c
>> @@ -1,41 +1,49 @@
>>   // SPDX-License-Identifier: GPL-2.0-or-later
>>   /*
>> - * Copyright (c) 2019 FUJITSU LIMITED. All rights reserved.
>> - * Author: Yang Xu<xuyang2018.jy@cn.fujitsu.com>
>> + * Copyright (c) 2019-2021 FUJITSU LIMITED. All rights reserved.
>> + * Author: Yang Xu<xuyang2018.jy@fujitsu.com>
>> + */
>> +
>> +/*\
>> + * [Description]
>> + *
>> + * Tests basic error handling of the quotactl syscall with visible quota files
>> + * (cover two formats, vfsv0 and vfsv1):
>> + *
>> + * - EACCES when cmd is Q_QUOTAON and addr existed but not a regular file
>> + * - ENOENT when the file specified by special or addr does not exist
>> + * - EBUSTY when cmd is Q_QUOTAON and another Q_QUOTAON had already been performed
>> + * - EFAULT when addr or special is invalid
>> + * - EINVAL when cmd or type is invalid
>> + * - ENOTBLK when special is not a block device
>> + * - ESRCH when no disk quota is found for the indicated user and quotas have not been
>> + *   turned on for this fs
>> + * - ESRCH when cmd is Q_QUOTAON, but the quota format was not found
>> + * - ESRCH when cmd is Q_GETNEXTQUOTA, but there is no ID greater than or equal to id that
>> + *   has an active quota
>> + * - ERANGE when cmd is Q_SETQUOTA, but the specified limits are out of the range allowed
>> + *   by the quota format
>> + * - EPERM when the caller lacked the required privilege (CAP_SYS_ADMIN) for the specified
>> + *   operation
>> + *
>> + * For ERANGE error, the vfsv0 and vfsv1 format's maximum quota limit setting have been
>> + * fixed since the following kernel patch:
>> + *
>> + *  commit 7e08da50cf706151f324349f9235ebd311226997
>> + *  Author: Jan Kara<jack@suse.cz>
>> + *  Date:   Wed Mar 4 14:42:02 2015 +0100
>>    *
>> - * 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.
>> + *  quota: Fix maximum quota limit settings
>>    */
>>
>>   #include<errno.h>
>>   #include<sys/quota.h>
>>   #include "tst_test.h"
>> -#include "lapi/quotactl.h"
>> +#include "quotactl_fmt_var.h"
>>   #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,9 +51,9 @@
>>   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_invalid = 1;
>>   static int test_id;
>>   static int getnextquota_nsup;
>>
>> @@ -105,7 +113,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 +143,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,19 +158,22 @@ static void verify_quotactl(unsigned int n)
>>
>>   static void setup(void)
>>   {
>> -	const char *const cmd[] = {"quotacheck", "-uF", "vfsv0", MNTPOINT, NULL};
>>   	unsigned int i;
>> +	const char *const cmd[] = {"quotacheck", "-ugF", fmt_variants[tst_variant].fmt_name, MNTPOINT, NULL};
>
> Here as well, I would consider storing the variants pointer.
Will do.
>
>> +	tst_res(TINFO, "quotactl() with %s format", fmt_variants[tst_variant].fmt_name);
>>   	SAFE_CMD(cmd, NULL, NULL);
>> +	fmt_id = fmt_variants[tst_variant].fmt_id;
>> +	/* vfsv0 block limit 2^42, vfsv1 block limit 2^63 - 1 */
>> +	set_dqmax.dqb_bsoftlimit = tst_variant ? 0x20000000000000 : 0x100000000;
>>
>>   	if (access(USRPATH, F_OK) == -1)
>>   		tst_brk(TFAIL | TERRNO, "user quotafile didn't exist");
>>
>>   	tst_require_quota_support(tst_device->dev, fmt_id, usrpath);
>>
>> -	SAFE_MKDIR(TESTDIR1, 0666);
>> -	test_id = geteuid();
>> -	test_invalid = test_id + 1;
>> +	if (access(TESTDIR1, F_OK) == -1&&  errno == ENOENT)
>> +		SAFE_MKDIR(TESTDIR1, 0666);
>
> Why don't we SAFE_RMDIR() in the test cleanup and create the directory
> here unconditionally?
Yes, Will mkdir in setup and rmdir in cleanup.
>
> Other than this:
>
> Reviewed-by: Cyril Hrubis<chrubis@suse.cz>
>

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [LTP] [PATCH v2 03/13] syscalls/quotactl04: Remove useless mount option
  2021-11-08 15:40   ` Cyril Hrubis
@ 2021-11-09  8:14     ` xuyang2018.jy
  0 siblings, 0 replies; 14+ messages in thread
From: xuyang2018.jy @ 2021-11-09  8:14 UTC (permalink / raw)
  To: Cyril Hrubis; +Cc: ltp

Hi Cyril
> Hi!
>> Adjust header position.
>>
>> [1]https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=7c319d3
>
> So this went in to Linux 3.5 looking at supported versions ofSLES and
>RHEL it looks that anything older went out of support, so it's likely
> that we do not care anymore.
>
> Or does anyone still needs to test quota on kernels older than 3.5?
 From my side, I don't test such old kernel.
I list this kernel commit, just want to said the quota mount option is 
no need.
>
>
>> Signed-off-by: Yang Xu<xuyang2018.jy@fujitsu.com>
>> ---
>>   .../kernel/syscalls/quotactl/quotactl04.c     | 41 ++++++++-----------
>>   1 file changed, 17 insertions(+), 24 deletions(-)
>>
>> diff --git a/testcases/kernel/syscalls/quotactl/quotactl04.c b/testcases/kernel/syscalls/quotactl/quotactl04.c
>> index fd3afc888..f34050716 100644
>> --- a/testcases/kernel/syscalls/quotactl/quotactl04.c
>> +++ b/testcases/kernel/syscalls/quotactl/quotactl04.c
>> @@ -1,24 +1,22 @@
>>   // SPDX-License-Identifier: GPL-2.0-or-later
>>   /*
>> - * Copyright (c) 2019 FUJITSU LIMITED. All rights reserved.
>> - * Author: Yang Xu<xuyang2018.jy@cn.fujitsu.com>
>> + * Copyright (c) 2019-2021 FUJITSU LIMITED. All rights reserved.
>> + * Author: Yang Xu<xuyang2018.jy@fujitsu.com>
>> + */
>> +
>> +/*\
>> + * [Description]
>>    *
>> - * This testcase checks the basic flag of quotactl(2) for project quota on
>> - * non-XFS filesystems.
>> + * This testcases checks that quotactl(2) on ext4 filesystem succeeds to:
>>    *
>> - * 1) quotactl(2) succeeds to turn on quota with Q_QUOTAON flag for project.
>> - * 2) quotactl(2) succeeds to set disk quota limits with Q_SETQUOTA flag
>> - *    for project.
>> - * 3) quotactl(2) succeeds to get disk quota limits with Q_GETQUOTA flag
>> - *    for project.
>> - * 4) quotactl(2) succeeds to set information about quotafile with Q_SETINFO
>> - *    flag for project.
>> - * 5) quotactl(2) succeeds to get information about quotafile with Q_GETINFO
>> - *    flag for project.
>> - * 6) quotactl(2) succeeds to get quota format with Q_GETFMT flag for project.
>> - * 7) quotactl(2) succeeds to get disk quota limit greater than or equal to
>> - *    ID with Q_GETNEXTQUOTA flag for project.
>> - * 8) quotactl(2) succeeds to turn off quota with Q_QUOTAOFF flag for project.
>> + * - turn on quota with Q_QUOTAON flag for project
>> + * - set disk quota limits with Q_SETQUOTA flag for project
>> + * - get disk quota limits with Q_GETQUOTA flag for project
>> + * - set information about quotafile with Q_SETINFO flag for project
>> + * - get information about quotafile with Q_GETINFO flag for project
>> + * - get quota format with Q_GETFMT flag for project
>> + * - get disk quota limit greater than or equal to ID with Q_GETNEXTQUOTA flag for project
>> + * - turn off quota with Q_QUOTAOFF flag for project
>>    *
>>    * Minimum e2fsprogs version required is 1.43.
>>    */
>
> It would be cleaner to separate the change to the description from the
> possibly functional change that removes the mount option. It would be
> much easier to revert the functional change in the very unlikely case
> that we ever need it.
Ok. I will move this change to the next patch.
>
>> @@ -29,14 +27,9 @@
>>   #include<stdio.h>
>>   #include<sys/stat.h>
>>   #include<sys/mount.h>
>> -#include "config.h"
>> -#include "lapi/quotactl.h"
>>   #include "tst_safe_stdio.h"
>>   #include "tst_test.h"
>> -
>> -#ifndef QFMT_VFS_V1
>> -# define QFMT_VFS_V1 4
>> -#endif
>> +#include "lapi/quotactl.h"
>>
>>   #define FMTID QFMT_VFS_V1
>>   #define MNTPOINT	"mntpoint"
>> @@ -141,7 +134,7 @@ static void setup(void)
>>   		tst_brk(TCONF, "Test needs mkfs.ext4>= 1.43 for quota,project option, test skipped");
>>   	pclose(f);
>>   	SAFE_MKFS(tst_device->dev, tst_device->fs_type, fs_opts, NULL);
>> -	do_mount(tst_device->dev, MNTPOINT, tst_device->fs_type, 0, "quota");
>> +	do_mount(tst_device->dev, MNTPOINT, tst_device->fs_type, 0, NULL);
>>   }
>>
>>   static void cleanup(void)
>> --
>> 2.23.0
>>
>>
>> --
>> Mailing list info: https://lists.linux.it/listinfo/ltp
>

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2021-11-09  8:14 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-27 12:25 [LTP] [PATCH v2 01/13] syscalls/quotactl01: Also test with vfsv1 format Yang Xu
2021-10-27 12:25 ` [LTP] [PATCH v2 02/13] syscalls/quotactl06: " Yang Xu
2021-11-08 15:29   ` Cyril Hrubis
2021-11-09  6:59     ` xuyang2018.jy
2021-10-27 12:25 ` [LTP] [PATCH v2 03/13] syscalls/quotactl04: Remove useless mount option Yang Xu
2021-11-08 15:40   ` Cyril Hrubis
2021-11-09  8:14     ` xuyang2018.jy
2021-10-27 12:26 ` [LTP] [PATCH v2 04/13] syscalls/quotactl:Add docparse formatting Yang Xu
2021-11-08 16:08   ` Cyril Hrubis
2021-10-27 12:26 ` [LTP] [PATCH v2 05/13] lapi/syscalls: Add syscall number for quotactl_fd Yang Xu
2021-11-08 16:09   ` Cyril Hrubis
2021-11-08  3:27 ` [LTP] [PATCH v2 01/13] syscalls/quotactl01: Also test with vfsv1 format xuyang2018.jy
2021-11-08 15:25 ` Cyril Hrubis
2021-11-09  5:13   ` xuyang2018.jy

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.