* [LTP] [PATCH v2] safe_mount: safe_umount: print debug info about the operation
@ 2023-06-07 12:36 Murphy Zhou
2023-06-08 6:06 ` Li Wang
2023-06-08 15:49 ` Martin Doucha
0 siblings, 2 replies; 3+ messages in thread
From: Murphy Zhou @ 2023-06-07 12:36 UTC (permalink / raw)
To: ltp
Make the source and the target to mount/umount visible. It's
good for debugging.
Signed-off-by: Murphy Zhou <jencce.kernel@gmail.com>
---
lib/safe_macros.c | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/lib/safe_macros.c b/lib/safe_macros.c
index af6dd0716..6add92f06 100644
--- a/lib/safe_macros.c
+++ b/lib/safe_macros.c
@@ -898,7 +898,15 @@ int safe_mount(const char *file, const int lineno, void (*cleanup_fn)(void),
const void *data)
{
int rval = -1;
+ char mpath[PATH_MAX];
+ if (!realpath(target, mpath))
+ tst_brkm_(file, lineno, TBROK | TERRNO, cleanup_fn,
+ "realpath(%s, s) failed", target);
+
+ tst_resm_(file, lineno, TINFO,
+ "Mounting %s to %s fstyp=%s flags=%lx",
+ 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.
@@ -948,6 +956,13 @@ int safe_umount(const char *file, const int lineno, void (*cleanup_fn)(void),
const char *target)
{
int rval;
+ char mpath[PATH_MAX];
+
+ if (!realpath(target, mpath))
+ tst_brkm_(file, lineno, TBROK | TERRNO, cleanup_fn,
+ "realpath(%s, s) failed", target);
+
+ tst_resm_(file, lineno, TINFO, "Umounting %s", mpath);
rval = tst_umount(target);
--
2.31.1
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [LTP] [PATCH v2] safe_mount: safe_umount: print debug info about the operation
2023-06-07 12:36 [LTP] [PATCH v2] safe_mount: safe_umount: print debug info about the operation Murphy Zhou
@ 2023-06-08 6:06 ` Li Wang
2023-06-08 15:49 ` Martin Doucha
1 sibling, 0 replies; 3+ messages in thread
From: Li Wang @ 2023-06-08 6:06 UTC (permalink / raw)
To: Murphy Zhou; +Cc: ltp
On Wed, Jun 7, 2023 at 8:37 PM Murphy Zhou <jencce.kernel@gmail.com> wrote:
> Make the source and the target to mount/umount visible. It's
> good for debugging.
>
> Signed-off-by: Murphy Zhou <jencce.kernel@gmail.com>
> ---
> lib/safe_macros.c | 15 +++++++++++++++
> 1 file changed, 15 insertions(+)
>
> diff --git a/lib/safe_macros.c b/lib/safe_macros.c
> index af6dd0716..6add92f06 100644
> --- a/lib/safe_macros.c
> +++ b/lib/safe_macros.c
> @@ -898,7 +898,15 @@ int safe_mount(const char *file, const int lineno,
> void (*cleanup_fn)(void),
> const void *data)
> {
> int rval = -1;
> + char mpath[PATH_MAX];
>
> + if (!realpath(target, mpath))
> + tst_brkm_(file, lineno, TBROK | TERRNO, cleanup_fn,
> + "realpath(%s, s) failed", target);
>
Shouldn't this be like:
"realpath(%s, %s) failed", target, mpath);
Otherwise, LGTM.
Reviewed-by: Li Wang <liwang@redhat.com>
> +
> + tst_resm_(file, lineno, TINFO,
> + "Mounting %s to %s fstyp=%s flags=%lx",
> + 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.
> @@ -948,6 +956,13 @@ int safe_umount(const char *file, const int lineno,
> void (*cleanup_fn)(void),
> const char *target)
> {
> int rval;
> + char mpath[PATH_MAX];
> +
> + if (!realpath(target, mpath))
> + tst_brkm_(file, lineno, TBROK | TERRNO, cleanup_fn,
> + "realpath(%s, s) failed", target);
>
and here ^
> +
> + tst_resm_(file, lineno, TINFO, "Umounting %s", mpath);
>
> rval = tst_umount(target);
>
> --
> 2.31.1
>
>
> --
> Mailing list info: https://lists.linux.it/listinfo/ltp
>
>
--
Regards,
Li Wang
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [LTP] [PATCH v2] safe_mount: safe_umount: print debug info about the operation
2023-06-07 12:36 [LTP] [PATCH v2] safe_mount: safe_umount: print debug info about the operation Murphy Zhou
2023-06-08 6:06 ` Li Wang
@ 2023-06-08 15:49 ` Martin Doucha
1 sibling, 0 replies; 3+ messages in thread
From: Martin Doucha @ 2023-06-08 15:49 UTC (permalink / raw)
To: Murphy Zhou, ltp
Hi,
On 07. 06. 23 14:36, Murphy Zhou wrote:
> Make the source and the target to mount/umount visible. It's
> good for debugging.
>
> Signed-off-by: Murphy Zhou <jencce.kernel@gmail.com>
> ---
> lib/safe_macros.c | 15 +++++++++++++++
> 1 file changed, 15 insertions(+)
>
> diff --git a/lib/safe_macros.c b/lib/safe_macros.c
> index af6dd0716..6add92f06 100644
> --- a/lib/safe_macros.c
> +++ b/lib/safe_macros.c
> @@ -898,7 +898,15 @@ int safe_mount(const char *file, const int lineno, void (*cleanup_fn)(void),
> const void *data)
> {
> int rval = -1;
> + char mpath[PATH_MAX];
>
> + if (!realpath(target, mpath))
> + tst_brkm_(file, lineno, TBROK | TERRNO, cleanup_fn,
> + "realpath(%s, s) failed", target);
> +
> + tst_resm_(file, lineno, TINFO,
> + "Mounting %s to %s fstyp=%s flags=%lx",
> + source, mpath, filesystemtype, mountflags);
This is much better, but realpath() failure is not a fatal error here,
just a minor inconvenience. So it'd be better to do this:
if (realpath(...)) {
tst_resm_(... TINFO, "Mounting %s to %s...", ...);
} else {
tst_resm_(... TINFO | TERRNO, "Cannot resolve absolute path to %s", ...);
}
> /*
> * Don't try using the kernel's NTFS driver when mounting NTFS, since
> * the kernel's NTFS driver doesn't have proper write support.
> @@ -948,6 +956,13 @@ int safe_umount(const char *file, const int lineno, void (*cleanup_fn)(void),
> const char *target)
> {
> int rval;
> + char mpath[PATH_MAX];
> +
> + if (!realpath(target, mpath))
> + tst_brkm_(file, lineno, TBROK | TERRNO, cleanup_fn,
> + "realpath(%s, s) failed", target);
> +
> + tst_resm_(file, lineno, TINFO, "Umounting %s", mpath);
Same here.
>
> rval = tst_umount(target);
>
--
Martin Doucha mdoucha@suse.cz
SW Quality Engineer
SUSE LINUX, s.r.o.
CORSO IIa
Krizikova 148/34
186 00 Prague 8
Czech Republic
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-06-08 15:49 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-07 12:36 [LTP] [PATCH v2] safe_mount: safe_umount: print debug info about the operation Murphy Zhou
2023-06-08 6:06 ` Li Wang
2023-06-08 15:49 ` Martin Doucha
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).