Commit | Line | Data |
---|---|---|
59d64e0b WD |
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 | ||
03019e41 WD |
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 | ||
59d64e0b WD |
10 | --- old/generator.c |
11 | +++ new/generator.c | |
a54a2c4d WD |
12 | @@ -43,6 +43,7 @@ extern int preserve_specials; |
13 | extern int preserve_hard_links; | |
898a2112 | 14 | extern int preserve_perms; |
59d64e0b | 15 | extern int preserve_times; |
59d64e0b | 16 | +extern int omit_dir_changes; |
898a2112 WD |
17 | extern int uid_ndx; |
18 | extern int gid_ndx; | |
59d64e0b | 19 | extern int delete_mode; |
f2acdf8c | 20 | @@ -554,6 +555,7 @@ void itemize(const char *fnamecmp, struc |
eab3568b | 21 | int keep_time = !preserve_times ? 0 |
a54a2c4d | 22 | : S_ISDIR(file->mode) ? preserve_times > 1 |
eab3568b WD |
23 | : !S_ISLNK(file->mode); |
24 | + int omit_changes = omit_dir_changes && S_ISDIR(sxp->st.st_mode); | |
25 | ||
26 | if (S_ISREG(file->mode) && F_LENGTH(file) != sxp->st.st_size) | |
27 | iflags |= ITEM_REPORT_SIZE; | |
6af518aa WD |
28 | @@ -569,10 +571,11 @@ void itemize(const char *fnamecmp, struc |
29 | #endif | |
ffc18846 | 30 | if (!BITS_EQUAL(sxp->st.st_mode, file->mode, CHMOD_BITS)) |
59d64e0b | 31 | iflags |= ITEM_REPORT_PERMS; |
898a2112 WD |
32 | - if (uid_ndx && am_root && (uid_t)F_OWNER(file) != sxp->st.st_uid) |
33 | + if (uid_ndx && am_root && !omit_changes | |
19036ed8 | 34 | + && (uid_t)F_OWNER(file) != sxp->st.st_uid) |
59d64e0b | 35 | iflags |= ITEM_REPORT_OWNER; |
898a2112 | 36 | - if (gid_ndx && !(file->flags & FLAG_SKIP_GROUP) |
19036ed8 | 37 | - && sxp->st.st_gid != (gid_t)F_GROUP(file)) |
898a2112 | 38 | + if (gid_ndx && !omit_changes |
30c5d6b4 | 39 | + && !(file->flags & FLAG_SKIP_GROUP) && sxp->st.st_gid != (gid_t)F_GROUP(file)) |
59d64e0b | 40 | iflags |= ITEM_REPORT_GROUP; |
ffc18846 WD |
41 | #ifdef SUPPORT_ACLS |
42 | if (preserve_acls && !S_ISLNK(file->mode)) { | |
6af518aa | 43 | @@ -1288,7 +1291,7 @@ static void recv_generator(char *fname, |
f2acdf8c WD |
44 | real_sx = sx; |
45 | if (file->flags & FLAG_DIR_CREATED) | |
46 | statret = -1; | |
2f999b32 WD |
47 | - if (!preserve_perms) { /* See comment in non-dir code below. */ |
48 | + if (!preserve_perms || omit_dir_changes) { /* See comment in non-dir code below. */ | |
ffc18846 WD |
49 | file->mode = dest_mode(file->mode, sx.st.st_mode, |
50 | dflt_perms, statret == 0); | |
2f999b32 | 51 | } |
59d64e0b WD |
52 | --- old/options.c |
53 | +++ new/options.c | |
6af518aa | 54 | @@ -57,6 +57,7 @@ int preserve_specials = 0; |
a54a2c4d | 55 | int preserve_uid = 0; |
59d64e0b WD |
56 | int preserve_gid = 0; |
57 | int preserve_times = 0; | |
59d64e0b WD |
58 | +int omit_dir_changes = 0; |
59 | int update_only = 0; | |
60 | int cvs_exclude = 0; | |
61 | int dry_run = 0; | |
6af518aa | 62 | @@ -346,6 +347,7 @@ void usage(enum logcode F) |
59d64e0b | 63 | rprintf(F," -D same as --devices --specials\n"); |
671e613f WD |
64 | rprintf(F," -t, --times preserve modification times\n"); |
65 | rprintf(F," -O, --omit-dir-times omit directories from --times\n"); | |
6af518aa | 66 | + rprintf(F," --omit-dir-changes omit directories from any attribute changes\n"); |
59d64e0b | 67 | rprintf(F," --super receiver attempts super-user activities\n"); |
8f0fca7a WD |
68 | #ifdef SUPPORT_XATTRS |
69 | rprintf(F," --fake-super store/recover privileged attrs using xattrs\n"); | |
6af518aa | 70 | @@ -483,6 +485,7 @@ static struct poptOption long_options[] |
a54a2c4d WD |
71 | {"omit-dir-times", 'O', POPT_ARG_VAL, &omit_dir_times, 1, 0, 0 }, |
72 | {"no-omit-dir-times",0, POPT_ARG_VAL, &omit_dir_times, 0, 0, 0 }, | |
73 | {"no-O", 0, POPT_ARG_VAL, &omit_dir_times, 0, 0, 0 }, | |
59d64e0b WD |
74 | + {"omit-dir-changes", 0, POPT_ARG_NONE, &omit_dir_changes, 0, 0, 0 }, |
75 | {"modify-window", 0, POPT_ARG_INT, &modify_window, OPT_MODIFY_WINDOW, 0, 0 }, | |
76 | {"super", 0, POPT_ARG_VAL, &am_root, 2, 0, 0 }, | |
77 | {"no-super", 0, POPT_ARG_VAL, &am_root, 0, 0, 0 }, | |
6af518aa WD |
78 | @@ -1451,6 +1454,8 @@ int parse_arguments(int *argc_p, const c |
79 | parse_rule(&filter_list, backup_dir_buf, 0, 0); | |
59d64e0b | 80 | } |
59d64e0b | 81 | |
a54a2c4d WD |
82 | + if (omit_dir_changes) |
83 | + omit_dir_times = 1; | |
84 | if (make_backups && !backup_dir) { | |
85 | omit_dir_times = 0; /* Implied, so avoid -O to sender. */ | |
86 | if (preserve_times > 1) | |
6af518aa | 87 | @@ -1687,6 +1692,8 @@ void server_options(char **args, int *ar |
59d64e0b | 88 | argstr[x++] = 'm'; |
a54a2c4d | 89 | if (omit_dir_times) |
59d64e0b WD |
90 | argstr[x++] = 'O'; |
91 | + if (omit_dir_changes == 1) | |
92 | + args[ac++] = "--omit-dir-changes"; | |
93 | } else { | |
94 | if (copy_links) | |
95 | argstr[x++] = 'L'; | |
59d64e0b WD |
96 | --- old/rsync.c |
97 | +++ new/rsync.c | |
6af518aa | 98 | @@ -34,6 +34,7 @@ extern int preserve_xattrs; |
a54a2c4d | 99 | extern int preserve_perms; |
59d64e0b WD |
100 | extern int preserve_executability; |
101 | extern int preserve_times; | |
59d64e0b WD |
102 | +extern int omit_dir_changes; |
103 | extern int am_root; | |
104 | extern int am_server; | |
105 | extern int am_sender; | |
6af518aa | 106 | @@ -397,9 +398,11 @@ int set_file_attrs(const char *fname, st |
59d64e0b WD |
107 | updated = 1; |
108 | } | |
109 | ||
898a2112 WD |
110 | - change_uid = am_root && uid_ndx && sxp->st.st_uid != (uid_t)F_OWNER(file); |
111 | + change_uid = am_root && uid_ndx && sxp->st.st_uid != (uid_t)F_OWNER(file) | |
8f0fca7a | 112 | + && !(omit_dir_changes && S_ISDIR(sxp->st.st_mode)); |
898a2112 | 113 | change_gid = gid_ndx && !(file->flags & FLAG_SKIP_GROUP) |
19036ed8 WD |
114 | - && sxp->st.st_gid != (gid_t)F_GROUP(file); |
115 | + && sxp->st.st_gid != (gid_t)F_GROUP(file) | |
8f0fca7a | 116 | + && !(omit_dir_changes && S_ISDIR(sxp->st.st_mode)); |
59d64e0b | 117 | #if !defined HAVE_LCHOWN && !defined CHOWN_MODIFIES_SYMLINK |
6af518aa | 118 | if (S_ISLNK(sxp->st.st_mode)) { |
59d64e0b | 119 | ; |
6af518aa WD |
120 | --- old/rsync.yo |
121 | +++ new/rsync.yo | |
122 | @@ -349,6 +349,7 @@ to the detailed description below for a | |
123 | -D same as --devices --specials | |
124 | -t, --times preserve modification times | |
125 | -O, --omit-dir-times omit directories from --times | |
126 | + --omit-dir-changes omit directories from any attribute changes | |
127 | --super receiver attempts super-user activities | |
128 | --fake-super store/recover privileged attrs using xattrs | |
129 | -S, --sparse handle sparse files efficiently | |
130 | @@ -965,6 +966,10 @@ it is preserving modification times (see | |
131 | the directories on the receiving side, it is a good idea to use bf(-O). | |
132 | This option is inferred if you use bf(--backup) without bf(--backup-dir). | |
133 | ||
134 | +dit(bf(--omit-dir-changes)) This tells rsync to omit directories when applying | |
135 | +any preserved attributes (owner, group, times, permissions) to already existing | |
136 | +directories. | |
137 | + | |
138 | dit(bf(--super)) This tells the receiving side to attempt super-user | |
139 | activities even if the receiving rsync wasn't run by the super-user. These | |
140 | activities include: preserving users via the bf(--owner) option, preserving |