qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] 9pfs: fix readdir() for 9p2000.u
@ 2017-09-18 15:46 Greg Kurz
  2017-09-18 16:34 ` Jan Dakinevich
       [not found] ` <1505767397-20462-1-git-send-email-jan.dakinevich@gmail.com>
  0 siblings, 2 replies; 5+ messages in thread
From: Greg Kurz @ 2017-09-18 15:46 UTC (permalink / raw)
  To: qemu-devel; +Cc: Jan Dakinevich

If the client is using 9p2000.u, the following occurs:

$ cd ${virtfs_shared_dir}
$ mkdir -p a/b/c
$ ls a/b
ls: cannot access 'a/b/a': No such file or directory
ls: cannot access 'a/b/b': No such file or directory
a  b  c

instead of the expected:

$ ls a/b
c

This is a regression introduced by commit f57f5878578a;
local_name_to_path() now resolves ".." and "." in paths,
and v9fs_do_readdir_with_stat()->stat_to_v9stat() then
copies the basename of the resulting path to the response.
With the example above, this means that "." and ".." are
turned into "b" and "a" respectively...

Actually, the name we need to pass is the d_name field of
the dirent.

Signed-off-by: Greg Kurz <groug@kaod.org>
---

Hi Jan,

I found this will testing your patches. I'd appreciate if you could
review this. Then I'll push all these patches to 9p-next and send
a pull request.

Thanks,

--
Greg

 hw/9pfs/9p.c |    3 +++
 1 file changed, 3 insertions(+)

diff --git a/hw/9pfs/9p.c b/hw/9pfs/9p.c
index 0a37c8bd1361..0474e9e787c0 100644
--- a/hw/9pfs/9p.c
+++ b/hw/9pfs/9p.c
@@ -1748,6 +1748,9 @@ static int coroutine_fn v9fs_do_readdir_with_stat(V9fsPDU *pdu,
         if (err < 0) {
             break;
         }
+        v9fs_path_free(&path);
+
+        v9fs_path_sprintf(&path, "%s", dent->d_name);
         err = stat_to_v9stat(pdu, &path, &stbuf, &v9stat);
         if (err < 0) {
             break;

^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2017-09-19 17:47 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
2017-09-19 14:28     ` Jan Dakinevich
2017-09-19 17:46       ` Greg Kurz

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