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