File:  [ELWIX - Embedded LightWeight unIX -] / embedaddon / rsync / patches / omit-dir-changes.diff
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs - revision graph
Wed Mar 17 00:32:36 2021 UTC (3 years, 3 months ago) by misho
Branches: rsync, MAIN
CVS tags: v3_2_3, HEAD
rsync 3.2.3

    1: This patch from Antti Tapaninen added the --omit-dir-changes option, which
    2: tells rsync to not affect any attributes on the directories in the transfer.
    3: 
    4: To use this patch, run these commands for a successful build:
    5: 
    6:     patch -p1 <patches/omit-dir-changes.diff
    7:     ./configure                              (optional if already run)
    8:     make
    9: 
   10: based-on: e94bad1c156fc3910f24e2b3b71a81b0b0bdeb70
   11: diff --git a/generator.c b/generator.c
   12: --- a/generator.c
   13: +++ b/generator.c
   14: @@ -45,6 +45,7 @@ extern int preserve_hard_links;
   15:  extern int preserve_executability;
   16:  extern int preserve_perms;
   17:  extern int preserve_times;
   18: +extern int omit_dir_changes;
   19:  extern int delete_mode;
   20:  extern int delete_before;
   21:  extern int delete_during;
   22: @@ -507,6 +508,7 @@ void itemize(const char *fnamecmp, struct file_struct *file, int ndx, int statre
   23:  	     const char *xname)
   24:  {
   25:  	if (statret >= 0) { /* A from-dest-dir statret can == 1! */
   26: +		int omit_changes = omit_dir_changes && S_ISDIR(sxp->st.st_mode);
   27:  		int keep_time = !preserve_times ? 0
   28:  		    : S_ISDIR(file->mode) ? preserve_times & PRESERVE_DIR_TIMES
   29:  		    : S_ISLNK(file->mode) ? preserve_times & PRESERVE_LINK_TIMES
   30: @@ -544,9 +546,9 @@ void itemize(const char *fnamecmp, struct file_struct *file, int ndx, int statre
   31:  		} else if (preserve_executability
   32:  		 && ((sxp->st.st_mode & 0111 ? 1 : 0) ^ (file->mode & 0111 ? 1 : 0)))
   33:  			iflags |= ITEM_REPORT_PERMS;
   34: -		if (uid_ndx && am_root && (uid_t)F_OWNER(file) != sxp->st.st_uid)
   35: +		if (uid_ndx && am_root && !omit_changes && (uid_t)F_OWNER(file) != sxp->st.st_uid)
   36:  			iflags |= ITEM_REPORT_OWNER;
   37: -		if (gid_ndx && !(file->flags & FLAG_SKIP_GROUP) && sxp->st.st_gid != (gid_t)F_GROUP(file))
   38: +		if (gid_ndx && !omit_changes && !(file->flags & FLAG_SKIP_GROUP) && sxp->st.st_gid != (gid_t)F_GROUP(file))
   39:  			iflags |= ITEM_REPORT_GROUP;
   40:  #ifdef SUPPORT_ACLS
   41:  		if (preserve_acls && !S_ISLNK(file->mode)) {
   42: @@ -1439,7 +1441,7 @@ static void recv_generator(char *fname, struct file_struct *file, int ndx,
   43:  		real_ret = statret;
   44:  		if (file->flags & FLAG_DIR_CREATED)
   45:  			statret = -1;
   46: -		if (!preserve_perms) { /* See comment in non-dir code below. */
   47: +		if (!preserve_perms || omit_dir_changes) { /* See comment in non-dir code below. */
   48:  			file->mode = dest_mode(file->mode, sx.st.st_mode, dflt_perms, statret == 0);
   49:  		}
   50:  		if (statret != 0 && basis_dir[0] != NULL) {
   51: diff --git a/options.c b/options.c
   52: --- a/options.c
   53: +++ b/options.c
   54: @@ -73,6 +73,7 @@ int delete_before = 0;
   55:  int delete_after = 0;
   56:  int delete_excluded = 0;
   57:  int remove_source_files = 0;
   58: +int omit_dir_changes = 0;
   59:  int one_file_system = 0;
   60:  int protocol_version = PROTOCOL_VERSION;
   61:  int sparse_files = 0;
   62: @@ -638,6 +639,7 @@ static struct poptOption long_options[] = {
   63:    {"omit-link-times", 'J', POPT_ARG_VAL,    &omit_link_times, 1, 0, 0 },
   64:    {"no-omit-link-times",0, POPT_ARG_VAL,    &omit_link_times, 0, 0, 0 },
   65:    {"no-J",             0,  POPT_ARG_VAL,    &omit_link_times, 0, 0, 0 },
   66: +  {"omit-dir-changes", 0,  POPT_ARG_NONE,   &omit_dir_changes, 0, 0, 0 },
   67:    {"modify-window",   '@', POPT_ARG_INT,    &modify_window, OPT_MODIFY_WINDOW, 0, 0 },
   68:    {"super",            0,  POPT_ARG_VAL,    &am_root, 2, 0, 0 },
   69:    {"no-super",         0,  POPT_ARG_VAL,    &am_root, 0, 0, 0 },
   70: @@ -2255,6 +2257,9 @@ int parse_arguments(int *argc_p, const char ***argv_p)
   71:  		parse_filter_str(&filter_list, backup_dir_buf, rule_template(0), 0);
   72:  	}
   73:  
   74: +	if (omit_dir_changes)
   75: +		omit_dir_times = 1;
   76: +
   77:  	if (preserve_times) {
   78:  		preserve_times = PRESERVE_FILE_TIMES;
   79:  		if (!omit_dir_times)
   80: @@ -2500,6 +2505,8 @@ void server_options(char **args, int *argc_p)
   81:  			argstr[x++] = 'O';
   82:  		if (omit_link_times)
   83:  			argstr[x++] = 'J';
   84: +		if (omit_dir_changes == 1)
   85: +			args[ac++] = "--omit-dir-changes";
   86:  		if (fuzzy_basis) {
   87:  			argstr[x++] = 'y';
   88:  			if (fuzzy_basis > 1)
   89: diff --git a/rsync.1.md b/rsync.1.md
   90: --- a/rsync.1.md
   91: +++ b/rsync.1.md
   92: @@ -376,6 +376,7 @@ detailed description below for a complete description.
   93:  --crtimes, -N            preserve create times (newness)
   94:  --omit-dir-times, -O     omit directories from --times
   95:  --omit-link-times, -J    omit symlinks from --times
   96: +--omit-dir-changes       omit directories from any attribute changes
   97:  --super                  receiver attempts super-user activities
   98:  --fake-super             store/recover privileged attrs using xattrs
   99:  --sparse, -S             turn sequences of nulls into sparse blocks
  100: @@ -1405,6 +1406,11 @@ your home directory (remove the '=' for that).
  101:      This tells rsync to omit symlinks when it is preserving modification times
  102:      (see `--times`).
  103:  
  104: +0.  `--omit-dir-changes`
  105: +
  106: +    This tells rsync to omit directories when applying any preserved attributes
  107: +    (owner, group, times, permissions) to already existing directories.
  108: +
  109:  0.  `--super`
  110:  
  111:      This tells the receiving side to attempt super-user activities even if the
  112: diff --git a/rsync.c b/rsync.c
  113: --- a/rsync.c
  114: +++ b/rsync.c
  115: @@ -33,6 +33,7 @@ extern int preserve_xattrs;
  116:  extern int preserve_perms;
  117:  extern int preserve_executability;
  118:  extern int preserve_times;
  119: +extern int omit_dir_changes;
  120:  extern int am_root;
  121:  extern int am_server;
  122:  extern int am_daemon;
  123: @@ -519,9 +520,11 @@ int set_file_attrs(const char *fname, struct file_struct *file, stat_x *sxp,
  124:  		get_acl(fname, sxp);
  125:  #endif
  126:  
  127: -	change_uid = am_root && uid_ndx && sxp->st.st_uid != (uid_t)F_OWNER(file);
  128: +	change_uid = am_root && uid_ndx && sxp->st.st_uid != (uid_t)F_OWNER(file)
  129: +		  && !(omit_dir_changes && S_ISDIR(sxp->st.st_mode));
  130:  	change_gid = gid_ndx && !(file->flags & FLAG_SKIP_GROUP)
  131: -		  && sxp->st.st_gid != (gid_t)F_GROUP(file);
  132: +		  && sxp->st.st_gid != (gid_t)F_GROUP(file)
  133: +		  && !(omit_dir_changes && S_ISDIR(sxp->st.st_mode));
  134:  #ifndef CAN_CHOWN_SYMLINK
  135:  	if (S_ISLNK(sxp->st.st_mode)) {
  136:  		;
  137: diff -Nurp a/rsync.1 b/rsync.1
  138: --- a/rsync.1
  139: +++ b/rsync.1
  140: @@ -452,6 +452,7 @@ detailed description below for a complet
  141:  --crtimes, -N            preserve create times (newness)
  142:  --omit-dir-times, -O     omit directories from --times
  143:  --omit-link-times, -J    omit symlinks from --times
  144: +--omit-dir-changes       omit directories from any attribute changes
  145:  --super                  receiver attempts super-user activities
  146:  --fake-super             store/recover privileged attrs using xattrs
  147:  --sparse, -S             turn sequences of nulls into sparse blocks
  148: @@ -1473,6 +1474,9 @@ these partially-finished directories.
  149:  .IP "\fB\-\-omit-link-times\fP, \fB\-J\fP"
  150:  This tells rsync to omit symlinks when it is preserving modification times
  151:  (see \fB\-\-times\fP).
  152: +.IP "\fB\-\-omit-dir-changes\fP"
  153: +This tells rsync to omit directories when applying any preserved attributes
  154: +(owner, group, times, permissions) to already existing directories.
  155:  .IP "\fB\-\-super\fP"
  156:  This tells the receiving side to attempt super-user activities even if the
  157:  receiving rsync wasn't run by the super-user.  These activities include:
  158: diff -Nurp a/rsync.1.html b/rsync.1.html
  159: --- a/rsync.1.html
  160: +++ b/rsync.1.html
  161: @@ -367,6 +367,7 @@ detailed description below for a complet
  162:  --crtimes, -N            preserve create times (newness)
  163:  --omit-dir-times, -O     omit directories from --times
  164:  --omit-link-times, -J    omit symlinks from --times
  165: +--omit-dir-changes       omit directories from any attribute changes
  166:  --super                  receiver attempts super-user activities
  167:  --fake-super             store/recover privileged attrs using xattrs
  168:  --sparse, -S             turn sequences of nulls into sparse blocks
  169: @@ -1354,6 +1355,11 @@ these partially-finished directories.</p
  170:  (see <code>--times</code>).</p>
  171:  </dd>
  172:  
  173: +<dt><code>--omit-dir-changes</code></dt><dd>
  174: +<p>This tells rsync to omit directories when applying any preserved attributes
  175: +(owner, group, times, permissions) to already existing directories.</p>
  176: +</dd>
  177: +
  178:  <dt><code>--super</code></dt><dd>
  179:  <p>This tells the receiving side to attempt super-user activities even if the
  180:  receiving rsync wasn't run by the super-user.  These activities include:

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>