From: Martin Doucha <mdoucha@suse.cz>
To: Murphy Zhou <jencce.kernel@gmail.com>, ltp@lists.linux.it
Subject: Re: [LTP] [PATCH] SAFE_MOUNT: print debug info about mounting operation
Date: Mon, 5 Jun 2023 10:39:48 +0200 [thread overview]
Message-ID: <233a0f31-e4de-de65-4752-d43cb1ae3c1f@suse.cz> (raw)
In-Reply-To: <20230604095117.3543342-1-jencce.kernel@gmail.com>
Hi,
On 04. 06. 23 11:51, Murphy Zhou 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;
You return success when nothing was mounted. That is clearly wrong.
Either call tst_brkm_(... TBROK ...) if the failure is so serious that
the test cannot continue, or don't return at all.
> + }
> +
> + rval = snprintf(mpath, PATH_MAX, "%s/%s", cdir, target);
The C library has a function for resolving paths: realpath(). Please use
that.
> + if (rval < 0 || rval >= PATH_MAX) {
> + tst_resm(TWARN | TERRNO,
> + "snprintf() should have returned %d instead of %d",
> + PATH_MAX, rval);
> + return 0;
Returning here is also wrong.
> + }
> +
> + 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.
--
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
next prev parent reply other threads:[~2023-06-05 8:40 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-04 9:51 [LTP] [PATCH] SAFE_MOUNT: print debug info about mounting operation Murphy Zhou
2023-06-05 6:30 ` Li Wang
2023-06-05 8:39 ` Martin Doucha [this message]
2023-06-05 9:56 ` Li Wang
2023-06-06 7:08 ` Murphy Zhou
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=233a0f31-e4de-de65-4752-d43cb1ae3c1f@suse.cz \
--to=mdoucha@suse.cz \
--cc=jencce.kernel@gmail.com \
--cc=ltp@lists.linux.it \
/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