X-Git-Url: https://mattmccutchen.net/rsync/rsync.git/blobdiff_plain/d62bcc17f303f30d1e3df1051b1390202a21cf9c..ecc81fce17f2e32fbe33c0050693899ce4d6c3cf:/rsync.c diff --git a/rsync.c b/rsync.c index 7af64e7e..e46d0861 100644 --- a/rsync.c +++ b/rsync.c @@ -30,7 +30,11 @@ extern int am_sender; extern int am_generator; extern int preserve_uid; extern int preserve_gid; +extern int force_delete; +extern int recurse; extern int make_backups; +extern char *backup_dir; +extern int inplace; /* @@ -52,10 +56,8 @@ int delete_file(char *fname) DIR *d; struct dirent *di; char buf[MAXPATHLEN]; - extern int force_delete; STRUCT_STAT st; int ret; - extern int recurse; #if SUPPORT_LINKS ret = do_lstat(fname, &st); @@ -96,7 +98,7 @@ int delete_file(char *fname) continue; pathjoin(buf, sizeof buf, fname, dname); if (verbose > 0) - rprintf(FINFO, "deleting %s\n", buf); + rprintf(FINFO, "deleting %s\n", safe_fname(buf)); if (delete_file(buf) != 0) { closedir(d); return -1; @@ -127,10 +129,11 @@ int set_perms(char *fname,struct file_struct *file,STRUCT_STAT *st, STRUCT_STAT st2; int change_uid, change_gid; - if (dry_run) return 0; + if (dry_run) + return 0; if (!st) { - if (link_stat(fname,&st2) != 0) { + if (link_stat(fname, &st2, 0) < 0) { rsyserr(FERROR, errno, "stat %s failed", full_fname(fname)); return 0; @@ -138,7 +141,8 @@ int set_perms(char *fname,struct file_struct *file,STRUCT_STAT *st, st = &st2; } - if (!preserve_times || S_ISLNK(st->st_mode)) + if (!preserve_times || S_ISLNK(st->st_mode) + || (make_backups && !backup_dir && S_ISDIR(st->st_mode))) flags |= PERMS_SKIP_MTIME; if (!(flags & PERMS_SKIP_MTIME) && cmp_modtime(st->st_mtime, file->modtime) != 0) { @@ -183,7 +187,7 @@ int set_perms(char *fname,struct file_struct *file,STRUCT_STAT *st, * destination had the setuid or setgid bits set due * to the side effect of the chown call */ if (st->st_mode & (S_ISUID | S_ISGID)) { - link_stat(fname, st); + link_stat(fname, st, 0); } updated = 1; } @@ -236,17 +240,25 @@ void finish_transfer(char *fname, char *fnametmp, struct file_struct *file, if (make_backups && !make_backup(fname)) return; + if (inplace) { + if (verbose > 2) + rprintf(FINFO, "finishing %s\n", fname); + goto do_set_perms; + } + /* move tmp file over real file */ + if (verbose > 2) + rprintf(FINFO, "renaming %s to %s\n", fnametmp, fname); ret = robust_rename(fnametmp, fname, file->mode & INITACCESSPERMS); if (ret < 0) { rsyserr(FERROR, errno, "%s %s -> \"%s\"", ret == -2 ? "copy" : "rename", full_fname(fnametmp), fname); do_unlink(fnametmp); - } else { - set_perms(fname, file, NULL, - ok_to_set_time ? 0 : PERMS_SKIP_MTIME); + return; } + do_set_perms: + set_perms(fname, file, NULL, ok_to_set_time ? 0 : PERMS_SKIP_MTIME); } const char *who_am_i(void)