Added a couple missing NEWS items.
[rsync/rsync.git] / syscall.c
index f7ce3f0..b198dbf 100644 (file)
--- a/syscall.c
+++ b/syscall.c
@@ -111,19 +111,31 @@ int do_rename(char *fname1, char *fname2)
 }
 
 
-int do_mkdir(char *fname, mode_t mode)
+void trim_trailing_slashes(char *name)
 {
        int l;
-       if (dry_run)
-               return 0;
-       CHECK_RO;
-       
        /* Some BSD systems cannot make a directory if the name
         * contains a trailing slash.
         * <http://www.opensource.apple.com/bugs/X/BSD%20Kernel/2734739.html> */
-       if ((l = strlen(fname))  &&  (fname[l-1] == '/'))
-               fname[l-1] = '/';
        
+       /* Don't change empty string; and also we can't improve on
+        * "/" */
+       
+       l = strlen(name);
+       while (l > 1) {
+               if (name[--l] != '/')
+                       break;
+               name[l] = '\0';
+       }
+}
+
+
+int do_mkdir(char *fname, mode_t mode)
+{
+       if (dry_run)
+               return 0;
+       CHECK_RO;
+       trim_trailing_slashes(fname);   
        return mkdir(fname, mode);
 }