All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] Fix bug with virtio-9p rename
@ 2011-04-27 18:30 Sassan Panahinejad
  2011-04-28 11:11 ` Sassan Panahinejad
  0 siblings, 1 reply; 2+ messages in thread
From: Sassan Panahinejad @ 2011-04-27 18:30 UTC (permalink / raw)
  To: qemu-devel; +Cc: Sassan Panahinejad

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 <sassan@sassan.me.uk>
---
 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)
                     */
                     continue;
                 }
+                /*
+                * 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,
                                   strlen(vs->fidp->path.data));
-- 
1.7.0.4

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

* Re: [Qemu-devel] [PATCH] Fix bug with virtio-9p rename
  2011-04-27 18:30 [Qemu-devel] [PATCH] Fix bug with virtio-9p rename Sassan Panahinejad
@ 2011-04-28 11:11 ` Sassan Panahinejad
  0 siblings, 0 replies; 2+ messages in thread
From: Sassan Panahinejad @ 2011-04-28 11:11 UTC (permalink / raw)
  To: qemu-devel; +Cc: Sassan Panahinejad

[-- Attachment #1: Type: text/plain, Size: 1973 bytes --]

Malahal Naineni's patch "Stop renaming files with similar name!" (posted
since this one) also fixes this bug.
I don't mind which one gets merged, as long as the bug gets fixed ;)

Sassan


On 27 April 2011 19:30, Sassan Panahinejad <sassan@sassan.me.uk> wrote:

> 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 <sassan@sassan.me.uk>
> ---
>  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)
>                     */
>                     continue;
>                 }
> +                /*
> +                * 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,
>                                   strlen(vs->fidp->path.data));
> --
> 1.7.0.4
>
>

[-- Attachment #2: Type: text/html, Size: 2524 bytes --]

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

end of thread, other threads:[~2011-04-28 11:11 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-04-27 18:30 [Qemu-devel] [PATCH] Fix bug with virtio-9p rename Sassan Panahinejad
2011-04-28 11:11 ` Sassan Panahinejad

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.