[LTP] [PATCH] SAFE_MOUNT: print debug info about mounting operation
Li Wang
liwang@redhat.com
Mon Jun 5 08:30:00 CEST 2023
Hi Murphy,
This is helpful for knowing the mount info.
But as SAFE_MOUNT is not only used for relative path but
mount absolute path, so we'd better determine what the '*target'
path type.
How about changing to below:
if (target[0] == '/') {
strncpy(mpath, target, PATH_MAX-1);
mpath[PATH_MAX-1] = '\0';
} else {
.... your relative path code ...
}
tst_resm_(file, lineno, TINFO,
"Mounting %s to %s fstyp=%s flags=%x",
source, mpath, filesystemtype, mountflags);
On Sun, Jun 4, 2023 at 5:51 PM Murphy Zhou <jencce.kernel@gmail.com> wrote:
> Signed-off-by: Murphy Zhou <jencce.kernel@gmail.com>
> ---
> lib/safe_macros.c | 17 +++++++++++++++++
> 1 file changed, 17 insertions(+)
>
> diff --git a/lib/safe_macros.c b/lib/safe_macros.c
> index af6dd0716..a66285a0e 100644
> --- a/lib/safe_macros.c
> +++ b/lib/safe_macros.c
> @@ -898,7 +898,24 @@ int safe_mount(const char *file, const int lineno,
> void (*cleanup_fn)(void),
> const void *data)
> {
> int rval = -1;
> + char cdir[PATH_MAX], mpath[PATH_MAX];
>
> + if (!getcwd(cdir, PATH_MAX)) {
> + tst_resm(TWARN | TERRNO, "Failed to find current
> directory");
> + return 0;
> + }
> +
> + rval = snprintf(mpath, PATH_MAX, "%s/%s", cdir, target);
> + if (rval < 0 || rval >= PATH_MAX) {
> + tst_resm(TWARN | TERRNO,
> + "snprintf() should have returned %d instead of
> %d",
> + PATH_MAX, rval);
> + return 0;
> + }
> +
+ tst_resm_(file, lineno, TINFO,
> + "Mounting %s to %s fstyp=%s flags=%x",
> + source, mpath, filesystemtype, mountflags);
> /*
> * Don't try using the kernel's NTFS driver when mounting NTFS,
> since
> * the kernel's NTFS driver doesn't have proper write support.
> --
> 2.31.1
>
>
> --
> Mailing list info: https://lists.linux.it/listinfo/ltp
>
>
--
Regards,
Li Wang
More information about the ltp
mailing list