diff options
| author | Wayne Davison <wayned@samba.org> | 2004-02-17 23:13:10 +0000 |
|---|---|---|
| committer | Wayne Davison <wayned@samba.org> | 2004-02-17 23:13:10 +0000 |
| commit | 62c9e6b3a54f147629497a2bc791acac60b5668b (patch) | |
| tree | 49fb016adf08930397034eed23308570cd3ff41b /backup.c | |
| parent | cfeed4da95fd8c38eadab32c9d897302e73d5a91 (diff) | |
| download | android_external_rsync-62c9e6b3a54f147629497a2bc791acac60b5668b.tar.gz android_external_rsync-62c9e6b3a54f147629497a2bc791acac60b5668b.tar.bz2 android_external_rsync-62c9e6b3a54f147629497a2bc791acac60b5668b.zip | |
Moved the EXDEV handling into robust_rename().
Diffstat (limited to 'backup.c')
| -rw-r--r-- | backup.c | 40 |
1 files changed, 4 insertions, 36 deletions
@@ -130,42 +130,10 @@ failure: /* robustly move a file, creating new directory structures if necessary */ static int robust_move(char *src, char *dst) { - int keep_trying = 4; - int keep_path_extfs = 0; - int failed; - - while (keep_trying) { - if (keep_path_extfs) { - failed = copy_file(src, dst, 0755); - if (!failed) - do_unlink(src); - } else - failed = robust_rename(src, dst); - - if (failed) { - if (verbose > 2) { - rprintf(FERROR, "robust_move failed: %s(%d)\n", - strerror(errno), errno); - } - switch (errno) { - case EXDEV: /* external filesystem */ - keep_path_extfs = 1; - keep_trying--; - break; - case ENOENT: /* no directory to write to */ - if (make_bak_dir(dst) < 0) - keep_trying = 0; - else - keep_trying--; - break; - default: - keep_trying = 0; - break; - } - } else - keep_trying = 0; - } - return !failed; + if (robust_rename(src, dst, 0755) != 0 || errno != ENOENT + || make_bak_dir(dst) < 0 || robust_rename(src, dst, 0755) != 0) + return -1; + return 0; } |
