diff options
| author | Martin Pool <mbp@samba.org> | 2002-03-25 03:29:47 +0000 |
|---|---|---|
| committer | Martin Pool <mbp@samba.org> | 2002-03-25 03:29:47 +0000 |
| commit | bf4e725d5d3c0a06c9a8d74cb9b1c183e161f148 (patch) | |
| tree | f56d357c4aa7e6aa0e28b7d93dd760444b33d168 /syscall.c | |
| parent | 663717f465a82e1955508b4e40dfdee8789a03cb (diff) | |
| download | android_external_rsync-bf4e725d5d3c0a06c9a8d74cb9b1c183e161f148.tar.gz android_external_rsync-bf4e725d5d3c0a06c9a8d74cb9b1c183e161f148.tar.bz2 android_external_rsync-bf4e725d5d3c0a06c9a8d74cb9b1c183e161f148.zip | |
Code that was meant to trim trailing slashes from mkdir() paths
actually did not; fix it.
Diffstat (limited to 'syscall.c')
| -rw-r--r-- | syscall.c | 24 |
1 files changed, 16 insertions, 8 deletions
@@ -111,19 +111,27 @@ int do_rename(char *fname1, char *fname2) } +void trim_trailing_slashes(char *name) +{ + char *p; + /* 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 (!*name) + return; /* empty string */ + p = strchr(name, '\0') - 1; + while (p == '/') { + p-- = '\0'; + } +} + + int do_mkdir(char *fname, mode_t mode) { - 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] = '/'; - + trim_trailing_slashes(fname); return mkdir(fname, mode); } |
