[LTP] [PATCH 2/2] mount05: check if mount path exist before tst_is_mounted

Li Wang liwang@redhat.com
Fri Aug 22 09:22:04 CEST 2025


tst_is_mounted() now internally resolves the mount path via realpath(),
which will fail if the path does not exist. In mount05, MNTPOINT2 may
not always be created during the test flow, so calling tst_is_mounted()
directly could produce misleading warnings or errors.

Add an explicit access(MNTPOINT2, F_OK) check before calling
tst_is_mounted(), ensuring we only query mounts for existing paths.

Signed-off-by: Li Wang <liwang@redhat.com>
---
 testcases/kernel/syscalls/mount/mount05.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/testcases/kernel/syscalls/mount/mount05.c b/testcases/kernel/syscalls/mount/mount05.c
index 66e102a32..5585e230e 100644
--- a/testcases/kernel/syscalls/mount/mount05.c
+++ b/testcases/kernel/syscalls/mount/mount05.c
@@ -35,7 +35,7 @@ static void cleanup(void)
 	if (tst_is_mounted(MNTPOINT1))
 		SAFE_UMOUNT(MNTPOINT1);
 
-	if (tst_is_mounted(MNTPOINT2))
+	if (!access(MNTPOINT2, F_OK) && tst_is_mounted(MNTPOINT2))
 		SAFE_UMOUNT(MNTPOINT2);
 }
 
-- 
2.49.0



More information about the ltp mailing list