Marc Aurèle La France
2023-May-17 02:16 UTC
[PATCH] Add --omit-{device,special}-times options
Similar to --omit-{dir,link}-times: --omit-device-times omit device files from --times --omit-special-times omit sockets and fifos from --times Also, fix corner case that allows --omit-dir-times to be ignored. See unchanged_attrs() and recv_generator()'s call to try_dests_non(). Marc. diff -aNpRruz -X /etc/diff.excludes rsync-3.2.7/generator.c devel-3.2.7/generator.c --- rsync-3.2.7/generator.c 2022-09-15 11:12:02.000000000 -0600 +++ devel-3.2.7/generator.c 2022-09-15 11:12:02.000000000 -0600 @@ -47,6 +47,8 @@ extern int preserve_perms; extern int preserve_mtimes; extern int omit_dir_times; extern int omit_link_times; +extern int omit_device_times; +extern int omit_special_times; extern int delete_mode; extern int delete_before; extern int delete_during; @@ -482,7 +484,12 @@ int unchanged_attrs(const char *fname, struct file_struct *file, stat_x *sxp) return 0; #endif } else { - if (preserve_mtimes && any_time_differs(sxp, file, fname)) + int keep_time = !preserve_mtimes ? 0 + : S_ISDIR(file->mode) ? !omit_dir_times + : IS_DEVICE(file->mode) ? !omit_device_times + : IS_SPECIAL(file->mode) ? !omit_special_times + : 1; + if (keep_time && any_time_differs(sxp, file, fname)) return 0; if (perms_differ(file, sxp)) return 0; @@ -509,6 +516,8 @@ void itemize(const char *fnamecmp, struct file_struct *file, int ndx, int statret, int keep_time = !preserve_mtimes ? 0 : S_ISDIR(file->mode) ? !omit_dir_times : S_ISLNK(file->mode) ? !omit_link_times + : IS_DEVICE(file->mode) ? !omit_device_times + : IS_SPECIAL(file->mode) ? !omit_special_times : 1; if (S_ISREG(file->mode) && F_LENGTH(file) != sxp->st.st_size) diff -aNpRruz -X /etc/diff.excludes rsync-3.2.7/options.c devel-3.2.7/options.c --- rsync-3.2.7/options.c 2022-09-10 14:14:42.000000000 -0600 +++ devel-3.2.7/options.c 2022-09-10 14:14:42.000000000 -0600 @@ -66,6 +66,8 @@ int preserve_atimes = 0; int preserve_crtimes = 0; int omit_dir_times = 0; int omit_link_times = 0; +int omit_device_times = 0; +int omit_special_times = 0; int trust_sender = 0; int update_only = 0; int open_noatime = 0; @@ -646,6 +648,10 @@ static struct poptOption long_options[] = { {"omit-link-times", 'J', POPT_ARG_VAL, &omit_link_times, 1, 0, 0 }, {"no-omit-link-times",0, POPT_ARG_VAL, &omit_link_times, 0, 0, 0 }, {"no-J", 0, POPT_ARG_VAL, &omit_link_times, 0, 0, 0 }, + {"omit-device-times",0, POPT_ARG_VAL, &omit_device_times, 1, 0, 0 }, + {"no-omit-device-times",0, POPT_ARG_VAL, &omit_device_times, 0, 0, 0 }, + {"omit-special-times",0, POPT_ARG_VAL, &omit_special_times, 1, 0, 0 }, + {"no-omit-special-times",0, POPT_ARG_VAL, &omit_special_times, 0, 0, 0 }, {"modify-window", '@', POPT_ARG_INT, &modify_window, OPT_MODIFY_WINDOW, 0, 0 }, {"super", 0, POPT_ARG_VAL, &am_root, 2, 0, 0 }, {"no-super", 0, POPT_ARG_VAL, &am_root, 0, 0, 0 }, @@ -2815,6 +2821,10 @@ void server_options(char **args, int *argc_p) args[ac++] = "--size-only"; if (do_stats) args[ac++] = "--stats"; + if (omit_device_times) + args[ac++] = "--omit-device-times"; + if (omit_special_times) + args[ac++] = "--omit-special-times"; } else { if (skip_compress) args[ac++] = safe_arg("--skip-compress", skip_compress); diff -aNpRruz -X /etc/diff.excludes rsync-3.2.7/rsync.1.md devel-3.2.7/rsync.1.md --- rsync-3.2.7/rsync.1.md 2022-10-16 13:27:30.000000000 -0600 +++ devel-3.2.7/rsync.1.md 2022-10-16 13:27:30.000000000 -0600 @@ -463,6 +463,8 @@ has its own detailed description later in this manpage. --crtimes, -N preserve create times (newness) --omit-dir-times, -O omit directories from --times --omit-link-times, -J omit symlinks from --times +--omit-device-times omit device files from --times +--omit-special-times omit sockets and fifos from --times --super receiver attempts super-user activities --fake-super store/recover privileged attrs using xattrs --sparse, -S turn sequences of nulls into sparse blocks @@ -1654,6 +1656,16 @@ expand it. This tells rsync to omit symlinks when it is preserving modification, access, and create times. +0. `--omit-device-times` + + This tells rsync to omit device files when it is preserving modification, + access, and create times. + +0. `--omit-special-times` + + This tells rsync to omit sockets and fifos when it is preserving + modification, access, and create times. + 0. `--super` This tells the receiving side to attempt super-user activities even if the diff -aNpRruz -X /etc/diff.excludes rsync-3.2.7/rsync.c devel-3.2.7/rsync.c --- rsync-3.2.7/rsync.c 2022-08-13 11:53:53.000000000 -0600 +++ devel-3.2.7/rsync.c 2022-08-13 11:53:53.000000000 -0600 @@ -35,6 +35,8 @@ extern int preserve_executability; extern int preserve_mtimes; extern int omit_dir_times; extern int omit_link_times; +extern int omit_device_times; +extern int omit_special_times; extern int am_root; extern int am_server; extern int am_daemon; @@ -578,7 +580,9 @@ int set_file_attrs(const char *fname, struct file_struct *file, stat_x *sxp, #endif if ((omit_dir_times && S_ISDIR(sxp->st.st_mode)) - || (omit_link_times && S_ISLNK(sxp->st.st_mode))) + || (omit_link_times && S_ISLNK(sxp->st.st_mode)) + || (omit_device_times && IS_DEVICE(sxp->st.st_mode)) + || (omit_special_times && IS_SPECIAL(sxp->st.st_mode))) flags |= ATTRS_SKIP_MTIME | ATTRS_SKIP_ATIME | ATTRS_SKIP_CRTIME; else { if (!preserve_mtimes)
On Tue, May 16, 2023 at 7:28?PM Marc Aur?le La France wrote:> Similar to --omit-{dir,link}-times: > > --omit-device-times omit device files from --times > --omit-special-times omit sockets and fifos from --times >I'm not convinced these are needed at present. Also, fix corner case that allows --omit-dir-times to be ignored. See> unchanged_attrs() and recv_generator()'s call to try_dests_non(). >Directories aren't linked together, so they aren't passed to unchanged_attrs() or try_dests_non(). ..wayne.. -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.samba.org/pipermail/rsync/attachments/20230526/e3058145/attachment.htm>