From: Greg Kurz <groug@kaod.org>
To: Jan Dakinevich <jan.dakinevich@gmail.com>
Cc: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH] 9pfs: fix readdir() for 9p2000.u
Date: Tue, 19 Sep 2017 00:26:59 +0200 [thread overview]
Message-ID: <20170919002659.3cd0004a@bahia.lan> (raw)
In-Reply-To: <1505767397-20462-1-git-send-email-jan.dakinevich@gmail.com>
On Mon, 18 Sep 2017 23:43:17 +0300
Jan Dakinevich <jan.dakinevich@gmail.com> wrote:
> ---
> Greg,
>
> What do you think about this way?
I couldn't reproduce the issue with the symbolic link... can you
provide your QEMU command line and the mount options of the 9p
filesystem ?
Anyway, I had the very same patch in mind because only v9fs_stat() needs the
basename actually and it shouldn't be open-coded in stat_to_v9stat().
Please resend with proper changelog and Signed-off-by and I'll gladly
take it.
Cheers,
--
Greg
> ---
> hw/9pfs/9p.c | 18 +++++++-----------
> 1 file changed, 7 insertions(+), 11 deletions(-)
>
> diff --git a/hw/9pfs/9p.c b/hw/9pfs/9p.c
> index d152f5c..4697c00 100644
> --- a/hw/9pfs/9p.c
> +++ b/hw/9pfs/9p.c
> @@ -826,11 +826,11 @@ static uint32_t stat_to_v9mode(const struct stat *stbuf)
> }
>
> static int coroutine_fn stat_to_v9stat(V9fsPDU *pdu, V9fsPath *name,
> + const char *basename,
> const struct stat *stbuf,
> V9fsStat *v9stat)
> {
> int err;
> - const char *str;
>
> memset(v9stat, 0, sizeof(*v9stat));
>
> @@ -864,14 +864,7 @@ static int coroutine_fn stat_to_v9stat(V9fsPDU *pdu, V9fsPath *name,
> "HARDLINKCOUNT", (unsigned long)stbuf->st_nlink);
> }
>
> - str = strrchr(name->data, '/');
> - if (str) {
> - str += 1;
> - } else {
> - str = name->data;
> - }
> -
> - v9fs_string_sprintf(&v9stat->name, "%s", str);
> + v9fs_string_sprintf(&v9stat->name, "%s", basename);
>
> v9stat->size = 61 +
> v9fs_string_size(&v9stat->name) +
> @@ -1080,6 +1073,7 @@ static void coroutine_fn v9fs_stat(void *opaque)
> struct stat stbuf;
> V9fsFidState *fidp;
> V9fsPDU *pdu = opaque;
> + char *basename;
>
> err = pdu_unmarshal(pdu, offset, "d", &fid);
> if (err < 0) {
> @@ -1096,7 +1090,9 @@ static void coroutine_fn v9fs_stat(void *opaque)
> if (err < 0) {
> goto out;
> }
> - err = stat_to_v9stat(pdu, &fidp->path, &stbuf, &v9stat);
> + basename = g_path_get_basename(fidp->path.data);
> + err = stat_to_v9stat(pdu, &fidp->path, basename, &stbuf, &v9stat);
> + g_free(basename);
> if (err < 0) {
> goto out;
> }
> @@ -1772,7 +1768,7 @@ static int coroutine_fn v9fs_do_readdir_with_stat(V9fsPDU *pdu,
> if (err < 0) {
> break;
> }
> - err = stat_to_v9stat(pdu, &path, &stbuf, &v9stat);
> + err = stat_to_v9stat(pdu, &path, dent->d_name, &stbuf, &v9stat);
> if (err < 0) {
> break;
> }
--
Gregory Kurz kurzgreg@fr.ibm.com
gkurz@linux.vnet.ibm.com
Software Engineer @ IBM/LTC http://www.ibm.com
Tel 33-5-6218-1607
"Anarchy is about taking complete responsibility for yourself."
Alan Moore.
next prev parent reply other threads:[~2017-09-18 22:27 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-09-18 15:46 [Qemu-devel] [PATCH] 9pfs: fix readdir() for 9p2000.u Greg Kurz
2017-09-18 16:34 ` Jan Dakinevich
[not found] ` <1505767397-20462-1-git-send-email-jan.dakinevich@gmail.com>
2017-09-18 22:26 ` Greg Kurz [this message]
2017-09-19 14:28 ` Jan Dakinevich
2017-09-19 17:46 ` Greg Kurz
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=20170919002659.3cd0004a@bahia.lan \
--to=groug@kaod.org \
--cc=jan.dakinevich@gmail.com \
--cc=qemu-devel@nongnu.org \
/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;
as well as URLs for NNTP newsgroup(s).