* [LTP] [PATCH] syscalls/ftruncate04: TCONF on kernels without MANDLOCK
@ 2016-06-09 13:58 Jiri Jaburek
2016-06-09 14:42 ` Cyril Hrubis
0 siblings, 1 reply; 2+ messages in thread
From: Jiri Jaburek @ 2016-06-09 13:58 UTC (permalink / raw)
To: ltp
Upstream kernel commit
9e8925b67a809bb27ce4b7d352d67f25cf1d7fc5
locks: Allow disabling mandatory locking at compile time
added a config option to remove support for mandatory locking
(mount -o mand, MS_MANDLOCK), which went into v4.5.
Some distributions (like Fedora) already disable it, causing
ftruncate04 to fail:
ftruncate04 1 TBROK : safe_macros.c:728: ftruncate04.c:247:
mount(/dev/loop0, dir/, ext2, 64, (nil)) failed: errno=EPERM(1):
Operation not permitted
As the kernel returns EPERM in this case, there's no easy reliable
way of checking whether MANDLOCK is supported - instead, we perform
"regular" mount, to catch EPERM due to other causes early, and then
remount with MS_MANDLOCK.
If the remount triggers EPERM, the kernel was likely compiled
without CONFIG_MANDATORY_FILE_LOCKING.
Signed-off-by: Jiri Jaburek <jjaburek@redhat.com>
---
testcases/kernel/syscalls/ftruncate/ftruncate04.c | 18 ++++++++++++++++--
1 file changed, 16 insertions(+), 2 deletions(-)
diff --git a/testcases/kernel/syscalls/ftruncate/ftruncate04.c b/testcases/kernel/syscalls/ftruncate/ftruncate04.c
index e75178b..f234f75 100644
--- a/testcases/kernel/syscalls/ftruncate/ftruncate04.c
+++ b/testcases/kernel/syscalls/ftruncate/ftruncate04.c
@@ -240,10 +240,24 @@ static void setup(void)
if (!device)
tst_brkm(TCONF, cleanup, "Failed to obtain block device");
- tst_mkfs(cleanup, device, fs_type, NULL, NULL);
+ /* the 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 */
- SAFE_MOUNT(NULL, device, MOUNT_DIR, fs_type, MS_MANDLOCK, NULL);
+ tst_mkfs(cleanup, device, fs_type, NULL, NULL);
+ SAFE_MOUNT(cleanup, device, MOUNT_DIR, fs_type, 0, NULL);
mount_flag = 1;
+
+ if (mount(NULL, MOUNT_DIR, NULL, MS_REMOUNT|MS_MANDLOCK, NULL) == -1) {
+ if (errno == EPERM) {
+ tst_brkm(TCONF, cleanup, "Mandatory locking (likely) "
+ "not supported by this system");
+ } else {
+ tst_brkm(TBROK, cleanup,
+ "Remount with MS_MANDLOCK failed: %s",
+ strerror(errno));
+ }
+ }
}
static void cleanup(void)
--
2.4.3
^ permalink raw reply related [flat|nested] 2+ messages in thread* [LTP] [PATCH] syscalls/ftruncate04: TCONF on kernels without MANDLOCK
2016-06-09 13:58 [LTP] [PATCH] syscalls/ftruncate04: TCONF on kernels without MANDLOCK Jiri Jaburek
@ 2016-06-09 14:42 ` Cyril Hrubis
0 siblings, 0 replies; 2+ messages in thread
From: Cyril Hrubis @ 2016-06-09 14:42 UTC (permalink / raw)
To: ltp
Hi!
Pushed with following change:
--- a/testcases/kernel/syscalls/ftruncate/ftruncate04.c
+++ b/testcases/kernel/syscalls/ftruncate/ftruncate04.c
@@ -253,9 +253,8 @@ static void setup(void)
tst_brkm(TCONF, cleanup, "Mandatory locking (likely) "
"not supported by this system");
} else {
- tst_brkm(TBROK, cleanup,
- "Remount with MS_MANDLOCK failed: %s",
- strerror(errno));
+ tst_brkm(TBROK | TERRNO, cleanup,
+ "Remount with MS_MANDLOCK failed");
}
}
}
Since in LTP we prefer TERRNO flag over strerror().
Thanks.
--
Cyril Hrubis
chrubis@suse.cz
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2016-06-09 14:42 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-06-09 13:58 [LTP] [PATCH] syscalls/ftruncate04: TCONF on kernels without MANDLOCK Jiri Jaburek
2016-06-09 14:42 ` Cyril Hrubis
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox