[Top][All Lists]

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

[Qemu-devel] [PATCH] Fix bug with virtio-9p rename

From: Sassan Panahinejad
Subject: [Qemu-devel] [PATCH] Fix bug with virtio-9p rename
Date: Wed, 27 Apr 2011 19:30:46 +0100

After renaming a file, any existing references to the file are updated.
However, in addition to this, it would update any files whos names began with 
that of the file being moved.
Therefore when renaming somefile.txt to somefile.txt-old, any references to 
somefile.txt-new became somefile.txt-old-new.
This breaks debconf and probably many other applications.
This patch fixes the problem. Now only files exactly matching, or files which 
are a subdirectory of a directory being moved are affected.

Signed-off-by: Sassan Panahinejad <address@hidden>
 hw/virtio-9p.c |    9 ++++++++-
 1 files changed, 8 insertions(+), 1 deletions(-)

diff --git a/hw/virtio-9p.c b/hw/virtio-9p.c
index 2530f6d..a2f096d 100644
--- a/hw/virtio-9p.c
+++ b/hw/virtio-9p.c
@@ -2810,8 +2810,15 @@ static int v9fs_complete_rename(V9fsState *s, 
V9fsRenameState *vs)
+                /*
+                * Fix the name if
+                * A: The file is the one we're moving
+                * Or B: The file is a subdirectory of one we're moving
+                */
                 if (!strncmp(vs->fidp->path.data, fidp->path.data,
-                    strlen(vs->fidp->path.data))) {
+                    strlen(vs->fidp->path.data)) &&
+                    (strlen(vs->fidp->path.data) == strlen(fidp->path.data) ||
+                    fidp->path.data[strlen(vs->fidp->path.data)] == '/')) {
                     /* replace the name */
                     v9fs_fix_path(&fidp->path, &vs->name,

reply via email to

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