From nobody Mon Apr 29 00:07:23 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1505749651030724.1650930416379; Mon, 18 Sep 2017 08:47:31 -0700 (PDT) Received: from localhost ([::1]:37407 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dtyGf-00019i-VE for importer@patchew.org; Mon, 18 Sep 2017 11:47:29 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58491) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dtyFp-0000YL-5n for qemu-devel@nongnu.org; Mon, 18 Sep 2017 11:46:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dtyFl-000899-T9 for qemu-devel@nongnu.org; Mon, 18 Sep 2017 11:46:37 -0400 Received: from 9.mo68.mail-out.ovh.net ([46.105.78.111]:55717) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dtyFl-000842-NO for qemu-devel@nongnu.org; Mon, 18 Sep 2017 11:46:33 -0400 Received: from player711.ha.ovh.net (b9.ovh.net [213.186.33.59]) by mo68.mail-out.ovh.net (Postfix) with ESMTP id 274D67E578 for ; Mon, 18 Sep 2017 17:46:26 +0200 (CEST) Received: from bahia.lan (gar31-1-82-66-74-139.fbx.proxad.net [82.66.74.139]) (Authenticated sender: groug@kaod.org) by player711.ha.ovh.net (Postfix) with ESMTPA id A15BE38008D; Mon, 18 Sep 2017 17:46:24 +0200 (CEST) From: Greg Kurz To: qemu-devel@nongnu.org Date: Mon, 18 Sep 2017 17:46:18 +0200 Message-ID: <150574930075.27635.3945832472060840946.stgit@bahia> User-Agent: StGit/0.17.1-46-g6855-dirty MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Ovh-Tracer-Id: 16884276481426889108 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrfeelledrheehgdefgecutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfqggfjpdevjffgvefmvefgnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 46.105.78.111 Subject: [Qemu-devel] [PATCH] 9pfs: fix readdir() for 9p2000.u X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jan Dakinevich Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 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 --- 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(V9f= sPDU *pdu, if (err < 0) { break; } + v9fs_path_free(&path); + + v9fs_path_sprintf(&path, "%s", dent->d_name); err =3D stat_to_v9stat(pdu, &path, &stbuf, &v9stat); if (err < 0) { break;