[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH] 9p: getattr: use fstat if we have a fd

From: Greg Kurz
Subject: [Qemu-devel] [PATCH] 9p: getattr: use fstat if we have a fd
Date: Wed, 25 May 2016 16:18:35 +0200
User-agent: StGit/0.17.1-dirty

If we have an opened fd, it is better to call fstat() as the underlying
file may have been unlinked and lstat() will fail.

Signed-off-by: Greg Kurz <address@hidden>

This QEMU patch goes with the create-unlink-getattr fix at:


I could verify that a basic program doing open(O_CREAT)+unlink()+fstat() in
the guest works as expected.

Eric (or other v9fs maintainers),

Is there a chance the above kernel patch gets pushed upstream in a near
future ?



 hw/9pfs/9p.c |    6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/hw/9pfs/9p.c b/hw/9pfs/9p.c
index 482a35ead51b..572aaf09930b 100644
--- a/hw/9pfs/9p.c
+++ b/hw/9pfs/9p.c
@@ -1103,7 +1103,11 @@ static void v9fs_getattr(void *opaque)
      * Currently we only support BASIC fields in stat, so there is no
      * need to look at request_mask.
-    retval = v9fs_co_lstat(pdu, &fidp->path, &stbuf);
+    if (fidp->fs.fd > 0) {
+        retval = v9fs_co_fstat(pdu, fidp, &stbuf);
+    } else {
+        retval = v9fs_co_lstat(pdu, &fidp->path, &stbuf);
+    }
     if (retval < 0) {
         goto out;

reply via email to

[Prev in Thread] Current Thread [Next in Thread]