X-Git-Url: https://mattmccutchen.net/rsync/rsync-patches.git/blobdiff_plain/1ed0b5c9ae5edd0232d22a0d8acf05bb120b23af..c2f699cc6bfb241c97cc53dfe6bfd0ea0385456c:/atimes.diff diff --git a/atimes.diff b/atimes.diff index 3eaf5d3..0ec615a 100644 --- a/atimes.diff +++ b/atimes.diff @@ -1,5 +1,6 @@ -After applying this patch, run these commands for a successful build: +To use this patch, run these commands for a successful build: + patch -p1 mode == mode) flags |= XMIT_SAME_MODE; -@@ -359,6 +369,12 @@ static void send_file_entry(struct file_ +@@ -363,6 +373,12 @@ static void send_file_entry(struct file_ flags |= XMIT_SAME_TIME; else modtime = file->modtime; @@ -90,7 +91,7 @@ After applying this patch, run these commands for a successful build: #ifdef SUPPORT_HARD_LINKS if (file->link_u.idev) { -@@ -412,6 +428,8 @@ static void send_file_entry(struct file_ +@@ -416,6 +432,8 @@ static void send_file_entry(struct file_ write_int(f, modtime); if (!(flags & XMIT_SAME_MODE)) write_int(f, to_wire_mode(mode)); @@ -99,7 +100,7 @@ After applying this patch, run these commands for a successful build: if (preserve_uid && !(flags & XMIT_SAME_UID)) { if (!numeric_ids) add_uid(uid); -@@ -478,6 +496,7 @@ static struct file_struct *receive_file_ +@@ -482,6 +500,7 @@ static struct file_struct *receive_file_ unsigned short flags, int f) { static time_t modtime; @@ -107,7 +108,7 @@ After applying this patch, run these commands for a successful build: static mode_t mode; static int64 dev; static dev_t rdev; -@@ -496,7 +515,7 @@ static struct file_struct *receive_file_ +@@ -500,7 +519,7 @@ static struct file_struct *receive_file_ struct file_struct *file; if (!flist) { @@ -116,7 +117,7 @@ After applying this patch, run these commands for a successful build: dev = 0, rdev = MAKEDEV(0, 0); rdev_major = 0; uid = 0, gid = 0; -@@ -552,6 +571,8 @@ static struct file_struct *receive_file_ +@@ -556,6 +575,8 @@ static struct file_struct *receive_file_ modtime = (time_t)read_int(f); if (!(flags & XMIT_SAME_MODE)) mode = from_wire_mode(read_int(f)); @@ -125,7 +126,7 @@ After applying this patch, run these commands for a successful build: if (chmod_modes && !S_ISLNK(mode)) mode = tweak_mode(mode, chmod_modes); -@@ -607,6 +628,8 @@ static struct file_struct *receive_file_ +@@ -611,6 +632,8 @@ static struct file_struct *receive_file_ file->mode = mode; file->uid = uid; file->gid = gid; @@ -134,7 +135,7 @@ After applying this patch, run these commands for a successful build: if (dirname_len) { file->dirname = lastdir = bp; -@@ -632,12 +655,12 @@ static struct file_struct *receive_file_ +@@ -636,12 +659,12 @@ static struct file_struct *receive_file_ && lastname[del_hier_name_len-1] == '.' && lastname[del_hier_name_len-2] == '/') del_hier_name_len -= 2; @@ -149,7 +150,7 @@ After applying this patch, run these commands for a successful build: else in_del_hier = 0; } -@@ -853,12 +876,14 @@ struct file_struct *make_file(char *fnam +@@ -858,12 +881,14 @@ struct file_struct *make_file(char *fnam memset(bp, 0, file_struct_len); bp += file_struct_len; @@ -165,7 +166,7 @@ After applying this patch, run these commands for a successful build: #ifdef SUPPORT_HARD_LINKS if (flist && flist->hlink_pool) { -@@ -971,7 +996,7 @@ static void send_if_directory(int f, str +@@ -976,7 +1001,7 @@ static void send_if_directory(int f, str char is_dot_dir = fbuf[ol-1] == '.' && (ol == 1 || fbuf[ol-2] == '/'); if (S_ISDIR(file->mode) @@ -174,7 +175,7 @@ After applying this patch, run these commands for a successful build: void *save_filters; unsigned int len = strlen(fbuf); if (len > 1 && fbuf[len-1] == '/') -@@ -1585,8 +1610,9 @@ static void clean_flist(struct file_list +@@ -1586,8 +1611,9 @@ static void clean_flist(struct file_list } /* Make sure we don't lose track of a user-specified * top directory. */ @@ -186,7 +187,7 @@ After applying this patch, run these commands for a successful build: clear_file(flist->files[drop], flist); -@@ -1710,7 +1736,7 @@ static void output_flist(struct file_lis +@@ -1711,7 +1737,7 @@ static void output_flist(struct file_lis file->dirname ? file->dirname : "", file->dirname ? "/" : "", NS(file->basename), S_ISDIR(file->mode) ? "/" : "", (int)file->mode, @@ -205,7 +206,7 @@ After applying this patch, run these commands for a successful build: extern int omit_dir_times; extern int delete_mode; extern int delete_before; -@@ -89,6 +90,7 @@ extern dev_t filesystem_dev; +@@ -90,6 +91,7 @@ extern dev_t filesystem_dev; extern char *backup_dir; extern char *backup_suffix; extern int backup_suffix_len; @@ -213,7 +214,7 @@ After applying this patch, run these commands for a successful build: extern struct file_list *the_file_list; extern struct filter_list_struct server_filter_list; -@@ -181,7 +183,7 @@ static int delete_item(char *fname, int +@@ -182,7 +184,7 @@ static int delete_item(char *fname, int for (j = dirlist->count; j--; ) { struct file_struct *fp = dirlist->files[j]; @@ -222,7 +223,7 @@ After applying this patch, run these commands for a successful build: continue; strlcpy(p, fp->basename, remainder); -@@ -259,7 +261,7 @@ static void delete_in_dir(struct file_li +@@ -260,7 +262,7 @@ static void delete_in_dir(struct file_li filt_array[cur_depth] = push_local_filters(fbuf, dlen); if (one_file_system) { @@ -231,7 +232,7 @@ After applying this patch, run these commands for a successful build: filesystem_dev = stp->st_dev; else if (filesystem_dev != stp->st_dev) return; -@@ -271,7 +273,7 @@ static void delete_in_dir(struct file_li +@@ -272,7 +274,7 @@ static void delete_in_dir(struct file_li * from the filesystem. */ for (i = dirlist->count; i--; ) { struct file_struct *fp = dirlist->files[i]; @@ -240,7 +241,7 @@ After applying this patch, run these commands for a successful build: continue; if (flist_find(flist, fp) < 0) { f_name(fp, delbuf); -@@ -297,11 +299,11 @@ static void do_delete_pass(struct file_l +@@ -298,11 +300,11 @@ static void do_delete_pass(struct file_l for (j = 0; j < flist->count; j++) { struct file_struct *file = flist->files[j]; @@ -254,7 +255,7 @@ After applying this patch, run these commands for a successful build: rprintf(FINFO, "deleting in %s\n", fbuf); if (link_stat(fbuf, &st, keep_dirlinks) < 0 -@@ -345,6 +347,9 @@ void itemize(struct file_struct *file, i +@@ -346,6 +348,9 @@ void itemize(struct file_struct *file, i && (!(iflags & ITEM_XNAME_FOLLOWS) || *xname)) || (keep_time && cmp_time(file->modtime, st->st_mtime) != 0)) iflags |= ITEM_REPORT_TIME; @@ -264,7 +265,7 @@ After applying this patch, run these commands for a successful build: if ((file->mode & CHMOD_BITS) != (st->st_mode & CHMOD_BITS)) iflags |= ITEM_REPORT_PERMS; if (preserve_uid && am_root && file->uid != st->st_uid) -@@ -548,7 +553,7 @@ static int find_fuzzy(struct file_struct +@@ -549,7 +554,7 @@ static int find_fuzzy(struct file_struct uint32 dist; if (!S_ISREG(fp->mode) || !fp->length @@ -273,17 +274,26 @@ After applying this patch, run these commands for a successful build: continue; name = fp->basename; -@@ -657,6 +662,8 @@ static int try_dests_reg(struct file_str +@@ -658,6 +663,8 @@ static int try_dests_reg(struct file_str itemizing && verbose > 1, code) < 0) goto try_a_copy; + if (preserve_atimes) + set_file_attrs(fname, file, stp, 0); - if (preserve_hard_links && file->link_u.links) - hard_link_cluster(file, ndx, itemizing, code); - } else -@@ -934,7 +941,7 @@ static void recv_generator(char *fname, - && verbose && code && f_out != -1) + if (preserve_hard_links && file->link_u.links) { + if (dry_run) + file->link_u.links->link_dest_used = j + 1; +@@ -930,7 +937,7 @@ static void recv_generator(char *fname, + rsyserr(FERROR, errno, + "recv_generator: mkdir %s failed", + full_fname(fname)); +- file->flags |= FLAG_MISSING; ++ FFLAGS(file) |= FLAG_MISSING; + if (ndx+1 < the_file_list->count + && the_file_list->files[ndx+1]->dir.depth > file->dir.depth) { + rprintf(FERROR, +@@ -944,7 +951,7 @@ static void recv_generator(char *fname, + && verbose && code != FNONE && f_out != -1) rprintf(code, "%s/\n", fname); if (delete_during && f_out != -1 && !phase && dry_run < 2 - && (file->flags & FLAG_DEL_HERE)) @@ -291,7 +301,7 @@ After applying this patch, run these commands for a successful build: delete_in_dir(the_file_list, fname, file, &st); return; } -@@ -1237,7 +1244,7 @@ static void recv_generator(char *fname, +@@ -1252,7 +1259,7 @@ static void recv_generator(char *fname, if (fuzzy_dirlist) { int j = flist_find(fuzzy_dirlist, file); if (j >= 0) /* don't use changing file as future fuzzy basis */ @@ -300,6 +310,15 @@ After applying this patch, run these commands for a successful build: } /* open the file */ +@@ -1517,7 +1524,7 @@ void generate_files(int f_out, struct fi + continue; + if (!need_retouch_dir_times && file->mode & S_IWUSR) + continue; +- if (file->flags & FLAG_MISSING) { ++ if (FFLAGS(file) & FLAG_MISSING) { + int missing = file->dir.depth; + while (++i < flist->count) { + file = flist->files[i]; --- old/hlink.c +++ new/hlink.c @@ -30,6 +30,7 @@ extern int make_backups; @@ -310,7 +329,7 @@ After applying this patch, run these commands for a successful build: extern struct file_list *the_file_list; #ifdef SUPPORT_HARD_LINKS -@@ -90,10 +91,10 @@ static void link_idev_data(void) +@@ -91,10 +92,10 @@ static void link_idev_data(void) FPTR(cur)->link_u.links = pool_talloc(hlink_pool, struct hlink, 1, "hlink_list"); @@ -320,10 +339,10 @@ After applying this patch, run these commands for a successful build: FPTR(cur)->F_NEXT = head; - FPTR(cur)->flags |= FLAG_HLINK_EOL; + FFLAGS(FPTR(cur)) |= FLAG_HLINK_EOL; + FPTR(cur)->link_u.links->link_dest_used = 0; hlink_list[to++] = head; } else - FPTR(cur)->link_u.links = NULL; -@@ -179,7 +180,7 @@ int hard_link_check(struct file_struct * +@@ -181,7 +182,7 @@ int hard_link_check(struct file_struct * { #ifdef SUPPORT_HARD_LINKS int head; @@ -332,7 +351,7 @@ After applying this patch, run these commands for a successful build: head = hlink_list[file->F_HLINDEX] = file->F_NEXT; else head = hlink_list[file->F_HLINDEX]; -@@ -279,8 +280,8 @@ void hard_link_cluster(struct file_struc +@@ -289,8 +290,8 @@ void hard_link_cluster(struct file_struc file->F_HLINDEX = FINISHED_LINK; if (link_stat(f_name(file, hlink1), &st1, 0) < 0) return; @@ -343,7 +362,7 @@ After applying this patch, run these commands for a successful build: ndx = file->F_NEXT; file = FPTR(ndx); } -@@ -300,6 +301,6 @@ void hard_link_cluster(struct file_struc +@@ -310,6 +311,6 @@ void hard_link_cluster(struct file_struc send_msg(MSG_SUCCESS, numbuf, 4); } file->F_HLINDEX = FINISHED_LINK; @@ -361,7 +380,7 @@ After applying this patch, run these commands for a successful build: extern int stdout_format_has_i; extern int stdout_format_has_o_or_i; extern int logfile_format_has_i; -@@ -609,7 +610,8 @@ static void log_formatted(enum logcode c +@@ -606,7 +607,8 @@ static void log_formatted(enum logcode c n[5] = !(iflags & ITEM_REPORT_PERMS) ? '.' : 'p'; n[6] = !(iflags & ITEM_REPORT_OWNER) ? '.' : 'o'; n[7] = !(iflags & ITEM_REPORT_GROUP) ? '.' : 'g'; @@ -381,7 +400,7 @@ After applying this patch, run these commands for a successful build: int update_only = 0; int cvs_exclude = 0; int dry_run = 0; -@@ -309,8 +310,9 @@ void usage(enum logcode F) +@@ -311,8 +312,9 @@ void usage(enum logcode F) rprintf(F," --devices preserve device files (super-user only)\n"); rprintf(F," --specials preserve special files\n"); rprintf(F," -D same as --devices --specials\n"); @@ -393,7 +412,7 @@ After applying this patch, run these commands for a successful build: rprintf(F," --super receiver attempts super-user activities\n"); rprintf(F," -S, --sparse handle sparse files efficiently\n"); rprintf(F," -n, --dry-run show what would have been transferred\n"); -@@ -424,6 +426,9 @@ static struct poptOption long_options[] +@@ -428,6 +430,9 @@ static struct poptOption long_options[] {"times", 't', POPT_ARG_VAL, &preserve_times, 1, 0, 0 }, {"no-times", 0, POPT_ARG_VAL, &preserve_times, 0, 0, 0 }, {"no-t", 0, POPT_ARG_VAL, &preserve_times, 0, 0, 0 }, @@ -403,7 +422,7 @@ After applying this patch, run these commands for a successful build: {"omit-dir-times", 'O', POPT_ARG_VAL, &omit_dir_times, 2, 0, 0 }, {"modify-window", 0, POPT_ARG_INT, &modify_window, OPT_MODIFY_WINDOW, 0, 0 }, {"super", 0, POPT_ARG_VAL, &am_root, 2, 0, 0 }, -@@ -1537,6 +1542,8 @@ void server_options(char **args,int *arg +@@ -1538,6 +1543,8 @@ void server_options(char **args,int *arg argstr[x++] = 'D'; if (preserve_times) argstr[x++] = 't'; @@ -485,7 +504,7 @@ After applying this patch, run these commands for a successful build: #define FULL_FLUSH 1 #define NORMAL_FLUSH 0 -@@ -529,9 +531,12 @@ struct file_struct { +@@ -530,9 +532,12 @@ struct file_struct { uid_t uid; gid_t gid; mode_t mode; @@ -501,7 +520,7 @@ After applying this patch, run these commands for a successful build: * by doubling until FLIST_LINEAR then grow by FLIST_LINEAR --- old/rsync.yo +++ new/rsync.yo -@@ -327,8 +327,9 @@ to the detailed description below for a +@@ -328,8 +328,9 @@ to the detailed description below for a --devices preserve device files (super-user only) --specials preserve special files -D same as --devices --specials @@ -513,7 +532,7 @@ After applying this patch, run these commands for a successful build: --super receiver attempts super-user activities -S, --sparse handle sparse files efficiently -n, --dry-run show what would have been transferred -@@ -863,6 +864,12 @@ it is preserving modification times (see +@@ -869,6 +870,12 @@ it is preserving modification times (see the directories on the receiving side, it is a good idea to use bf(-O). This option is inferred if you use bf(--backup) without bf(--backup-dir). @@ -526,7 +545,7 @@ After applying this patch, run these commands for a successful build: dit(bf(--super)) This tells the receiving side to attempt super-user activities even if the receiving rsync wasn't run by the super-user. These activities include: preserving users via the bf(--owner) option, preserving -@@ -1384,7 +1391,7 @@ with older versions of rsync, but that a +@@ -1390,7 +1397,7 @@ with older versions of rsync, but that a verbose messages). The "%i" escape has a cryptic output that is 9 letters long. The general @@ -535,7 +554,7 @@ After applying this patch, run these commands for a successful build: type of update being done, bf(X) is replaced by the file-type, and the other letters represent attributes that may be output if they are being modified. -@@ -1424,7 +1431,7 @@ quote(itemize( +@@ -1430,7 +1437,7 @@ quote(itemization( by the file transfer. it() A bf(t) means the modification time is different and is being updated to the sender's value (requires bf(--times)). An alternate value of bf(T) @@ -544,7 +563,7 @@ After applying this patch, run these commands for a successful build: anytime a symlink is transferred, or when a file or device is transferred without bf(--times). it() A bf(p) means the permissions are different and are being updated to -@@ -1433,7 +1440,10 @@ quote(itemize( +@@ -1439,7 +1446,10 @@ quote(itemization( sender's value (requires bf(--owner) and super-user privileges). it() A bf(g) means the group is different and is being updated to the sender's value (requires bf(--group) and the authority to set the group). @@ -657,21 +676,21 @@ After applying this patch, run these commands for a successful build: exit(1); } -+static void storetime(char *dest, time_t t) ++static void storetime(char *dest, time_t t, size_t destsize) +{ + if (t) { + struct tm *mt = gmtime(&t); + -+ sprintf(dest, "%04d-%02d-%02d %02d:%02d:%02d ", ++ snprintf(dest, destsize, ++ "%04d-%02d-%02d %02d:%02d:%02d ", + (int)mt->tm_year + 1900, + (int)mt->tm_mon + 1, + (int)mt->tm_mday, + (int)mt->tm_hour, + (int)mt->tm_min, + (int)mt->tm_sec); -+ } else { -+ strcpy(dest, " "); -+ } ++ } else ++ strlcpy(dest, " ", destsize); +} + static void list_file(const char *fname) @@ -692,18 +711,18 @@ After applying this patch, run these commands for a successful build: - if (buf.st_mtime) { - mt = gmtime(&buf.st_mtime); - -- sprintf(datebuf, "%04d-%02d-%02d %02d:%02d:%02d", +- snprintf(datebuf, sizeof datebuf, +- "%04d-%02d-%02d %02d:%02d:%02d", - (int)mt->tm_year + 1900, - (int)mt->tm_mon + 1, - (int)mt->tm_mday, - (int)mt->tm_hour, - (int)mt->tm_min, - (int)mt->tm_sec); -- } else { -- strcpy(datebuf, " "); -- } -+ storetime(mtimebuf, buf.st_mtime); -+ storetime(atimebuf, buf.st_atime); +- } else +- strlcpy(datebuf, " ", sizeof datebuf); ++ storetime(mtimebuf, buf.st_mtime, sizeof mtimebuf); ++ storetime(atimebuf, buf.st_atime, sizeof atimebuf); /* TODO: Perhaps escape special characters in fname? */ @@ -740,10 +759,13 @@ After applying this patch, run these commands for a successful build: - fprintf(stderr, "usage: " PROGRAM " DIR ...\n" - "Trivial file listing program for portably checking rsync\n"); - return 1; +- } + poptContext pc; + const char **extra_args; + int opt; -+ + +- for (argv++; *argv; argv++) { +- list_file(*argv); + pc = poptGetContext(PROGRAM, argc, (const char **)argv, + long_options, 0); + while ((opt = poptGetNextOpt(pc)) != -1) { @@ -759,9 +781,6 @@ After applying this patch, run these commands for a successful build: + } } -- for (argv++; *argv; argv++) { -- list_file(*argv); -- } + extra_args = poptGetArgs(pc); + if (*extra_args == NULL) + tls_usage(1); @@ -769,12 +788,12 @@ After applying this patch, run these commands for a successful build: + for (; *extra_args; extra_args++) + list_file(*extra_args); + poptFreeContext(pc); - ++ return 0; } --- old/util.c +++ new/util.c -@@ -121,7 +121,7 @@ void overflow_exit(char *str) +@@ -121,7 +121,7 @@ NORETURN void overflow_exit(char *str) exit_cleanup(RERR_MALLOC); }