From: Li Wang via ltp <ltp@lists.linux.it>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH v2 2/2] mount: check path exists before tst_is_mounted in cleanup
Date: Fri, 22 Aug 2025 15:48:11 +0800 [thread overview]
Message-ID: <20250822074811.2192404-1-liwang@redhat.com> (raw)
In-Reply-To: <CAEemH2fM4vHRdgHh62krquK5CFuHvpKdJtj--S6Vvt_i0xRBFw@mail.gmail.com>
tst_is_mounted() now internally resolves the mount path via realpath(),
which will fail if the path does not exist. In sometest (e.g. mount05),
MNTPOINT2 may not exist yet during cleanup, calling tst_is_mounted()
directly could produce misleading warnings or errors.
Add an explicit access(PATH, F_OK) check before calling tst_is_mounted()
in the cleanup, ensuring we only query mounts for existing paths.
Signed-off-by: Li Wang <liwang@redhat.com>
---
Notes:
v1 --> v2:
patch 1/2, keep no change, do not send v2.
patch 2/2, adding two more files for path exist check
testcases/kernel/containers/mqns/mqns_03.c | 2 +-
testcases/kernel/containers/mqns/mqns_04.c | 2 +-
testcases/kernel/syscalls/mount/mount05.c | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/testcases/kernel/containers/mqns/mqns_03.c b/testcases/kernel/containers/mqns/mqns_03.c
index 4d3bfc52f..ac8311559 100644
--- a/testcases/kernel/containers/mqns/mqns_03.c
+++ b/testcases/kernel/containers/mqns/mqns_03.c
@@ -130,7 +130,7 @@ static void cleanup(void)
if (!access(MQUEUE2, F_OK))
SAFE_MQ_UNLINK(MQNAME2);
- if (tst_is_mounted(DEVDIR))
+ if (!access(DEVDIR, F_OK) && tst_is_mounted(DEVDIR))
SAFE_UMOUNT(DEVDIR);
}
diff --git a/testcases/kernel/containers/mqns/mqns_04.c b/testcases/kernel/containers/mqns/mqns_04.c
index d28c330c4..790607ecd 100644
--- a/testcases/kernel/containers/mqns/mqns_04.c
+++ b/testcases/kernel/containers/mqns/mqns_04.c
@@ -123,7 +123,7 @@ static void cleanup(void)
if (!access(MQUEUE2, F_OK))
SAFE_MQ_UNLINK(MQNAME2);
- if (tst_is_mounted(DEVDIR))
+ if (!access(DEVDIR, F_OK) && tst_is_mounted(DEVDIR))
SAFE_UMOUNT(DEVDIR);
}
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
--
Mailing list info: https://lists.linux.it/listinfo/ltp
next prev parent reply other threads:[~2025-08-22 7:48 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-22 7:22 [LTP] [PATCH 1/2] tst_device: refine tst_is_mounted() Li Wang via ltp
2025-08-22 7:22 ` [LTP] [PATCH 2/2] mount05: check if mount path exist before tst_is_mounted Li Wang via ltp
2025-08-22 7:28 ` Li Wang via ltp
2025-08-22 7:48 ` Li Wang via ltp [this message]
2025-08-22 8:02 ` [LTP] [PATCH v2 2/2] mount: check path exists before tst_is_mounted in cleanup Wei Gao via ltp
2025-08-22 8:12 ` Li Wang via ltp
2025-08-22 8:32 ` Wei Gao via ltp
2025-08-22 7:45 ` [LTP] [PATCH 1/2] tst_device: refine tst_is_mounted() Wei Gao via ltp
2025-08-26 1:16 ` Li Wang via ltp
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250822074811.2192404-1-liwang@redhat.com \
--to=ltp@lists.linux.it \
--cc=liwang@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox