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

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


On Fri, Aug 22, 2025 at 3:24 PM Li Wang via ltp <ltp@lists.linux.it> wrote:

> 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()
>

This line was forgotten to amend in my git log:

"In mount05, MNTPOINT2 may not exist yet during cleanup. "

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
>
>
> --
> Mailing list info: https://lists.linux.it/listinfo/ltp
>
>

-- 
Regards,
Li Wang


More information about the ltp mailing list