A minor tweak to the compatibility code.
[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 @@ -64,6 +64,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         if (preserve_xattrs)
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 @@ -48,6 +48,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 @@ -353,6 +354,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 @@ -373,6 +377,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 (F_FFLAGS(file) == fileflags)
61 +               flags |= XMIT_SAME_FLAGS;
62 +       else
63 +               fileflags = F_FFLAGS(file);
64 +#endif
65         if ((preserve_devices && IS_DEVICE(mode))
66          || (preserve_specials && IS_SPECIAL(mode))) {
67                 if (protocol_version < 28) {
68 @@ -486,6 +496,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 @@ -574,6 +588,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 @@ -670,9 +687,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 @@ -790,6 +810,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 @@ -1099,6 +1123,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 @@ -112,6 +112,14 @@ 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 FF_PTR(p) F_FFLAGS(p)
133 +#define FF_STAT(s) s.st_flags
134 +#else
135 +#define FF_PTR(p) 0
136 +#define FF_STAT(s) 0
137 +#endif
138 +
139  /* For calling delete_item() and delete_dir_contents(). */
140  #define DEL_RECURSE            (1<<1) /* recurse */
141  #define DEL_DIR_IS_EMPTY       (1<<2) /* internal delete_FUNCTIONS use only */
142 @@ -127,7 +135,6 @@ enum delret {
143  /* Forward declaration for delete_item(). */
144  static enum delret delete_dir_contents(char *fname, int flags);
145  
146 -
147  static int is_backup_file(char *fn)
148  {
149         int k = strlen(fn) - backup_suffix_len;
150 @@ -140,17 +147,20 @@ static int is_backup_file(char *fn)
151   * Note that fbuf must point to a MAXPATHLEN buffer if the mode indicates it's
152   * a directory! (The buffer is used for recursion, but returned unchanged.)
153   */
154 -static enum delret delete_item(char *fbuf, int mode, char *replace, int flags)
155 +static enum delret delete_item(char *fbuf, int mode, uint32 fileflags, char *replace, int flags)
156  {
157         enum delret ret;
158         char *what;
159         int ok;
160  
161         if (verbose > 2) {
162 -               rprintf(FINFO, "delete_item(%s) mode=%o flags=%d\n",
163 -                       fbuf, mode, flags);
164 +               rprintf(FINFO, "delete_item(%s) mode=%o fileflags=%o flags=%d\n",
165 +                       fbuf, mode, fileflags, flags);
166         }
167  
168 +#ifdef SUPPORT_FLAGS
169 +       make_mutable(fbuf, mode, fileflags);
170 +#endif
171         if (S_ISDIR(mode) && !(flags & DEL_DIR_IS_EMPTY)) {
172                 ignore_perishable = 1;
173                 /* If DEL_RECURSE is not set, this just reports emptiness. */
174 @@ -262,7 +272,7 @@ static enum delret delete_dir_contents(c
175                 if (S_ISDIR(fp->mode)
176                  && delete_dir_contents(fname, flags | DEL_RECURSE) != DR_SUCCESS)
177                         ret = DR_NOT_EMPTY;
178 -               if (delete_item(fname, fp->mode, NULL, flags) != DR_SUCCESS)
179 +               if (delete_item(fname, fp->mode, FF_PTR(fp), NULL, flags) != DR_SUCCESS)
180                         ret = DR_NOT_EMPTY;
181         }
182  
183 @@ -318,8 +328,9 @@ static int remember_delete(struct file_s
184         
185         while (1) {
186                 len = snprintf(deldelay_buf + deldelay_cnt,
187 -                              deldelay_size - deldelay_cnt,
188 -                              "%x %s%c", (int)file->mode, fname, '\0');
189 +                              deldelay_size - deldelay_cnt, "%x %x %s%c",
190 +                              (int)file->mode, (int)FF_PTR(file),
191 +                              fname, '\0');
192                 if ((deldelay_cnt += len) <= deldelay_size)
193                         break;
194                 if (deldelay_fd < 0 && !start_delete_delay_temp())
195 @@ -332,7 +343,7 @@ static int remember_delete(struct file_s
196         return 1;
197  }
198  
199 -static int read_delay_line(char *buf)
200 +static int read_delay_line(char *buf, int *fileflags_p)
201  {
202         static int read_pos = 0;
203         int j, len, mode;
204 @@ -374,7 +385,7 @@ static int read_delay_line(char *buf)
205  
206         bp = deldelay_buf + read_pos;
207  
208 -       if (sscanf(bp, "%x ", &mode) != 1) {
209 +       if (sscanf(bp, "%x %x ", &mode, fileflags_p) != 2) {
210           invalid_data:
211                 rprintf(FERROR, "ERROR: invalid data in delete-delay file.\n");
212                 return -1;
213 @@ -397,15 +408,15 @@ static int read_delay_line(char *buf)
214  
215  static void do_delayed_deletions(char *delbuf)
216  {
217 -       int mode;
218 +       int mode, fileflags;
219  
220         if (deldelay_fd >= 0) {
221                 if (deldelay_cnt && !flush_delete_delay())
222                         return;
223                 lseek(deldelay_fd, 0, 0);
224         }
225 -       while ((mode = read_delay_line(delbuf)) >= 0)
226 -               delete_item(delbuf, mode, NULL, DEL_RECURSE);
227 +       while ((mode = read_delay_line(delbuf, &fileflags)) >= 0)
228 +               delete_item(delbuf, mode, fileflags, NULL, DEL_RECURSE);
229         if (deldelay_fd >= 0)
230                 close(deldelay_fd);
231  }
232 @@ -473,7 +484,7 @@ static void delete_in_dir(struct file_li
233                                 if (!remember_delete(fp, delbuf))
234                                         break;
235                         } else
236 -                               delete_item(delbuf, fp->mode, NULL, DEL_RECURSE);
237 +                               delete_item(delbuf, fp->mode, FF_PTR(fp), NULL, DEL_RECURSE);
238                 }
239         }
240  
241 @@ -1211,7 +1222,7 @@ static void recv_generator(char *fname, 
242                  * we need to delete it.  If it doesn't exist, then
243                  * (perhaps recursively) create it. */
244                 if (statret == 0 && !S_ISDIR(sx.st.st_mode)) {
245 -                       if (delete_item(fname, sx.st.st_mode, "directory", del_opts) != 0)
246 +                       if (delete_item(fname, sx.st.st_mode, FF_STAT(sx.st), "directory", del_opts) != 0)
247                                 return;
248                         statret = -1;
249                 }
250 @@ -1324,7 +1335,7 @@ static void recv_generator(char *fname, 
251                         }
252                         /* Not the right symlink (or not a symlink), so
253                          * delete it. */
254 -                       if (delete_item(fname, sx.st.st_mode, "symlink", del_opts) != 0)
255 +                       if (delete_item(fname, sx.st.st_mode, FF_STAT(sx.st), "symlink", del_opts) != 0)
256                                 goto cleanup;
257                 } else if (basis_dir[0] != NULL) {
258                         int j = try_dests_non(file, fname, ndx, fnamecmpbuf, &sx,
259 @@ -1401,7 +1412,7 @@ static void recv_generator(char *fname, 
260                                         goto return_with_success;
261                                 goto cleanup;
262                         }
263 -                       if (delete_item(fname, sx.st.st_mode, t, del_opts) != 0)
264 +                       if (delete_item(fname, sx.st.st_mode, FF_STAT(sx.st), t, del_opts) != 0)
265                                 goto cleanup;
266                 } else if (basis_dir[0] != NULL) {
267                         int j = try_dests_non(file, fname, ndx, fnamecmpbuf, &sx,
268 @@ -1490,7 +1501,7 @@ static void recv_generator(char *fname, 
269         fnamecmp_type = FNAMECMP_FNAME;
270  
271         if (statret == 0 && !S_ISREG(sx.st.st_mode)) {
272 -               if (delete_item(fname, sx.st.st_mode, "regular file", del_opts) != 0)
273 +               if (delete_item(fname, sx.st.st_mode, FF_STAT(sx.st), "regular file", del_opts) != 0)
274                         goto cleanup;
275                 statret = -1;
276                 stat_errno = ENOENT;
277 --- old/options.c
278 +++ new/options.c
279 @@ -49,6 +49,7 @@ int preserve_hard_links = 0;
280  int preserve_acls = 0;
281  int preserve_xattrs = 0;
282  int preserve_perms = 0;
283 +int preserve_fileflags = 0;
284  int preserve_executability = 0;
285  int preserve_devices = 0;
286  int preserve_specials = 0;
287 @@ -205,6 +206,7 @@ static void print_rsync_version(enum log
288         char const *xattrs = "no ";
289         char const *links = "no ";
290         char const *ipv6 = "no ";
291 +       char const *fileflags = "no ";
292         STRUCT_STAT *dumstat;
293  
294  #ifdef HAVE_SOCKETPAIR
295 @@ -233,6 +235,10 @@ static void print_rsync_version(enum log
296         ipv6 = "";
297  #endif
298  
299 +#ifdef SUPPORT_FLAGS
300 +       fileflags = "";
301 +#endif
302 +
303         rprintf(f, "%s  version %s  protocol version %d\n",
304                 RSYNC_NAME, RSYNC_VERSION, PROTOCOL_VERSION);
305         rprintf(f, "Copyright (C) 1996-2007 by Andrew Tridgell, Wayne Davison, and others.\n");
306 @@ -243,8 +249,8 @@ static void print_rsync_version(enum log
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\n",
311 -               have_inplace, acls, xattrs);
312 +       rprintf(f, "    %sappend, %sACLs, %sxattrs, %sfile-flags\n",
313 +               have_inplace, acls, xattrs, fileflags);
314  
315  #ifdef MAINTAINER_MODE
316         rprintf(f, "Panic Action: \"%s\"\n", get_panic_action());
317 @@ -310,6 +316,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 @@ -441,6 +448,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 @@ -1187,6 +1196,15 @@ int parse_arguments(int *argc, const cha
335         }
336  #endif
337  
338 +#ifndef SUPPORT_FLAGS
339 +       if (preserve_fileflags) {
340 +               snprintf(err_buf, sizeof err_buf,
341 +                        "file flags are 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 @@ -1654,6 +1672,9 @@ void server_options(char **args,int *arg
351         if (xfer_dirs && !recurse && delete_mode && am_sender)
352                 args[ac++] = "--no-r";
353  
354 +       if (preserve_fileflags)
355 +               args[ac++] = "--flags";
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;
360 --- old/rsync.c
361 +++ new/rsync.c
362 @@ -34,6 +34,7 @@ extern int dry_run;
363  extern int preserve_acls;
364  extern int preserve_xattrs;
365  extern int preserve_perms;
366 +extern int preserve_fileflags;
367  extern int preserve_executability;
368  extern int preserve_times;
369  extern int omit_dir_times;
370 @@ -54,6 +55,16 @@ extern int make_backups;
371  extern struct file_list *cur_flist, *first_flist, *dir_flist;
372  extern struct chmod_mode_struct *daemon_chmod_modes;
373  
374 +#ifdef SUPPORT_FLAGS
375 +#ifndef UF_NOUNLINK
376 +#define UF_NOUNLINK 0
377 +#endif
378 +#ifndef SF_NOUNLINK
379 +#define SF_NOUNLINK 0
380 +#endif
381 +#define NOCHANGE_FLAGS (UF_IMMUTABLE|UF_APPEND|UF_NOUNLINK|SF_IMMUTABLE|SF_APPEND|SF_NOUNLINK)
382 +#endif
383 +
384  #if defined HAVE_ICONV_OPEN && defined HAVE_ICONV_H
385  iconv_t ic_chck = (iconv_t)-1;
386  
387 @@ -222,6 +233,41 @@ mode_t dest_mode(mode_t flist_mode, mode
388         return new_mode;
389  }
390  
391 +#ifdef SUPPORT_FLAGS
392 +/* Set a file's st_flags. */
393 +static int set_fileflags(const char *fname, uint32 fileflags)
394 +{
395 +       if (do_chflags(fname, fileflags) != 0) {
396 +               rsyserr(FERROR, errno,
397 +                       "failed to set file flags on %s",
398 +                       full_fname(fname));
399 +               return 0;
400 +       }
401 +
402 +       return 1;
403 +}
404 +
405 +/* Remove immutable flags from an object, so it can be altered/removed. */
406 +void 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 & ~NOCHANGE_FLAGS);
413 +}
414 +
415 +/* Undo a prior make_mutable() call. */
416 +void undo_make_mutable(char *fname, mode_t mode, uint32 fileflags)
417 +{
418 +       if (!preserve_fileflags && S_ISLNK(mode))
419 +               return;
420 +
421 +       if (fileflags & NOCHANGE_FLAGS)
422 +               set_fileflags(fname, fileflags);
423 +}
424 +#endif
425 +
426  int set_file_attrs(const char *fname, struct file_struct *file, statx *sxp,
427                    const char *fnamecmp, int flags)
428  {
429 @@ -348,6 +394,15 @@ int set_file_attrs(const char *fname, st
430         }
431  #endif
432  
433 +#ifdef SUPPORT_FLAGS
434 +       if (preserve_fileflags && !S_ISLNK(sxp->st.st_mode)
435 +        && sxp->st.st_flags != F_FFLAGS(file)) {
436 +               if (!set_fileflags(fname, F_FFLAGS(file)))
437 +                       return 0;
438 +               updated = 1;
439 +       }
440 +#endif
441 +
442         if (verbose > 1 && flags & ATTRS_REPORT) {
443                 if (updated)
444                         rprintf(FCLIENT, "%s\n", fname);
445 @@ -407,6 +462,9 @@ void finish_transfer(const char *fname, 
446         set_file_attrs(fnametmp, file, NULL, fnamecmp,
447                        ok_to_set_time ? 0 : ATTRS_SKIP_MTIME);
448  
449 +#ifdef SUPPORT_FLAGS
450 +       make_mutable(fnametmp, file->mode, F_FFLAGS(file));
451 +#endif
452         /* move tmp file over real file */
453         if (verbose > 2)
454                 rprintf(FINFO, "renaming %s to %s\n", fnametmp, fname);
455 @@ -421,6 +479,9 @@ void finish_transfer(const char *fname, 
456         }
457         if (ret == 0) {
458                 /* The file was moved into place (not copied), so it's done. */
459 +#ifdef SUPPORT_FLAGS
460 +               undo_make_mutable(fname, file->mode, F_FFLAGS(file));
461 +#endif
462                 return;
463         }
464         /* The file was copied, so tweak the perms of the copied file.  If it
465 --- old/rsync.h
466 +++ new/rsync.h
467 @@ -56,6 +56,7 @@
468  #define XMIT_RDEV_MINOR_8_pre30 (1<<11)        /* protocols 28 - 29  */
469  #define XMIT_GROUP_NAME_FOLLOWS (1<<11) /* protocols 30 - NOW */
470  #define XMIT_HLINK_FIRST (1<<12)       /* protocols 30 - NOW */
471 +#define XMIT_SAME_FLAGS (1<<14)                /* protocols ?? - NOW */
472  
473  /* These flags are used in the live flist data. */
474  
475 @@ -389,6 +390,10 @@ enum msgcode {
476  #endif
477  #endif
478  
479 +#ifdef HAVE_CHFLAGS
480 +#define SUPPORT_FLAGS 1
481 +#endif
482 +
483  /* Find a variable that is either exactly 32-bits or longer.
484   * If some code depends on 32-bit truncation, it will need to
485   * take special action in a "#if SIZEOF_INT32 > 4" section. */
486 @@ -568,6 +573,7 @@ struct file_struct {
487  extern int file_extra_cnt;
488  extern int preserve_uid;
489  extern int preserve_gid;
490 +extern int preserve_fileflags;
491  extern int preserve_acls;
492  extern int preserve_xattrs;
493  
494 @@ -602,6 +608,7 @@ extern int preserve_xattrs;
495  /* When the associated option is on, all entries will have these present: */
496  #define F_OWNER(f) REQ_EXTRA(f, preserve_uid)->unum
497  #define F_GROUP(f) REQ_EXTRA(f, preserve_gid)->unum
498 +#define F_FFLAGS(f) REQ_EXTRA(f, preserve_fileflags)->unum
499  #define F_ACL(f) REQ_EXTRA(f, preserve_acls)->num
500  #define F_XATTR(f) REQ_EXTRA(f, preserve_xattrs)->num
501  
502 --- old/rsync.yo
503 +++ new/rsync.yo
504 @@ -321,6 +321,7 @@ to the detailed description below for a 
505   -K, --keep-dirlinks         treat symlinked dir on receiver as dir
506   -H, --hard-links            preserve hard links
507   -p, --perms                 preserve permissions
508 +     --flags                 preserve file flags
509   -E, --executability         preserve executability
510       --chmod=CHMOD           affect file and/or directory permissions
511   -A, --acls                  preserve ACLs (implies -p)
512 @@ -512,7 +513,9 @@ specified, in which case bf(-r) is not i
513  
514  Note that bf(-a) bf(does not preserve hardlinks), because
515  finding multiply-linked files is expensive.  You must separately
516 -specify bf(-H).
517 +specify bf(-H).  Note also that for compatibility, bf(-a)
518 +currently bf(does not include --flags) (see there) to include preserving
519 +change file flags (if supported by the OS).
520  
521  dit(--no-OPTION) You may turn off one or more implied options by prefixing
522  the option name with "no-".  Not all options may be prefixed with a "no-":
523 @@ -837,6 +840,13 @@ extended attributes to be the same as th
524  only if the remote machine's rsync supports this option also. This is
525  a non-standard option.
526  
527 +dit(bf(--flags)) This option causes rsync to update the change file flags
528 +to be the same as the source file, if your OS supports the bf(chflags)(2)
529 +system call.  In any case, an attempt is made to remove flags that would
530 +prevent a file to be altered.  Some flags can only be altered by the
531 +super-user and can only be unset below a certain secure-level (usually
532 +single-user mode).
533 +
534  dit(bf(--chmod)) This option tells rsync to apply one or more
535  comma-separated "chmod" strings to the permission of the files in the
536  transfer.  The resulting value is treated as though it was the permissions
537 --- old/syscall.c
538 +++ new/syscall.c
539 @@ -152,6 +152,15 @@ int do_chmod(const char *path, mode_t mo
540  }
541  #endif
542  
543 +#ifdef SUPPORT_FLAGS
544 +int do_chflags(const char *path, u_long flags)
545 +{
546 +       if (dry_run) return 0;
547 +       RETURN_ERROR_IF_RO_OR_LO;
548 +       return chflags(path, flags);
549 +}
550 +#endif
551 +
552  int do_rename(const char *fname1, const char *fname2)
553  {
554         if (dry_run) return 0;