Renamed flags.diff fileflags.diff.
[rsync/rsync-patches.git] / fileflags.diff
... / ...
CommitLineData
1This patch provides --fileflags, which preserves the st_flags stat() field.
2Modified from a patch that was written by Rolf Grossmann.
3
4To use this patch, run these commands for a successful build:
5
6 patch -p1 <patches/flags.diff
7 ./prepare-source
8 ./configure
9 make
10
11diff --git a/compat.c b/compat.c
12--- a/compat.c
13+++ b/compat.c
14@@ -44,6 +44,7 @@ extern int protocol_version;
15 extern int protect_args;
16 extern int preserve_uid;
17 extern int preserve_gid;
18+extern int preserve_fileflags;
19 extern int preserve_acls;
20 extern int preserve_xattrs;
21 extern int need_messages_from_generator;
22@@ -60,7 +61,7 @@ extern iconv_t ic_send, ic_recv;
23 #endif
24
25 /* These index values are for the file-list's extra-attribute array. */
26-int uid_ndx, gid_ndx, acls_ndx, xattrs_ndx, unsort_ndx;
27+int uid_ndx, gid_ndx, fileflags_ndx, acls_ndx, xattrs_ndx, unsort_ndx;
28
29 int receiver_symlink_times = 0; /* receiver can set the time on a symlink */
30
31@@ -134,6 +135,8 @@ void setup_protocol(int f_out,int f_in)
32 uid_ndx = ++file_extra_cnt;
33 if (preserve_gid)
34 gid_ndx = ++file_extra_cnt;
35+ if (preserve_fileflags)
36+ fileflags_ndx = ++file_extra_cnt;
37 if (preserve_acls && !am_sender)
38 acls_ndx = ++file_extra_cnt;
39 if (preserve_xattrs)
40diff --git a/configure.in b/configure.in
41--- a/configure.in
42+++ b/configure.in
43@@ -551,7 +551,7 @@ AC_CHECK_FUNCS(waitpid wait4 getcwd strdup chown chmod lchmod mknod mkfifo \
44 memmove lchown vsnprintf snprintf vasprintf asprintf setsid glob strpbrk \
45 strlcat strlcpy strtol mallinfo getgroups setgroups geteuid getegid \
46 setlocale setmode open64 lseek64 mkstemp64 mtrace va_copy __va_copy \
47- strerror putenv iconv_open locale_charset nl_langinfo getxattr \
48+ chflags strerror putenv iconv_open locale_charset nl_langinfo getxattr \
49 extattr_get_link sigaction sigprocmask setattrlist)
50
51 dnl cygwin iconv.h defines iconv_open as libiconv_open
52diff --git a/flist.c b/flist.c
53--- a/flist.c
54+++ b/flist.c
55@@ -50,6 +50,7 @@ extern int preserve_links;
56 extern int preserve_hard_links;
57 extern int preserve_devices;
58 extern int preserve_specials;
59+extern int fileflags_ndx;
60 extern int uid_ndx;
61 extern int gid_ndx;
62 extern int eol_nulls;
63@@ -344,6 +345,9 @@ static void send_file_entry(int f, struct file_struct *file, int ndx, int first_
64 {
65 static time_t modtime;
66 static mode_t mode;
67+#ifdef SUPPORT_FLAGS
68+ static uint32 fileflags;
69+#endif
70 #ifdef SUPPORT_HARD_LINKS
71 static int64 dev;
72 #endif
73@@ -403,6 +407,14 @@ static void send_file_entry(int f, struct file_struct *file, int ndx, int first_
74 xflags |= XMIT_SAME_MODE;
75 else
76 mode = file->mode;
77+#ifdef SUPPORT_FLAGS
78+ if (fileflags_ndx) {
79+ if (F_FFLAGS(file) == fileflags)
80+ xflags |= XMIT_SAME_FLAGS;
81+ else
82+ fileflags = F_FFLAGS(file);
83+ }
84+#endif
85
86 if ((preserve_devices && IS_DEVICE(mode))
87 || (preserve_specials && IS_SPECIAL(mode))) {
88@@ -522,6 +534,10 @@ static void send_file_entry(int f, struct file_struct *file, int ndx, int first_
89 }
90 if (!(xflags & XMIT_SAME_MODE))
91 write_int(f, to_wire_mode(mode));
92+#ifdef SUPPORT_FLAGS
93+ if (fileflags_ndx && !(xflags & XMIT_SAME_FLAGS))
94+ write_int(f, (int)fileflags);
95+#endif
96 if (uid_ndx && !(xflags & XMIT_SAME_UID)) {
97 if (protocol_version < 30)
98 write_int(f, uid);
99@@ -610,6 +626,9 @@ static struct file_struct *recv_file_entry(struct file_list *flist,
100 {
101 static int64 modtime;
102 static mode_t mode;
103+#ifdef SUPPORT_FLAGS
104+ static uint32 fileflags;
105+#endif
106 #ifdef SUPPORT_HARD_LINKS
107 static int64 dev;
108 #endif
109@@ -744,6 +763,10 @@ static struct file_struct *recv_file_entry(struct file_list *flist,
110
111 if (chmod_modes && !S_ISLNK(mode))
112 mode = tweak_mode(mode, chmod_modes);
113+#ifdef SUPPORT_FLAGS
114+ if (fileflags_ndx && !(xflags & XMIT_SAME_FLAGS))
115+ fileflags = (uint32)read_int(f);
116+#endif
117
118 if (uid_ndx && !(xflags & XMIT_SAME_UID)) {
119 if (protocol_version < 30)
120@@ -865,6 +888,10 @@ static struct file_struct *recv_file_entry(struct file_list *flist,
121 OPT_EXTRA(file, 0)->unum = (uint32)(file_length >> 32);
122 }
123 file->mode = mode;
124+#ifdef SUPPORT_FLAGS
125+ if (fileflags_ndx)
126+ F_FFLAGS(file) = fileflags;
127+#endif
128 if (uid_ndx)
129 F_OWNER(file) = uid;
130 if (gid_ndx) {
131@@ -1199,6 +1226,10 @@ struct file_struct *make_file(const char *fname, struct file_list *flist,
132 OPT_EXTRA(file, 0)->unum = (uint32)(st.st_size >> 32);
133 }
134 file->mode = st.st_mode;
135+#ifdef SUPPORT_FLAGS
136+ if (fileflags_ndx)
137+ F_FFLAGS(file) = st.st_flags;
138+#endif
139 if (uid_ndx)
140 F_OWNER(file) = st.st_uid;
141 if (gid_ndx)
142diff --git a/generator.c b/generator.c
143--- a/generator.c
144+++ b/generator.c
145@@ -124,6 +124,7 @@ static const char *solo_file = NULL;
146 #define DEL_FOR_SYMLINK (1<<5) /* making room for a replacement symlink */
147 #define DEL_FOR_DEVICE (1<<6) /* making room for a replacement device */
148 #define DEL_FOR_SPECIAL (1<<7) /* making room for a replacement special */
149+#define DEL_AN_IMMUTABLE (1<<8) /* item has an immutable flag set */
150
151 #define DEL_MAKE_ROOM (DEL_FOR_FILE|DEL_FOR_DIR|DEL_FOR_SYMLINK|DEL_FOR_DEVICE|DEL_FOR_SPECIAL)
152
153@@ -163,6 +164,10 @@ static enum delret delete_item(char *fbuf, int mode, int flags)
154
155 if (!am_root && !(mode & S_IWUSR) && flags & DEL_OWNED_BY_US)
156 do_chmod(fbuf, mode |= S_IWUSR);
157+#ifdef SUPPORT_FLAGS
158+ if (fileflags_ndx && flags & DEL_AN_IMMUTABLE)
159+ make_mutable(fbuf, mode, NODELETE_FLAGS);
160+#endif
161
162 if (S_ISDIR(mode) && !(flags & DEL_DIR_IS_EMPTY)) {
163 ignore_perishable = 1;
164@@ -284,6 +289,14 @@ static enum delret delete_dir_contents(char *fname, int flags)
165 flags |= DEL_OWNED_BY_US;
166 else
167 flags &= ~DEL_OWNED_BY_US;
168+#ifdef SUPPORT_FLAGS
169+ if (fileflags_ndx) {
170+ if (F_FFLAGS(fp) & NODELETE_FLAGS)
171+ flags |= DEL_AN_IMMUTABLE;
172+ else
173+ flags &= ~DEL_AN_IMMUTABLE;
174+ }
175+#endif
176 /* Save stack by recursing to ourself directly. */
177 if (S_ISDIR(fp->mode)) {
178 if (!am_root && !(fp->mode & S_IWUSR) && flags & DEL_OWNED_BY_US)
179@@ -343,15 +356,22 @@ static int flush_delete_delay(void)
180
181 static int remember_delete(struct file_struct *file, const char *fname, int flags)
182 {
183- const char *plus = (!am_root && !(file->mode & S_IWUSR) && flags & DEL_OWNED_BY_US)
184- ? "+" : "";
185+ char buf[16], *bp = buf;
186 int len;
187
188+ if (!am_root && !(file->mode & S_IWUSR) && flags & DEL_OWNED_BY_US)
189+ *bp++ = '+';
190+#ifdef SUPPORT_FLAGS
191+ if (flags & DEL_AN_IMMUTABLE)
192+ *bp++ = '-';
193+#endif
194+ *bp = '\0';
195+
196 while (1) {
197 len = snprintf(deldelay_buf + deldelay_cnt,
198 deldelay_size - deldelay_cnt,
199 "%s%x %s%c",
200- plus, (int)file->mode, fname, '\0');
201+ buf, (int)file->mode, fname, '\0');
202 if ((deldelay_cnt += len) <= deldelay_size)
203 break;
204 if (deldelay_fd < 0 && !start_delete_delay_temp())
205@@ -364,10 +384,10 @@ static int remember_delete(struct file_struct *file, const char *fname, int flag
206 return 1;
207 }
208
209-static int read_delay_line(char *buf, int *own_flag_p)
210+static int read_delay_line(char *buf, int *flags_p)
211 {
212 static int read_pos = 0;
213- int j, len, mode;
214+ int j, len, mode, flags = 0;
215 char *bp, *past_space;
216
217 while (1) {
218@@ -407,9 +427,15 @@ static int read_delay_line(char *buf, int *own_flag_p)
219 bp = deldelay_buf + read_pos;
220 if (*bp == '+') {
221 bp++;
222- *own_flag_p = DEL_OWNED_BY_US;
223- } else
224- *own_flag_p = 0;
225+ flags |= DEL_OWNED_BY_US;
226+ }
227+#ifdef SUPPORT_FLAGS
228+ if (*bp == '-') {
229+ bp++;
230+ flags |= DEL_AN_IMMUTABLE;
231+ }
232+#endif
233+ *flags_p = flags;
234
235 if (sscanf(bp, "%x ", &mode) != 1) {
236 invalid_data:
237@@ -434,15 +460,15 @@ static int read_delay_line(char *buf, int *own_flag_p)
238
239 static void do_delayed_deletions(char *delbuf)
240 {
241- int mode, own_flag;
242+ int mode, flags;
243
244 if (deldelay_fd >= 0) {
245 if (deldelay_cnt && !flush_delete_delay())
246 return;
247 lseek(deldelay_fd, 0, 0);
248 }
249- while ((mode = read_delay_line(delbuf, &own_flag)) >= 0)
250- delete_item(delbuf, mode, own_flag | DEL_RECURSE);
251+ while ((mode = read_delay_line(delbuf, &flags)) >= 0)
252+ delete_item(delbuf, mode, DEL_RECURSE | flags);
253 if (deldelay_fd >= 0)
254 close(deldelay_fd);
255 }
256@@ -505,6 +531,9 @@ static void delete_in_dir(char *fbuf, struct file_struct *file, dev_t *fs_dev)
257 }
258 if (flist_find(cur_flist, fp) < 0) {
259 int flags = DEL_RECURSE
260+#ifdef SUPPORT_FLAGS
261+ | (fileflags_ndx && F_FFLAGS(fp) & NODELETE_FLAGS ? DEL_AN_IMMUTABLE : 0)
262+#endif
263 | (!uid_ndx || (uid_t)F_OWNER(fp) == our_uid ? DEL_OWNED_BY_US : 0);
264 f_name(fp, delbuf);
265 if (delete_during == 2) {
266@@ -1329,6 +1358,10 @@ static void recv_generator(char *fname, struct file_struct *file, int ndx,
267
268 if (statret == 0 && sx.st.st_uid == our_uid)
269 del_opts |= DEL_OWNED_BY_US;
270+#ifdef SUPPORT_FLAGS
271+ if (statret == 0 && fileflags_ndx && sx.st.st_flags & NODELETE_FLAGS)
272+ del_opts |= DEL_AN_IMMUTABLE;
273+#endif
274
275 if (is_dir) {
276 if (!implied_dirs && file->flags & FLAG_IMPLIED_DIR)
277diff --git a/options.c b/options.c
278--- a/options.c
279+++ b/options.c
280@@ -52,6 +52,7 @@ int preserve_hard_links = 0;
281 int preserve_acls = 0;
282 int preserve_xattrs = 0;
283 int preserve_perms = 0;
284+int preserve_fileflags = 0;
285 int preserve_executability = 0;
286 int preserve_devices = 0;
287 int preserve_specials = 0;
288@@ -224,6 +225,7 @@ static void print_rsync_version(enum logcode f)
289 char const *links = "no ";
290 char const *iconv = "no ";
291 char const *ipv6 = "no ";
292+ char const *fileflags = "no ";
293 STRUCT_STAT *dumstat;
294
295 #if SUBPROTOCOL_VERSION != 0
296@@ -256,6 +258,9 @@ static void print_rsync_version(enum logcode f)
297 #if defined HAVE_LUTIMES && defined HAVE_UTIMES
298 symtimes = "";
299 #endif
300+#ifdef SUPPORT_FLAGS
301+ fileflags = "";
302+#endif
303
304 rprintf(f, "%s version %s protocol version %d%s\n",
305 RSYNC_NAME, RSYNC_VERSION, PROTOCOL_VERSION, subprotocol);
306@@ -269,8 +274,8 @@ static void print_rsync_version(enum logcode f)
307 (int)(sizeof (int64) * 8));
308 rprintf(f, " %ssocketpairs, %shardlinks, %ssymlinks, %sIPv6, batchfiles, %sinplace,\n",
309 got_socketpair, hardlinks, links, ipv6, have_inplace);
310- rprintf(f, " %sappend, %sACLs, %sxattrs, %siconv, %ssymtimes\n",
311- have_inplace, acls, xattrs, iconv, symtimes);
312+ rprintf(f, " %sappend, %sACLs, %sxattrs, %siconv, %ssymtimes, %sfile-flags\n",
313+ have_inplace, acls, xattrs, iconv, symtimes, fileflags);
314
315 #ifdef MAINTAINER_MODE
316 rprintf(f, "Panic Action: \"%s\"\n", get_panic_action());
317@@ -337,6 +342,7 @@ void usage(enum logcode F)
318 rprintf(F," -K, --keep-dirlinks treat symlinked dir on receiver as dir\n");
319 rprintf(F," -H, --hard-links preserve hard links\n");
320 rprintf(F," -p, --perms preserve permissions\n");
321+ rprintf(F," --fileflags preserve file-flags\n");
322 rprintf(F," -E, --executability preserve the file's executability\n");
323 rprintf(F," --chmod=CHMOD affect file and/or directory permissions\n");
324 #ifdef SUPPORT_ACLS
325@@ -477,6 +483,8 @@ static struct poptOption long_options[] = {
326 {"perms", 'p', POPT_ARG_VAL, &preserve_perms, 1, 0, 0 },
327 {"no-perms", 0, POPT_ARG_VAL, &preserve_perms, 0, 0, 0 },
328 {"no-p", 0, POPT_ARG_VAL, &preserve_perms, 0, 0, 0 },
329+ {"fileflags", 0, POPT_ARG_VAL, &preserve_fileflags, 1, 0, 0 },
330+ {"no-fileflags", 0, POPT_ARG_VAL, &preserve_fileflags, 0, 0, 0 },
331 {"executability", 'E', POPT_ARG_NONE, &preserve_executability, 0, 0, 0 },
332 {"acls", 'A', POPT_ARG_NONE, 0, 'A', 0, 0 },
333 {"no-acls", 0, POPT_ARG_VAL, &preserve_acls, 0, 0, 0 },
334@@ -1311,6 +1319,15 @@ int parse_arguments(int *argc_p, const char ***argv_p, int frommain)
335 }
336 #endif
337
338+#ifndef SUPPORT_FLAGS
339+ if (preserve_fileflags) {
340+ snprintf(err_buf, sizeof err_buf,
341+ "the --fileflags option is not supported on this %s\n",
342+ am_server ? "server" : "client");
343+ return 0;
344+ }
345+#endif
346+
347 if (write_batch && read_batch) {
348 snprintf(err_buf, sizeof err_buf,
349 "--write-batch and --read-batch can not be used together\n");
350@@ -1826,6 +1843,9 @@ void server_options(char **args, int *argc_p)
351 if (xfer_dirs && !recurse && delete_mode && am_sender)
352 args[ac++] = "--no-r";
353
354+ if (preserve_fileflags)
355+ args[ac++] = "--fileflags";
356+
357 if (do_compression && def_compress_level != Z_DEFAULT_COMPRESSION) {
358 if (asprintf(&arg, "--compress-level=%d", def_compress_level) < 0)
359 goto oom;
360diff --git a/rsync.c b/rsync.c
361--- a/rsync.c
362+++ b/rsync.c
363@@ -32,6 +32,7 @@ extern int dry_run;
364 extern int preserve_acls;
365 extern int preserve_xattrs;
366 extern int preserve_perms;
367+extern int preserve_fileflags;
368 extern int preserve_executability;
369 extern int preserve_times;
370 extern int am_root;
371@@ -339,6 +340,41 @@ mode_t dest_mode(mode_t flist_mode, mode_t stat_mode, int dflt_perms,
372 return new_mode;
373 }
374
375+#ifdef SUPPORT_FLAGS
376+/* Set a file's st_flags. */
377+static int set_fileflags(const char *fname, uint32 fileflags)
378+{
379+ if (do_chflags(fname, fileflags) != 0) {
380+ rsyserr(FERROR_XFER, errno,
381+ "failed to set file flags on %s",
382+ full_fname(fname));
383+ return 0;
384+ }
385+
386+ return 1;
387+}
388+
389+/* Remove immutable flags from an object, so it can be altered/removed. */
390+void make_mutable(const char *fname, mode_t mode, uint32 fileflags)
391+{
392+ if (S_ISLNK(mode))
393+ return;
394+
395+ if (fileflags & NOCHANGE_FLAGS)
396+ set_fileflags(fname, fileflags & ~NOCHANGE_FLAGS);
397+}
398+
399+/* Undo a prior make_mutable() call. */
400+void undo_make_mutable(const char *fname, mode_t mode, uint32 fileflags)
401+{
402+ if (S_ISLNK(mode))
403+ return;
404+
405+ if (fileflags & NOCHANGE_FLAGS)
406+ set_fileflags(fname, fileflags);
407+}
408+#endif
409+
410 int set_file_attrs(const char *fname, struct file_struct *file, stat_x *sxp,
411 const char *fnamecmp, int flags)
412 {
413@@ -472,6 +508,15 @@ int set_file_attrs(const char *fname, struct file_struct *file, stat_x *sxp,
414 }
415 #endif
416
417+#ifdef SUPPORT_FLAGS
418+ if (preserve_fileflags && !S_ISLNK(sxp->st.st_mode)
419+ && sxp->st.st_flags != F_FFLAGS(file)) {
420+ if (!set_fileflags(fname, F_FFLAGS(file)))
421+ goto cleanup;
422+ updated = 1;
423+ }
424+#endif
425+
426 if (verbose > 1 && flags & ATTRS_REPORT) {
427 if (updated)
428 rprintf(FCLIENT, "%s\n", fname);
429@@ -533,6 +578,10 @@ int finish_transfer(const char *fname, const char *fnametmp,
430 set_file_attrs(fnametmp, file, NULL, fnamecmp,
431 ok_to_set_time ? 0 : ATTRS_SKIP_MTIME);
432
433+#ifdef SUPPORT_FLAGS
434+ if (preserve_fileflags)
435+ make_mutable(fnametmp, file->mode, F_FFLAGS(file));
436+#endif
437 /* move tmp file over real file */
438 if (verbose > 2)
439 rprintf(FINFO, "renaming %s to %s\n", fnametmp, fname);
440@@ -550,6 +599,10 @@ int finish_transfer(const char *fname, const char *fnametmp,
441 }
442 if (ret == 0) {
443 /* The file was moved into place (not copied), so it's done. */
444+#ifdef SUPPORT_FLAGS
445+ if (preserve_fileflags)
446+ undo_make_mutable(fname, file->mode, F_FFLAGS(file));
447+#endif
448 return 1;
449 }
450 /* The file was copied, so tweak the perms of the copied file. If it
451diff --git a/rsync.h b/rsync.h
452--- a/rsync.h
453+++ b/rsync.h
454@@ -60,6 +60,7 @@
455 #define XMIT_RDEV_MINOR_8_pre30 (1<<11) /* protocols 28 - 29 */
456 #define XMIT_GROUP_NAME_FOLLOWS (1<<11) /* protocols 30 - now */
457 #define XMIT_HLINK_FIRST (1<<12) /* protocols 30 - now (HLINKED files only) */
458+#define XMIT_SAME_FLAGS (1<<14) /* protocols ?? - now */
459
460 /* These flags are used in the live flist data. */
461
462@@ -452,6 +453,21 @@ typedef unsigned int size_t;
463 #endif
464 #endif
465
466+#ifdef HAVE_CHFLAGS
467+#define SUPPORT_FLAGS 1
468+#endif
469+
470+#ifdef SUPPORT_FLAGS
471+#ifndef UF_NOUNLINK
472+#define UF_NOUNLINK 0
473+#endif
474+#ifndef SF_NOUNLINK
475+#define SF_NOUNLINK 0
476+#endif
477+#define NODELETE_FLAGS (UF_IMMUTABLE|UF_NOUNLINK|SF_IMMUTABLE|SF_NOUNLINK)
478+#define NOCHANGE_FLAGS (NODELETE_FLAGS|UF_APPEND|SF_APPEND)
479+#endif
480+
481 /* Find a variable that is either exactly 32-bits or longer.
482 * If some code depends on 32-bit truncation, it will need to
483 * take special action in a "#if SIZEOF_INT32 > 4" section. */
484@@ -620,6 +636,7 @@ extern int file_extra_cnt;
485 extern int inc_recurse;
486 extern int uid_ndx;
487 extern int gid_ndx;
488+extern int fileflags_ndx;
489 extern int acls_ndx;
490 extern int xattrs_ndx;
491
492@@ -657,6 +674,7 @@ extern int xattrs_ndx;
493 /* When the associated option is on, all entries will have these present: */
494 #define F_OWNER(f) REQ_EXTRA(f, uid_ndx)->unum
495 #define F_GROUP(f) REQ_EXTRA(f, gid_ndx)->unum
496+#define F_FFLAGS(f) REQ_EXTRA(f, fileflags_ndx)->unum
497 #define F_ACL(f) REQ_EXTRA(f, acls_ndx)->num
498 #define F_XATTR(f) REQ_EXTRA(f, xattrs_ndx)->num
499 #define F_NDX(f) REQ_EXTRA(f, unsort_ndx)->num
500diff --git a/rsync.yo b/rsync.yo
501--- a/rsync.yo
502+++ b/rsync.yo
503@@ -338,6 +338,7 @@ to the detailed description below for a complete description. verb(
504 -K, --keep-dirlinks treat symlinked dir on receiver as dir
505 -H, --hard-links preserve hard links
506 -p, --perms preserve permissions
507+ --fileflags preserve file-flags
508 -E, --executability preserve executability
509 --chmod=CHMOD affect file and/or directory permissions
510 -A, --acls preserve ACLs (implies -p)
511@@ -540,7 +541,8 @@ specified, in which case bf(-r) is not implied.
512
513 Note that bf(-a) bf(does not preserve hardlinks), because
514 finding multiply-linked files is expensive. You must separately
515-specify bf(-H).
516+specify bf(-H). Note also that for backward compatibility, bf(-a)
517+currently does bf(not) imply the bf(--fileflags) option.
518
519 dit(--no-OPTION) You may turn off one or more implied options by prefixing
520 the option name with "no-". Not all options may be prefixed with a "no-":
521@@ -922,6 +924,13 @@ super-user copies all namespaces except system.*. A normal user only copies
522 the user.* namespace. To be able to backup and restore non-user namespaces as
523 a normal user, see the bf(--fake-super) option.
524
525+dit(bf(--fileflags)) This option causes rsync to update the file-flags
526+to be the same as the source file, if your OS supports the bf(chflags)(2)
527+system call. In any case, an attempt is made to remove flags that would
528+prevent a file to be altered. Some flags can only be altered by the
529+super-user and can only be unset below a certain secure-level (usually
530+single-user mode).
531+
532 dit(bf(--chmod)) This option tells rsync to apply one or more
533 comma-separated "chmod" strings to the permission of the files in the
534 transfer. The resulting value is treated as though it was the permissions
535diff --git a/syscall.c b/syscall.c
536--- a/syscall.c
537+++ b/syscall.c
538@@ -174,6 +174,15 @@ int do_chmod(const char *path, mode_t mode)
539 }
540 #endif
541
542+#ifdef SUPPORT_FLAGS
543+int do_chflags(const char *path, u_long flags)
544+{
545+ if (dry_run) return 0;
546+ RETURN_ERROR_IF_RO_OR_LO;
547+ return chflags(path, flags);
548+}
549+#endif
550+
551 int do_rename(const char *fname1, const char *fname2)
552 {
553 if (dry_run) return 0;