aboutsummaryrefslogtreecommitdiffstats
path: root/util.c
diff options
context:
space:
mode:
authorWayne Davison <wayned@samba.org>2006-01-30 07:18:16 +0000
committerWayne Davison <wayned@samba.org>2006-01-30 07:18:16 +0000
commit3ed8eafccb0f8880be295e67486347e5ffd93320 (patch)
tree07a8cda60f2a8ff79baccce2144b8752657c7039 /util.c
parentd8b1c923efd14d320f90884901b795f141aa6464 (diff)
downloadandroid_external_rsync-3ed8eafccb0f8880be295e67486347e5ffd93320.tar.gz
android_external_rsync-3ed8eafccb0f8880be295e67486347e5ffd93320.tar.bz2
android_external_rsync-3ed8eafccb0f8880be295e67486347e5ffd93320.zip
The robust_rename() function now takes a "partialptr" arg that, if
non-NULL, will be used if we are forced to copy the file.
Diffstat (limited to 'util.c')
-rw-r--r--util.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/util.c b/util.c
index 3d88b15c..d37ab61e 100644
--- a/util.c
+++ b/util.c
@@ -377,8 +377,11 @@ int robust_unlink(const char *fname)
}
/* Returns 0 on successful rename, 1 if we successfully copied the file
- * across filesystems, -2 if copy_file() failed, and -1 on other errors. */
-int robust_rename(const char *from, const char *to, int mode)
+ * across filesystems, -2 if copy_file() failed, and -1 on other errors.
+ * If partialptr is not NULL and we need to do a copy, copy the file into
+ * the active partial-dir instead of over the destination file. */
+int robust_rename(char *from, char *to, char *partialptr,
+ int mode)
{
int tries = 4;
@@ -394,6 +397,11 @@ int robust_rename(const char *from, const char *to, int mode)
break;
#endif
case EXDEV:
+ if (partialptr) {
+ if (!handle_partial_dir(partialptr,PDIR_CREATE))
+ return -1;
+ to = partialptr;
+ }
if (copy_file(from, to, mode) != 0)
return -2;
do_unlink(from);