[PATCH] Don't strip two leading slashes from paths.
David Rothenberger
daveroth at acm.org
Sat Nov 15 21:09:20 GMT 2008
rsync 3.0.4 will transform a path like '//machine/share/dir' to
'/machine/share/dir' when the --protect flag is provided. This causes a
problem with Cygwin, where the two leading slashes are meaningful
(access of a remote Windows share).
[[[
% rsync -s localhost://tela/downloads
rsync: link_stat "/tela/downloads" failed: No such file or directory (2)
rsync error: some files/attrs were not transferred (see previous errors)
(code 23) at
/home/lapo/packaging/rsync-3.0.4-1/src/rsync-3.0.4/main.c(1506)
[receiver=3.0.4]
]]]
http://www.opengroup.org/onlinepubs/000095399/basedefs/xbd_chap04.html#tag_04_11
mentions that "[a] pathname that begins with two successive slashes may
be interpreted in an implementation-defined manner, although more than
two leading slashes shall be treated as a single slash."
The attached patch prevents two leading slashes from being converted to
one and works fine for me with Cygwin:
[[[
% rsync -s localhost://tela/downloads
drwxr-xr-x 0 2008/01/14 09:46:23 downloads
]]]
Unfortunately, it doesn't fully conform to the POSIX specification
because it also translates '///' to '//' instead of '/' as required.
Does this patch (or a modified version that conforms to POSIX) stand a
chance of being accepted? Should I create a bugzilla issue and attach it
there? Should I work on modifying the patch to conform to POSIX?
--
David Rothenberger ---- daveroth at acm.org
-------------- next part --------------
Index: util.c
===================================================================
--- util.c.orig
+++ util.c
@@ -821,8 +821,12 @@ unsigned int clean_fname(char *name, int
if (!name)
return 0;
- if ((anchored = *f == '/') != 0)
+ if ((anchored = *f == '/') != 0) {
*t++ = *f++;
+ /* keep "//" */
+ if (*f == '/')
+ *t++ = *f++;
+ }
else if (flags & CFN_KEEP_DOT_DIRS && *f == '.' && f[1] == '/') {
*t++ = *f++;
*t++ = *f++;
More information about the rsync
mailing list