Fixed failing hunks.
[rsync/rsync-patches.git] / flags.diff
1 This patch provides --flags, which preserves the st_flags field.
2 Modified from a patch that was written by Rolf Grossmann.
3
4 To 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
11 TODO: fix --delete-delay to work with --flags option.
12
13 --- old/compat.c
14 +++ new/compat.c
15 @@ -62,6 +62,8 @@ void setup_protocol(int f_out,int f_in)
16                 preserve_uid = ++file_extra_cnt;
17         if (preserve_gid)
18                 preserve_gid = ++file_extra_cnt;
19 +       if (preserve_fileflags)
20 +               preserve_fileflags = ++file_extra_cnt;
21         if (preserve_acls && !am_sender)
22                 preserve_acls = ++file_extra_cnt;
23  
24 --- old/configure.in
25 +++ new/configure.in
26 @@ -559,7 +559,7 @@ AC_CHECK_FUNCS(waitpid wait4 getcwd strd
27      memmove lchown vsnprintf snprintf vasprintf asprintf setsid glob strpbrk \
28      strlcat strlcpy strtol mallinfo getgroups setgroups geteuid getegid \
29      setlocale setmode open64 lseek64 mkstemp64 mtrace va_copy __va_copy \
30 -    strerror putenv iconv_open locale_charset nl_langinfo \
31 +    chflags strerror putenv iconv_open locale_charset nl_langinfo \
32      sigaction sigprocmask)
33  
34  AC_CHECK_FUNCS(getpgrp tcgetpgrp)
35 --- old/flist.c
36 +++ new/flist.c
37 @@ -47,6 +47,7 @@ extern int preserve_links;
38  extern int preserve_hard_links;
39  extern int preserve_devices;
40  extern int preserve_specials;
41 +extern int preserve_fileflags;
42  extern int preserve_uid;
43  extern int preserve_gid;
44  extern int relative_paths;
45 @@ -350,6 +351,9 @@ static void send_file_entry(int f, struc
46  {
47         static time_t modtime;
48         static mode_t mode;
49 +#ifdef SUPPORT_FLAGS
50 +       static uint32 fileflags;
51 +#endif
52         static int64 dev;
53         static dev_t rdev;
54         static uint32 rdev_major;
55 @@ -370,6 +374,12 @@ static void send_file_entry(int f, struc
56                 flags |= XMIT_SAME_MODE;
57         else
58                 mode = file->mode;
59 +#ifdef SUPPORT_FLAGS
60 +       if (file->fileflags == fileflags)
61 +               flags |= XMIT_SAME_FLAGS;
62 +       else
63 +               fileflags = file->fileflags;
64 +#endif
65         if ((preserve_devices && IS_DEVICE(mode))
66          || (preserve_specials && IS_SPECIAL(mode))) {
67                 if (protocol_version < 28) {
68 @@ -483,6 +493,10 @@ static void send_file_entry(int f, struc
69                 write_int(f, modtime);
70         if (!(flags & XMIT_SAME_MODE))
71                 write_int(f, to_wire_mode(mode));
72 +#ifdef SUPPORT_FLAGS
73 +       if (preserve_fileflags && !(flags & XMIT_SAME_FLAGS))
74 +               write_int(f, (int)fileflags);
75 +#endif
76         if (preserve_uid && !(flags & XMIT_SAME_UID)) {
77                 if (protocol_version < 30)
78                         write_int(f, uid);
79 @@ -571,6 +585,9 @@ static struct file_struct *recv_file_ent
80  {
81         static time_t modtime;
82         static mode_t mode;
83 +#ifdef SUPPORT_FLAGS
84 +       static uint32 fileflags;
85 +#endif
86         static int64 dev;
87         static dev_t rdev;
88         static uint32 rdev_major;
89 @@ -667,9 +684,12 @@ static struct file_struct *recv_file_ent
90                 modtime = (time_t)read_int(f);
91         if (!(flags & XMIT_SAME_MODE))
92                 mode = from_wire_mode(read_int(f));
93 -
94         if (chmod_modes && !S_ISLNK(mode))
95                 mode = tweak_mode(mode, chmod_modes);
96 +#ifdef SUPPORT_FLAGS
97 +       if (preserve_fileflags && !(flags & XMIT_SAME_FLAGS))
98 +               fileflags = (uint32)read_int(f);
99 +#endif
100  
101         if (preserve_uid && !(flags & XMIT_SAME_UID)) {
102                 if (protocol_version < 30)
103 @@ -787,6 +807,10 @@ static struct file_struct *recv_file_ent
104                 OPT_EXTRA(file, 0)->unum = (uint32)(file_length >> 32);
105         }
106         file->mode = mode;
107 +#ifdef SUPPORT_FLAGS
108 +       if (preserve_fileflags)
109 +               F_FFLAGS(file) = fileflags;
110 +#endif
111         if (preserve_uid)
112                 F_OWNER(file) = uid;
113         if (preserve_gid)
114 @@ -1092,6 +1116,10 @@ struct file_struct *make_file(const char
115                 OPT_EXTRA(file, 0)->unum = (uint32)(st.st_size >> 32);
116         }
117         file->mode = st.st_mode;
118 +#ifdef SUPPORT_FLAGS
119 +       if (preserve_fileflags)
120 +               F_FFLAGS(file) = st.st_flags;
121 +#endif
122         if (preserve_uid)
123                 F_OWNER(file) = st.st_uid;
124         if (preserve_gid)
125 --- old/generator.c
126 +++ new/generator.c
127 @@ -111,6 +111,12 @@ static int dir_tweaking;
128  static int need_retouch_dir_times;
129  static const char *solo_file = NULL;
130  
131 +#ifdef SUPPORT_FLAGS
132 +#define FILEFLAGS(ff) ff
133 +#else
134 +#define FILEFLAGS(ff) 0
135 +#endif
136 +
137  /* For calling delete_item() and delete_dir_contents(). */
138  #define DEL_RECURSE            (1<<1) /* recurse */
139  #define DEL_DIR_IS_EMPTY       (1<<2) /* internal delete_FUNCTIONS use only */
140 @@ -126,7 +132,6 @@ enum delret {
141  /* Forward declaration for delete_item(). */
142  static enum delret delete_dir_contents(char *fname, int flags);
143  
144 -
145  static int is_backup_file(char *fn)
146  {
147         int k = strlen(fn) - backup_suffix_len;
148 @@ -139,17 +144,20 @@ static int is_backup_file(char *fn)
149   * Note that fbuf must point to a MAXPATHLEN buffer if the mode indicates it's
150   * a directory! (The buffer is used for recursion, but returned unchanged.)
151   */
152 -static enum delret delete_item(char *fbuf, int mode, char *replace, int flags)
153 +static enum delret delete_item(char *fbuf, int mode, uint32 fileflags, char *replace, int flags)
154  {
155         enum delret ret;
156         char *what;
157         int ok;
158  
159         if (verbose > 2) {
160 -               rprintf(FINFO, "delete_item(%s) mode=%o flags=%d\n",
161 -                       fbuf, mode, flags);
162 +               rprintf(FINFO, "delete_item(%s) mode=%o fileflags=%o flags=%d\n",
163 +                       fbuf, mode, fileflags, flags);
164         }
165  
166 +#ifdef SUPPORT_FLAGS
167 +       make_mutable(fbuf, mode, fileflags);
168 +#endif
169         if (S_ISDIR(mode) && !(flags & DEL_DIR_IS_EMPTY)) {
170                 ignore_perishable = 1;
171                 /* If DEL_RECURSE is not set, this just reports emptiness. */
172 @@ -261,7 +269,7 @@ static enum delret delete_dir_contents(c
173                 if (S_ISDIR(fp->mode)
174                  && delete_dir_contents(fname, flags | DEL_RECURSE) != DR_SUCCESS)
175                         ret = DR_NOT_EMPTY;
176 -               if (delete_item(fname, fp->mode, NULL, flags) != DR_SUCCESS)
177 +               if (delete_item(fname, fp->mode, FILEFLAGS(fp->fileflags), NULL, flags) != DR_SUCCESS)
178                         ret = DR_NOT_EMPTY;
179         }
180  
181 @@ -317,8 +325,9 @@ static int remember_delete(struct file_s
182         
183         while (1) {
184                 len = snprintf(deldelay_buf + deldelay_cnt,
185 -                              deldelay_size - deldelay_cnt,
186 -                              "%x %s%c", (int)file->mode, fname, '\0');
187 +                              deldelay_size - deldelay_cnt, "%x %x %s%c",
188 +                              (int)file->mode, (int)FILEFLAGS(file->fileflags),
189 +                              fname, '\0');
190                 if ((deldelay_cnt += len) <= deldelay_size)
191                         break;
192                 if (deldelay_fd < 0 && !start_delete_delay_temp())
193 @@ -331,7 +340,7 @@ static int remember_delete(struct file_s
194         return 1;
195  }
196  
197 -static int read_delay_line(char *buf)
198 +static int read_delay_line(char *buf, int *fileflags_p)
199  {
200         static int read_pos = 0;
201         int j, len, mode;
202 @@ -373,7 +382,7 @@ static int read_delay_line(char *buf)
203  
204         bp = deldelay_buf + read_pos;
205  
206 -       if (sscanf(bp, "%x ", &mode) != 1) {
207 +       if (sscanf(bp, "%x %x ", &mode, fileflags_p) != 2) {
208           invalid_data:
209                 rprintf(FERROR, "ERROR: invalid data in delete-delay file.\n");
210                 return -1;
211 @@ -396,15 +405,15 @@ static int read_delay_line(char *buf)
212  
213  static void do_delayed_deletions(char *delbuf)
214  {
215 -       int mode;
216 +       int mode, fileflags;
217  
218         if (deldelay_fd >= 0) {
219                 if (deldelay_cnt && !flush_delete_delay())
220                         return;
221                 lseek(deldelay_fd, 0, 0);
222         }
223 -       while ((mode = read_delay_line(delbuf)) >= 0)
224 -               delete_item(delbuf, mode, NULL, DEL_RECURSE);
225 +       while ((mode = read_delay_line(delbuf, &fileflags)) >= 0)
226 +               delete_item(delbuf, mode, fileflags, NULL, DEL_RECURSE);
227         if (deldelay_fd >= 0)
228                 close(deldelay_fd);
229  }
230 @@ -472,7 +481,7 @@ static void delete_in_dir(struct file_li
231                                 if (!remember_delete(fp, delbuf))
232                                         break;
233                         } else
234 -                               delete_item(delbuf, fp->mode, NULL, DEL_RECURSE);
235 +                               delete_item(delbuf, fp->mode, FILEFLAGS(fp->fileflags), NULL, DEL_RECURSE);
236                 }
237         }
238  
239 @@ -1178,7 +1187,7 @@ static void recv_generator(char *fname, 
240                  * we need to delete it.  If it doesn't exist, then
241                  * (perhaps recursively) create it. */
242                 if (statret == 0 && !S_ISDIR(sx.st.st_mode)) {
243 -                       if (delete_item(fname, sx.st.st_mode, "directory", del_opts) != 0)
244 +                       if (delete_item(fname, sx.st.st_mode, FILEFLAGS(sx.st.st_flags), "directory", del_opts) != 0)
245                                 return;
246                         statret = -1;
247                 }
248 @@ -1291,7 +1300,7 @@ static void recv_generator(char *fname, 
249                         }
250                         /* Not the right symlink (or not a symlink), so
251                          * delete it. */
252 -                       if (delete_item(fname, sx.st.st_mode, "symlink", del_opts) != 0)
253 +                       if (delete_item(fname, sx.st.st_mode, FILEFLAGS(sx.st.st_flags), "symlink", del_opts) != 0)
254                                 goto cleanup;
255                 } else if (basis_dir[0] != NULL) {
256                         int j = try_dests_non(file, fname, ndx, fnamecmpbuf, &sx,
257 @@ -1368,7 +1377,7 @@ static void recv_generator(char *fname, 
258                                         goto return_with_success;
259                                 goto cleanup;
260                         }
261 -                       if (delete_item(fname, sx.st.st_mode, t, del_opts) != 0)
262 +                       if (delete_item(fname, sx.st.st_mode, FILEFLAGS(sx.st.st_flags), t, del_opts) != 0)
263                                 goto cleanup;
264                 } else if (basis_dir[0] != NULL) {
265                         int j = try_dests_non(file, fname, ndx, fnamecmpbuf, &sx,
266 @@ -1457,7 +1466,7 @@ static void recv_generator(char *fname, 
267         fnamecmp_type = FNAMECMP_FNAME;
268  
269         if (statret == 0 && !S_ISREG(sx.st.st_mode)) {
270 -               if (delete_item(fname, sx.st.st_mode, "regular file", del_opts) != 0)
271 +               if (delete_item(fname, sx.st.st_mode, FILEFLAGS(sx.st.st_flags), "regular file", del_opts) != 0)
272                         goto cleanup;
273                 statret = -1;
274                 stat_errno = ENOENT;
275 --- old/options.c
276 +++ new/options.c
277 @@ -48,6 +48,7 @@ int preserve_links = 0;
278  int preserve_hard_links = 0;
279  int preserve_acls = 0;
280  int preserve_perms = 0;
281 +int preserve_fileflags = 0;
282  int preserve_executability = 0;
283  int preserve_devices = 0;
284  int preserve_specials = 0;
285 @@ -202,6 +203,7 @@ static void print_rsync_version(enum log
286         char const *acls = "no ";
287         char const *links = "no ";
288         char const *ipv6 = "no ";
289 +       char const *fileflags = "no ";
290         STRUCT_STAT *dumstat;
291  
292  #ifdef HAVE_SOCKETPAIR
293 @@ -228,6 +230,10 @@ static void print_rsync_version(enum log
294         ipv6 = "";
295  #endif
296  
297 +#ifdef SUPPORT_FLAGS
298 +       fileflags = "";
299 +#endif
300 +
301         rprintf(f, "%s  version %s  protocol version %d\n",
302                 RSYNC_NAME, RSYNC_VERSION, PROTOCOL_VERSION);
303         rprintf(f, "Copyright (C) 1996-2007 by Andrew Tridgell, Wayne Davison, and others.\n");
304 @@ -238,8 +244,8 @@ static void print_rsync_version(enum log
305                 (int)(sizeof (int64) * 8));
306         rprintf(f, "    %ssocketpairs, %shardlinks, %ssymlinks, %sIPv6, batchfiles, %sinplace,\n",
307                 got_socketpair, hardlinks, links, ipv6, have_inplace);
308 -       rprintf(f, "    %sappend, %sACLs\n",
309 -               have_inplace, acls);
310 +       rprintf(f, "    %sappend, %sACLs, %sfile-flags\n",
311 +               have_inplace, acls, fileflags);
312  
313  #ifdef MAINTAINER_MODE
314         rprintf(f, "Panic Action: \"%s\"\n", get_panic_action());
315 @@ -305,6 +311,7 @@ void usage(enum logcode F)
316    rprintf(F," -K, --keep-dirlinks         treat symlinked dir on receiver as dir\n");
317    rprintf(F," -H, --hard-links            preserve hard links\n");
318    rprintf(F," -p, --perms                 preserve permissions\n");
319 +  rprintf(F,"     --fileflags             preserve file-flags\n");
320    rprintf(F," -E, --executability         preserve the file's executability\n");
321    rprintf(F,"     --chmod=CHMOD           affect file and/or directory permissions\n");
322  #ifdef SUPPORT_ACLS
323 @@ -429,6 +436,8 @@ static struct poptOption long_options[] 
324    {"perms",           'p', POPT_ARG_VAL,    &preserve_perms, 1, 0, 0 },
325    {"no-perms",         0,  POPT_ARG_VAL,    &preserve_perms, 0, 0, 0 },
326    {"no-p",             0,  POPT_ARG_VAL,    &preserve_perms, 0, 0, 0 },
327 +  {"fileflags",        0,  POPT_ARG_VAL,    &preserve_fileflags, 1, 0, 0 },
328 +  {"no-fileflags",     0,  POPT_ARG_VAL,    &preserve_fileflags, 0, 0, 0 },
329    {"executability",   'E', POPT_ARG_NONE,   &preserve_executability, 0, 0, 0 },
330    {"acls",            'A', POPT_ARG_NONE,   0, 'A', 0, 0 },
331    {"no-acls",          0,  POPT_ARG_VAL,    &preserve_acls, 0, 0, 0 },
332 @@ -1161,6 +1170,15 @@ int parse_arguments(int *argc, const cha
333         }
334  #endif
335  
336 +#ifndef SUPPORT_FLAGS
337 +       if (preserve_fileflags) {
338 +               snprintf(err_buf, sizeof err_buf,
339 +                        "file flags are not supported on this %s\n",
340 +                        am_server ? "server" : "client");
341 +               return 0;
342 +       }
343 +#endif
344 +
345         if (write_batch && read_batch) {
346                 snprintf(err_buf, sizeof err_buf,
347                         "--write-batch and --read-batch can not be used together\n");
348 @@ -1624,6 +1642,9 @@ void server_options(char **args,int *arg
349         if (xfer_dirs && !recurse && delete_mode && am_sender)
350                 args[ac++] = "--no-r";
351  
352 +       if (preserve_fileflags)
353 +               args[ac++] = "--flags";
354 +
355         if (do_compression && def_compress_level != Z_DEFAULT_COMPRESSION) {
356                 if (asprintf(&arg, "--compress-level=%d", def_compress_level) < 0)
357                         goto oom;
358 --- old/rsync.c
359 +++ new/rsync.c
360 @@ -33,6 +33,7 @@ extern int verbose;
361  extern int dry_run;
362  extern int preserve_acls;
363  extern int preserve_perms;
364 +extern int preserve_fileflags;
365  extern int preserve_executability;
366  extern int preserve_times;
367  extern int omit_dir_times;
368 @@ -53,6 +54,8 @@ extern int make_backups;
369  extern struct file_list *cur_flist, *first_flist, *dir_flist;
370  extern struct chmod_mode_struct *daemon_chmod_modes;
371  
372 +#define NOCHANGE_FLAGS (UF_IMMUTABLE|UF_APPEND|UF_NOUNLINK|SF_IMMUTABLE|SF_APPEND|SF_NOUNLINK)
373 +
374  #if defined HAVE_ICONV_OPEN && defined HAVE_ICONV_H
375  iconv_t ic_chck = (iconv_t)-1;
376  
377 @@ -228,6 +231,41 @@ mode_t dest_mode(mode_t flist_mode, mode
378         return new_mode;
379  }
380  
381 +#ifdef SUPPORT_FLAGS
382 +/* Set a file's st_flags. */
383 +static int set_fileflags(const char *fname, uint32 fileflags)
384 +{
385 +       if (do_chflags(fname, fileflags) != 0) {
386 +               rsyserr(FERROR, errno,
387 +                       "failed to set file flags on %s",
388 +                       full_fname(fname));
389 +               return 0;
390 +       }
391 +
392 +       return 1;
393 +}
394 +
395 +/* Remove immutable flags from an object, so it can be altered/removed. */
396 +void make_mutable(char *fname, mode_t mode, uint32 fileflags)
397 +{
398 +       if (!preserve_fileflags && S_ISLNK(mode))
399 +               return;
400 +
401 +       if (fileflags & NOCHANGE_FLAGS)
402 +               set_fileflags(fname, fileflags & ~NOCHANGE_FLAGS);
403 +}
404 +
405 +/* Undo a prior make_mutable() call. */
406 +void undo_make_mutable(char *fname, mode_t mode, uint32 fileflags)
407 +{
408 +       if (!preserve_fileflags && S_ISLNK(mode))
409 +               return;
410 +
411 +       if (fileflags & NOCHANGE_FLAGS)
412 +               set_fileflags(fname, fileflags);
413 +}
414 +#endif
415 +
416  int set_file_attrs(char *fname, struct file_struct *file, statx *sxp,
417                    int flags)
418  {
419 @@ -346,6 +384,15 @@ int set_file_attrs(char *fname, struct f
420         }
421  #endif
422  
423 +#ifdef SUPPORT_FLAGS
424 +       if (preserve_fileflags && !S_ISLNK(st->st_mode)
425 +        && st->st_flags != file->fileflags) {
426 +               if (!set_fileflags(fname, file->fileflags))
427 +                       return 0;
428 +               updated = 1;
429 +       }
430 +#endif
431 +
432         if (verbose > 1 && flags & ATTRS_REPORT) {
433                 if (updated)
434                         rprintf(FCLIENT, "%s\n", fname);
435 @@ -398,6 +445,9 @@ void finish_transfer(char *fname, char *
436         set_file_attrs(fnametmp, file, NULL,
437                        ok_to_set_time ? 0 : ATTRS_SKIP_MTIME);
438  
439 +#ifdef SUPPORT_FLAGS
440 +       make_mutable(fnametmp, file->mode, file->fileflags);
441 +#endif
442         /* move tmp file over real file */
443         if (verbose > 2)
444                 rprintf(FINFO, "renaming %s to %s\n", fnametmp, fname);
445 @@ -412,6 +462,9 @@ void finish_transfer(char *fname, char *
446         }
447         if (ret == 0) {
448                 /* The file was moved into place (not copied), so it's done. */
449 +#ifdef SUPPORT_FLAGS
450 +               undo_make_mutable(fname, file->mode, file->fileflags);
451 +#endif
452                 return;
453         }
454         /* The file was copied, so tweak the perms of the copied file.  If it
455 --- old/rsync.h
456 +++ new/rsync.h
457 @@ -56,6 +56,7 @@
458  #define XMIT_RDEV_MINOR_8_pre30 (1<<11)        /* protocols 28 - 29  */
459  #define XMIT_GROUP_NAME_FOLLOWS (1<<11) /* protocols 30 - NOW */
460  #define XMIT_HLINK_FIRST (1<<12)       /* protocols 30 - NOW */
461 +#define XMIT_SAME_FLAGS (1<<14)                /* protocols ?? - NOW */
462  
463  /* These flags are used in the live flist data. */
464  
465 @@ -389,6 +390,10 @@ enum msgcode {
466  #endif
467  #endif
468  
469 +#ifdef HAVE_CHFLAGS
470 +#define SUPPORT_FLAGS 1
471 +#endif
472 +
473  /* Find a variable that is either exactly 32-bits or longer.
474   * If some code depends on 32-bit truncation, it will need to
475   * take special action in a "#if SIZEOF_INT32 > 4" section. */
476 @@ -570,6 +575,7 @@ struct file_struct {
477  extern int file_extra_cnt;
478  extern int preserve_uid;
479  extern int preserve_gid;
480 +extern int preserve_fileflags;
481  extern int preserve_acls;
482  
483  #define FILE_STRUCT_LEN (offsetof(struct file_struct, basename))
484 @@ -603,6 +609,7 @@ extern int preserve_acls;
485  /* When the associated option is on, all entries will have these present: */
486  #define F_OWNER(f) REQ_EXTRA(f, preserve_uid)->unum
487  #define F_GROUP(f) REQ_EXTRA(f, preserve_gid)->unum
488 +#define F_FFLAGS(f) REQ_EXTRA(f, preserve_fileflags).unum
489  #define F_ACL(f) REQ_EXTRA(f, preserve_acls)->unum
490  
491  /* These items are per-entry optional and mutally exclusive: */
492 --- old/rsync.yo
493 +++ new/rsync.yo
494 @@ -321,6 +321,7 @@ to the detailed description below for a 
495   -K, --keep-dirlinks         treat symlinked dir on receiver as dir
496   -H, --hard-links            preserve hard links
497   -p, --perms                 preserve permissions
498 +     --flags                 preserve file flags
499   -E, --executability         preserve executability
500       --chmod=CHMOD           affect file and/or directory permissions
501   -A, --acls                  preserve ACLs (implies -p)
502 @@ -511,7 +512,9 @@ specified, in which case bf(-r) is not i
503  
504  Note that bf(-a) bf(does not preserve hardlinks), because
505  finding multiply-linked files is expensive.  You must separately
506 -specify bf(-H).
507 +specify bf(-H).  Note also that for compatibility, bf(-a)
508 +currently bf(does not include --flags) (see there) to include preserving
509 +change file flags (if supported by the OS).
510  
511  dit(--no-OPTION) You may turn off one or more implied options by prefixing
512  the option name with "no-".  Not all options may be prefixed with a "no-":
513 @@ -831,6 +834,13 @@ dit(bf(-A, --acls)) This option causes r
514  ACLs to be the same as the source ACLs.  This nonstandard option only
515  works if the remote rsync also supports it.  bf(--acls) implies bf(--perms).
516  
517 +dit(bf(--flags)) This option causes rsync to update the change file flags
518 +to be the same as the source file, if your OS supports the bf(chflags)(2)
519 +system call.  In any case, an attempt is made to remove flags that would
520 +prevent a file to be altered.  Some flags can only be altered by the
521 +super-user and can only be unset below a certain secure-level (usually
522 +single-user mode).
523 +
524  dit(bf(--chmod)) This option tells rsync to apply one or more
525  comma-separated "chmod" strings to the permission of the files in the
526  transfer.  The resulting value is treated as though it was the permissions
527 --- old/syscall.c
528 +++ new/syscall.c
529 @@ -152,6 +152,15 @@ int do_chmod(const char *path, mode_t mo
530  }
531  #endif
532  
533 +#ifdef SUPPORT_FLAGS
534 +int do_chflags(const char *path, u_long flags)
535 +{
536 +       if (dry_run) return 0;
537 +       RETURN_ERROR_IF_RO_OR_LO;
538 +       return chflags(path, flags);
539 +}
540 +#endif
541 +
542  int do_rename(const char *fname1, const char *fname2)
543  {
544         if (dry_run) return 0;