aboutsummaryrefslogtreecommitdiffstats
path: root/backup.c
diff options
context:
space:
mode:
authorWayne Davison <wayned@samba.org>2005-06-10 17:57:18 +0000
committerWayne Davison <wayned@samba.org>2005-06-10 17:57:18 +0000
commit93e28fbd992a3e54e71e1c619309727fb71756d8 (patch)
tree70f589ba06c55a3551bff964f70b47caaa340e10 /backup.c
parent87a57a3072c0fe742b154bd62869cc08c65625bb (diff)
downloadandroid_external_rsync-93e28fbd992a3e54e71e1c619309727fb71756d8.tar.gz
android_external_rsync-93e28fbd992a3e54e71e1c619309727fb71756d8.tar.bz2
android_external_rsync-93e28fbd992a3e54e71e1c619309727fb71756d8.zip
Fixed a problem in the backing up of symlinks and devices: we
need to remove any old symlink/device/file to create the backup. Also fixed a couple minor logic errors in the handling of symlinks and devices. NOTE: the code still doesn't handle the changing of a name from a dir to a non-dir or visa versa (which is a very old deficiency in the code).
Diffstat (limited to 'backup.c')
-rw-r--r--backup.c41
1 files changed, 21 insertions, 20 deletions
diff --git a/backup.c b/backup.c
index 00e3e96d..7d288858 100644
--- a/backup.c
+++ b/backup.c
@@ -188,18 +188,16 @@ static int keep_backup(char *fname)
return 0;
/* Check to see if this is a device file, or link */
- if (IS_DEVICE(file->mode)) {
- if (am_root && preserve_devices) {
- if (do_mknod(buf, file->mode, file->u.rdev) < 0
- && (errno != ENOENT || make_bak_dir(buf) < 0
- || do_mknod(buf, file->mode, file->u.rdev) < 0)) {
- rsyserr(FERROR, errno, "mknod %s failed",
- full_fname(buf));
- } else if (verbose > 2) {
- rprintf(FINFO,
- "make_backup: DEVICE %s successful.\n",
- safe_fname(fname));
- }
+ if (IS_DEVICE(file->mode) && am_root && preserve_devices) {
+ do_unlink(buf);
+ if (do_mknod(buf, file->mode, file->u.rdev) < 0
+ && (errno != ENOENT || make_bak_dir(buf) < 0
+ || do_mknod(buf, file->mode, file->u.rdev) < 0)) {
+ rsyserr(FERROR, errno, "mknod %s failed",
+ full_fname(buf));
+ } else if (verbose > 2) {
+ rprintf(FINFO, "make_backup: DEVICE %s successful.\n",
+ safe_fname(fname));
}
kept = 1;
do_unlink(fname);
@@ -230,15 +228,18 @@ static int keep_backup(char *fname)
full_fname(buf), file->u.link);
}
kept = 1;
+ } else {
+ do_unlink(buf);
+ if (do_symlink(file->u.link, buf) < 0
+ && (errno != ENOENT || make_bak_dir(buf) < 0
+ || do_symlink(file->u.link, buf) < 0)) {
+ rsyserr(FERROR, errno, "link %s -> \"%s\"",
+ full_fname(buf),
+ safe_fname(file->u.link));
+ }
+ do_unlink(fname);
+ kept = 1;
}
- if (do_symlink(file->u.link, buf) < 0
- && (errno != ENOENT || make_bak_dir(buf) < 0
- || do_symlink(file->u.link, buf) < 0)) {
- rsyserr(FERROR, errno, "link %s -> \"%s\"",
- full_fname(buf), safe_fname(file->u.link));
- }
- do_unlink(fname);
- kept = 1;
}
#endif