X-Git-Url: https://mattmccutchen.net/rsync/rsync.git/blobdiff_plain/6cc119828892f4c28fc55274e11055f8c420515c..74de13d19c5c9bd1d7d1acde810fcb5bd398a359:/generator.c diff --git a/generator.c b/generator.c index f4dbb9cc..d50c090f 100644 --- a/generator.c +++ b/generator.c @@ -52,7 +52,8 @@ extern int ignore_errors; extern int remove_sent_files; extern int delay_updates; extern int update_only; -extern int opt_ignore_existing; +extern int ignore_existing; +extern int ignore_non_existing; extern int inplace; extern int append_mode; extern int make_backups; @@ -75,7 +76,6 @@ extern int link_dest; extern int whole_file; extern int list_only; extern int read_batch; -extern int only_existing; extern int orig_umask; extern int safe_symlinks; extern long block_size; /* "long" because popt can't set an int32. */ @@ -446,8 +446,8 @@ static void sum_sizes_sqroot(struct sum_struct *sum, int64 len) sum->flength = len; sum->blength = blength; sum->s2length = s2length; - sum->count = (len + (blength - 1)) / blength; - sum->remainder = (len % blength); + sum->remainder = len % blength; + sum->count = len / blength + (sum->remainder != 0); if (sum->count && verbose > 2) { rprintf(FINFO, @@ -675,8 +675,7 @@ static void recv_generator(char *fname, struct file_struct *file, int ndx, stat_errno = errno; } - if (only_existing && statret == -1 && stat_errno == ENOENT) { - /* we only want to update existing files */ + if (ignore_non_existing && statret == -1 && stat_errno == ENOENT) { if (verbose > 1) { rprintf(FINFO, "not creating new %s \"%s\"\n", S_ISDIR(file->mode) ? "directory" : "file", @@ -731,6 +730,11 @@ static void recv_generator(char *fname, struct file_struct *file, int ndx, return; } + if (preserve_hard_links && file->link_u.links + && hard_link_check(file, ndx, fname, statret, &st, + itemizing, code, HL_CHECK_MASTER)) + return; + if (preserve_links && S_ISLNK(file->mode)) { #ifdef SUPPORT_LINKS if (safe_symlinks && unsafe_symlink(file->u.link, fname)) { @@ -761,6 +765,12 @@ static void recv_generator(char *fname, struct file_struct *file, int ndx, } set_perms(fname, file, &st, maybe_PERMS_REPORT); + if (preserve_hard_links + && file->link_u.links) { + hard_link_cluster(file, ndx, + itemizing, + code); + } return; } } @@ -771,6 +781,10 @@ static void recv_generator(char *fname, struct file_struct *file, int ndx, if (!S_ISLNK(st.st_mode)) statret = -1; } + if (preserve_hard_links && file->link_u.links + && hard_link_check(file, ndx, fname, -1, &st, + itemizing, code, HL_SKIP)) + return; if (do_symlink(file->u.link,fname) != 0) { rsyserr(FERROR, errno, "symlink %s -> \"%s\" failed", full_fname(fname), safe_fname(file->u.link)); @@ -789,17 +803,23 @@ static void recv_generator(char *fname, struct file_struct *file, int ndx, SIVAL(numbuf, 0, ndx); send_msg(MSG_SUCCESS, numbuf, 4); } + if (preserve_hard_links && file->link_u.links) + hard_link_cluster(file, ndx, itemizing, code); } #endif return; } if (am_root && preserve_devices && IS_DEVICE(file->mode)) { - if (statret != 0 || - st.st_mode != file->mode || - st.st_rdev != file->u.rdev) { + if (statret != 0 + || (st.st_mode & ~CHMOD_BITS) != (file->mode & ~CHMOD_BITS) + || st.st_rdev != file->u.rdev) { if (delete_item(fname, st.st_mode, DEL_TERSE) < 0) return; + if (preserve_hard_links && file->link_u.links + && hard_link_check(file, ndx, fname, -1, &st, + itemizing, code, HL_SKIP)) + return; if (!IS_DEVICE(st.st_mode)) statret = -1; if (verbose > 2) { @@ -820,20 +840,21 @@ static void recv_generator(char *fname, struct file_struct *file, int ndx, rprintf(code, "%s\n", safe_fname(fname)); } + if (preserve_hard_links && file->link_u.links) { + hard_link_cluster(file, ndx, + itemizing, code); + } } } else { if (itemizing) itemize(file, ndx, statret, &st, 0, 0, NULL); set_perms(fname, file, &st, maybe_PERMS_REPORT); + if (preserve_hard_links && file->link_u.links) + hard_link_cluster(file, ndx, itemizing, code); } return; } - if (preserve_hard_links - && hard_link_check(file, ndx, fname, statret, &st, - itemizing, code, HL_CHECK_MASTER)) - return; - if (!S_ISREG(file->mode)) { if (the_file_list->count == 1) fname = f_name(file); @@ -852,7 +873,7 @@ static void recv_generator(char *fname, struct file_struct *file, int ndx, return; } - if (opt_ignore_existing && statret == 0) { + if (ignore_existing && statret == 0) { if (verbose > 1) rprintf(FINFO, "%s exists\n", safe_fname(fname)); return; @@ -1001,17 +1022,14 @@ static void recv_generator(char *fname, struct file_struct *file, int ndx, } if (statret != 0) { - if (preserve_hard_links + if (preserve_hard_links && file->link_u.links && hard_link_check(file, ndx, fname, statret, &st, itemizing, code, HL_SKIP)) return; if (stat_errno == ENOENT) goto notify_others; - if (verbose > 1) { - rsyserr(FERROR, stat_errno, - "recv_generator: failed to stat %s", - full_fname(fname)); - } + rsyserr(FERROR, stat_errno, "recv_generator: failed to stat %s", + full_fname(fname)); return; } @@ -1064,7 +1082,7 @@ prepare_to_open: full_fname(fnamecmp)); pretend_missing: /* pretend the file didn't exist */ - if (preserve_hard_links + if (preserve_hard_links && file->link_u.links && hard_link_check(file, ndx, fname, statret, &st, itemizing, code, HL_SKIP)) return; @@ -1159,8 +1177,8 @@ void generate_files(int f_out, struct file_list *flist, char *local_name) int lull_mod = allowed_lull * 5; int need_retouch_dir_times = preserve_times && !omit_dir_times; int need_retouch_dir_perms = 0; - int save_only_existing = only_existing; - int save_opt_ignore_existing = opt_ignore_existing; + int save_ignore_existing = ignore_existing; + int save_ignore_non_existing = ignore_non_existing; int save_do_progress = do_progress; int save_make_backups = make_backups; @@ -1247,7 +1265,7 @@ void generate_files(int f_out, struct file_list *flist, char *local_name) phase++; csum_length = SUM_LENGTH; - only_existing = max_size = opt_ignore_existing = 0; + max_size = ignore_existing = ignore_non_existing = 0; update_only = always_checksum = size_only = 0; ignore_times = 1; if (append_mode) /* resend w/o append mode */ @@ -1269,8 +1287,8 @@ void generate_files(int f_out, struct file_list *flist, char *local_name) } phase++; - only_existing = save_only_existing; - opt_ignore_existing = save_opt_ignore_existing; + ignore_non_existing = save_ignore_non_existing; + ignore_existing = save_ignore_existing; make_backups = save_make_backups; if (verbose > 2)