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 | |
ffc18846 | 12 | @@ -45,6 +45,7 @@ extern int preserve_uid; |
59d64e0b WD |
13 | extern int preserve_gid; |
14 | extern int preserve_times; | |
15 | extern int omit_dir_times; | |
16 | +extern int omit_dir_changes; | |
17 | extern int delete_mode; | |
18 | extern int delete_before; | |
19 | extern int delete_during; | |
ffc18846 | 20 | @@ -554,10 +555,11 @@ void itemize(const char *fname, struct f |
59d64e0b | 21 | iflags |= ITEM_REPORT_TIME; |
ffc18846 | 22 | if (!BITS_EQUAL(sxp->st.st_mode, file->mode, CHMOD_BITS)) |
59d64e0b | 23 | iflags |= ITEM_REPORT_PERMS; |
ffc18846 WD |
24 | - if (preserve_uid && am_root && F_UID(file) != sxp->st.st_uid) |
25 | + if (preserve_uid && am_root && F_UID(file) != sxp->st.st_uid | |
26 | + && !(omit_dir_changes && S_ISDIR(sxp->st.st_mode))) | |
59d64e0b | 27 | iflags |= ITEM_REPORT_OWNER; |
70891d26 | 28 | - if (preserve_gid && F_GID(file) != GID_NONE |
ffc18846 WD |
29 | - && sxp->st.st_gid != F_GID(file)) |
30 | + if (preserve_gid && F_GID(file) != GID_NONE && sxp->st.st_gid != F_GID(file) | |
31 | + && !(omit_dir_changes && S_ISDIR(sxp->st.st_mode))) | |
59d64e0b | 32 | iflags |= ITEM_REPORT_GROUP; |
ffc18846 WD |
33 | #ifdef SUPPORT_ACLS |
34 | if (preserve_acls && !S_ISLNK(file->mode)) { | |
35 | @@ -1193,7 +1195,7 @@ static void recv_generator(char *fname, | |
2f999b32 WD |
36 | statret = -1; |
37 | new_root_dir = 0; | |
38 | } | |
39 | - if (!preserve_perms) { /* See comment in non-dir code below. */ | |
40 | + if (!preserve_perms || omit_dir_changes) { /* See comment in non-dir code below. */ | |
ffc18846 WD |
41 | file->mode = dest_mode(file->mode, sx.st.st_mode, |
42 | dflt_perms, statret == 0); | |
2f999b32 | 43 | } |
59d64e0b WD |
44 | --- old/options.c |
45 | +++ new/options.c | |
ffc18846 | 46 | @@ -55,6 +55,7 @@ int preserve_uid = 0; |
59d64e0b WD |
47 | int preserve_gid = 0; |
48 | int preserve_times = 0; | |
49 | int omit_dir_times = 0; | |
50 | +int omit_dir_changes = 0; | |
51 | int update_only = 0; | |
52 | int cvs_exclude = 0; | |
53 | int dry_run = 0; | |
ffc18846 | 54 | @@ -317,6 +318,7 @@ void usage(enum logcode F) |
59d64e0b WD |
55 | rprintf(F," -D same as --devices --specials\n"); |
56 | rprintf(F," -t, --times preserve times\n"); | |
57 | rprintf(F," -O, --omit-dir-times omit directories when preserving times\n"); | |
58 | + rprintf(F," --omit-dir-changes omit directories when preserving any attributes\n"); | |
59 | rprintf(F," --super receiver attempts super-user activities\n"); | |
60 | rprintf(F," -S, --sparse handle sparse files efficiently\n"); | |
61 | rprintf(F," -n, --dry-run show what would have been transferred\n"); | |
ffc18846 | 62 | @@ -437,6 +439,7 @@ static struct poptOption long_options[] |
59d64e0b WD |
63 | {"no-times", 0, POPT_ARG_VAL, &preserve_times, 0, 0, 0 }, |
64 | {"no-t", 0, POPT_ARG_VAL, &preserve_times, 0, 0, 0 }, | |
65 | {"omit-dir-times", 'O', POPT_ARG_VAL, &omit_dir_times, 2, 0, 0 }, | |
66 | + {"omit-dir-changes", 0, POPT_ARG_NONE, &omit_dir_changes, 0, 0, 0 }, | |
67 | {"modify-window", 0, 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 }, | |
ffc18846 | 70 | @@ -1322,6 +1325,9 @@ int parse_arguments(int *argc, const cha |
59d64e0b | 71 | "P *%s", backup_suffix); |
ffc18846 | 72 | parse_rule(&filter_list, backup_dir_buf, 0, 0); |
59d64e0b WD |
73 | } |
74 | + | |
75 | + if (omit_dir_changes) | |
76 | + omit_dir_times = 2; | |
77 | if (make_backups && !backup_dir) | |
78 | omit_dir_times = 1; | |
79 | ||
ffc18846 | 80 | @@ -1551,6 +1557,8 @@ void server_options(char **args,int *arg |
59d64e0b WD |
81 | argstr[x++] = 'm'; |
82 | if (omit_dir_times == 2) | |
83 | argstr[x++] = 'O'; | |
84 | + if (omit_dir_changes == 1) | |
85 | + args[ac++] = "--omit-dir-changes"; | |
86 | } else { | |
87 | if (copy_links) | |
88 | argstr[x++] = 'L'; | |
59d64e0b WD |
89 | --- old/rsync.c |
90 | +++ new/rsync.c | |
ffc18846 | 91 | @@ -36,6 +36,7 @@ extern int preserve_perms; |
59d64e0b WD |
92 | extern int preserve_executability; |
93 | extern int preserve_times; | |
94 | extern int omit_dir_times; | |
95 | +extern int omit_dir_changes; | |
96 | extern int am_root; | |
97 | extern int am_server; | |
98 | extern int am_sender; | |
ffc18846 | 99 | @@ -275,9 +276,11 @@ int set_file_attrs(char *fname, struct f |
59d64e0b WD |
100 | updated = 1; |
101 | } | |
102 | ||
ffc18846 WD |
103 | - change_uid = am_root && preserve_uid && sxp->st.st_uid != F_UID(file); |
104 | + change_uid = am_root && preserve_uid && sxp->st.st_uid != F_UID(file) | |
105 | + && !(omit_dir_changes && S_ISDIR(sxp->st.st_mode)); | |
70891d26 | 106 | change_gid = preserve_gid && F_GID(file) != GID_NONE |
ffc18846 WD |
107 | - && sxp->st.st_gid != F_GID(file); |
108 | + && sxp->st.st_gid != F_GID(file) | |
109 | + && !(omit_dir_changes && S_ISDIR(sxp->st.st_mode)); | |
59d64e0b | 110 | #if !defined HAVE_LCHOWN && !defined CHOWN_MODIFIES_SYMLINK |
ffc18846 | 111 | if (S_ISLNK(sxp->st.st_mode)) |
59d64e0b | 112 | ; |