From: Wayne Davison Date: Sat, 2 Aug 2008 01:04:24 +0000 (-0700) Subject: Fixed a couple minor problems in util.c: X-Git-Url: https://mattmccutchen.net/rsync/rsync.git/commitdiff_plain/0479eb76015913a40a2d0423bdd6cfeec4a3a3e3 Fixed a couple minor problems in util.c: - Make sure that handle_partial_dir() never returns a truncated fname. - Make robust_rename() return that it failed to do a cross-device copy if the partial-dir could not be created. --- diff --git a/util.c b/util.c index 0af7259c..4b6c11fd 100644 --- a/util.c +++ b/util.c @@ -436,7 +436,7 @@ int robust_rename(const char *from, const char *to, const char *partialptr, case EXDEV: if (partialptr) { if (!handle_partial_dir(partialptr,PDIR_CREATE)) - return -1; + return -2; to = partialptr; } if (copy_file(from, to, -1, mode, 0) != 0) @@ -1111,12 +1111,16 @@ int handle_partial_dir(const char *fname, int create) STRUCT_STAT st; int statret = do_lstat(dir, &st); if (statret == 0 && !S_ISDIR(st.st_mode)) { - if (do_unlink(dir) < 0) + if (do_unlink(dir) < 0) { + *fn = '/'; return 0; + } statret = -1; } - if (statret < 0 && do_mkdir(dir, 0700) < 0) + if (statret < 0 && do_mkdir(dir, 0700) < 0) { + *fn = '/'; return 0; + } } else do_rmdir(dir); *fn = '/';