Copying ".."
Wayne Davison
wayned at samba.org
Fri May 13 22:27:00 GMT 2005
I just noticed that copying ".." with rsync copies the directory by
name, resulting in the destination files being written out one directory
higher than expected. For instance,
rsync -av .. /var/tmp/save-dir/
That would copy everything from the parent dir into /var/tmp, not
/var/tmp/save-dir. Ouch.
I don't think that anyone depends on this anti-intuitive behavior,
right? Attached is a patch that makes the above command behave as
if "../" had been specified for the source.
..wayne..
-------------- next part --------------
--- flist.c 13 May 2005 22:02:24 -0000 1.293
+++ flist.c 13 May 2005 22:17:04 -0000
@@ -1127,6 +1127,14 @@ struct file_list *send_file_list(int f,
fname[l] = '\0';
}
is_dot_dir = 1;
+ } else if (l > 1 && fname[l-1] == '.' && fname[l-2] == '.'
+ && (l == 2 || fname[l-3] == '/')) {
+ if (l + 2 >= MAXPATHLEN)
+ overflow("send_file_list");
+ fname[l++] = '/';
+ fname[l++] = '.';
+ fname[l] = '\0';
+ is_dot_dir = 1;
} else {
is_dot_dir = fname[l-1] == '.'
&& (l == 1 || fname[l-2] == '/');
More information about the rsync
mailing list