[LTP] [PATCH v2 3/3] syscalls/ftruncate: Rewrite ftruncate04

Cyril Hrubis chrubis@suse.cz
Tue Aug 13 17:10:01 CEST 2019


Hi!
Pushed with a few changes, thanks.

diff --git a/testcases/kernel/syscalls/ftruncate/ftruncate04.c b/testcases/kernel/syscalls/ftruncate/ftruncate04.c
index 097c283f4..53d395d1f 100644
--- a/testcases/kernel/syscalls/ftruncate/ftruncate04.c
+++ b/testcases/kernel/syscalls/ftruncate/ftruncate04.c
@@ -38,7 +38,7 @@
 #define MNTPOINT	"mntpoint"
 #define TESTFILE	MNTPOINT"/testfile"
 
-static int len = 1024;
+static int len = 8 * 1024;
                  ^
		  This was needlessly modified so I just returned it to
		  previous value.

 static int recstart, reclen;
 
 static void ftruncate_expect_fail(int fd, off_t offset, const char *msg)
@@ -151,14 +151,11 @@ static void verify_ftruncate(void)
 
 static void setup(void)
 {
-	struct statvfs fs;
-
-	if (statvfs(".", &fs) == -1)
-		tst_brk(TFAIL | TERRNO, "statvfs failed");
-
-	if ((fs.f_flag & MS_MANDLOCK))
-		return;
-

When the test was mounting the device in the setup this code was here to
skip the mkfs and mount in a case that the tmp was mounted with
mandatory locking, but after the change to .mount_device it became
meaningless. Moreover it would break the test in a case that the TMPDIR
was in fact mounted with mandatory locking.

+	 /*
+	  * Kernel returns EPERM when CONFIG_MANDATORY_FILE_LOCKING is not
+	  * supported - to avoid false negatives, mount the fs first without
+	  * flags and then remount it as MS_MANDLOCK
+	  */

And I've restored this comment as this is one of the places where it
makes sense to explain why we are not mounting the fs with MS_MANDLOCK
in the first place.

 	if (mount(NULL, MNTPOINT, NULL, MS_REMOUNT|MS_MANDLOCK, NULL) == -1) {
 		if (errno == EPERM) {
 			tst_brk(TCONF,
@@ -177,5 +174,6 @@ static struct tst_test test = {
 	.needs_tmpdir = 1,
 	.forks_child = 1,
 	.mount_device = 1,
+	.needs_root = 1,
 	.mntpoint = MNTPOINT,
 };

-- 
Cyril Hrubis
chrubis@suse.cz


More information about the ltp mailing list