Fixed a compilation problem.
[rsync/rsync-patches.git] / flags.diff
CommitLineData
31611b92 1This patch provides --flags, which preserves the st_flags field.
9f62ddf8 2Modified from a patch that was written by Rolf Grossmann.
31611b92 3
03019e41 4To use this patch, run these commands for a successful build:
9f62ddf8 5
03019e41 6 patch -p1 <patches/flags.diff
9f62ddf8
WD
7 ./prepare-source
8 ./configure
9 make
31611b92 10
5bafda30
WD
11TODO: fix --delete-delay to work with --flags option.
12
fdf967c7
WD
13--- old/compat.c
14+++ new/compat.c
15@@ -48,6 +48,8 @@ void setup_protocol(int f_out,int f_in)
16 preserve_uid = ++flist_extra_cnt;
17 if (preserve_gid)
18 preserve_gid = ++flist_extra_cnt;
19+ if (preserve_fileflags)
20+ preserve_fileflags = ++flist_extra_cnt;
21
22 if (remote_protocol == 0) {
23 if (!read_batch)
31611b92
WD
24--- old/configure.in
25+++ new/configure.in
f813befd 26@@ -549,7 +549,7 @@ AC_CHECK_FUNCS(waitpid wait4 getcwd strd
31611b92
WD
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
fdf967c7 37@@ -45,6 +45,7 @@ extern int preserve_links;
31611b92
WD
38 extern int preserve_hard_links;
39 extern int preserve_devices;
40 extern int preserve_specials;
5e3c6c93 41+extern int preserve_fileflags;
31611b92
WD
42 extern int preserve_uid;
43 extern int preserve_gid;
44 extern int relative_paths;
fdf967c7 45@@ -315,6 +316,9 @@ static void send_file_entry(struct file_
31611b92
WD
46 unsigned short flags;
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;
fdf967c7 55@@ -333,6 +337,12 @@ static void send_file_entry(struct file_
31611b92
WD
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) {
fdf967c7 68@@ -434,6 +444,10 @@ static void send_file_entry(struct file_
31611b92
WD
69 write_int(f, modtime);
70 if (!(flags & XMIT_SAME_MODE))
71 write_int(f, to_wire_mode(mode));
72+#ifdef SUPPORT_FLAGS
5e3c6c93 73+ if (preserve_fileflags && !(flags & XMIT_SAME_FLAGS))
31611b92
WD
74+ write_int(f, (int)fileflags);
75+#endif
76 if (preserve_uid && !(flags & XMIT_SAME_UID)) {
77 if (!numeric_ids)
78 add_uid(uid);
fdf967c7 79@@ -503,6 +517,9 @@ static struct file_struct *recv_file_ent
31611b92
WD
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;
fdf967c7 89@@ -610,9 +627,12 @@ static struct file_struct *recv_file_ent
31611b92
WD
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
5e3c6c93 97+ if (preserve_fileflags && !(flags & XMIT_SAME_FLAGS))
31611b92
WD
98+ fileflags = (uint32)read_int(f);
99+#endif
100
101 if (preserve_uid && !(flags & XMIT_SAME_UID))
102 uid = (uid_t)read_int(f);
fdf967c7 103@@ -696,6 +716,10 @@ static struct file_struct *recv_file_ent
1aa236e1
WD
104 OPT_EXTRA(file, 0)->unum = (uint32)(file_length >> 32);
105 }
31611b92
WD
106 file->mode = mode;
107+#ifdef SUPPORT_FLAGS
70891d26
WD
108+ if (preserve_fileflags)
109+ F_FFLAGS(file) = fileflags;
31611b92 110+#endif
70891d26
WD
111 if (preserve_uid)
112 F_UID(file) = uid;
113 if (preserve_gid)
fdf967c7 114@@ -998,6 +1022,10 @@ struct file_struct *make_file(const char
1aa236e1
WD
115 OPT_EXTRA(file, 0)->unum = (uint32)(st.st_size >> 32);
116 }
31611b92
WD
117 file->mode = st.st_mode;
118+#ifdef SUPPORT_FLAGS
70891d26
WD
119+ if (preserve_fileflags)
120+ F_FFLAGS(file) = st.st_flags;
31611b92 121+#endif
70891d26
WD
122 if (preserve_uid)
123 F_UID(file) = st.st_uid;
124 if (preserve_gid)
31611b92
WD
125--- old/generator.c
126+++ new/generator.c
fdf967c7 127@@ -103,6 +103,12 @@ static char *deldelay_buf = NULL;
ee76479d
WD
128 static int deldelay_fd = -1;
129 static BOOL solo_file = 0;
f90a882e
WD
130
131+#ifdef SUPPORT_FLAGS
132+#define FILEFLAGS(ff) ff
133+#else
134+#define FILEFLAGS(ff) 0
135+#endif
136+
d16b5fd6 137 /* For calling delete_item() and delete_dir_contents(). */
87d0091c 138 #define DEL_RECURSE (1<<1) /* recurse */
d16b5fd6 139 #define DEL_DIR_IS_EMPTY (1<<2) /* internal delete_FUNCTIONS use only */
fdf967c7 140@@ -118,7 +124,6 @@ enum delret {
87d0091c
WD
141 /* Forward declaration for delete_item(). */
142 static enum delret delete_dir_contents(char *fname, int flags);
f90a882e 143
87d0091c
WD
144-
145 static int is_backup_file(char *fn)
146 {
147 int k = strlen(fn) - backup_suffix_len;
fdf967c7 148@@ -131,17 +136,20 @@ static int is_backup_file(char *fn)
f813befd 149 * Note that fbuf must point to a MAXPATHLEN buffer if the mode indicates it's
f90a882e
WD
150 * a directory! (The buffer is used for recursion, but returned unchanged.)
151 */
f813befd
WD
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)
f90a882e 154 {
87d0091c
WD
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",
f813befd 161- fbuf, mode, flags);
87d0091c 162+ rprintf(FINFO, "delete_item(%s) mode=%o fileflags=%o flags=%d\n",
f813befd 163+ fbuf, mode, fileflags, flags);
87d0091c
WD
164 }
165
31611b92 166+#ifdef SUPPORT_FLAGS
f813befd 167+ make_mutable(fbuf, mode, fileflags);
31611b92 168+#endif
d16b5fd6
WD
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. */
fdf967c7 172@@ -253,7 +261,7 @@ static enum delret delete_dir_contents(c
d16b5fd6
WD
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;
f90a882e 179 }
d16b5fd6 180
fdf967c7 181@@ -309,8 +317,9 @@ static int remember_delete(struct file_s
ee76479d
WD
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())
fdf967c7 193@@ -323,7 +332,7 @@ static int remember_delete(struct file_s
ee76479d
WD
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;
fdf967c7 202@@ -365,7 +374,7 @@ static int read_delay_line(char *buf)
ee76479d
WD
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;
fdf967c7 211@@ -388,15 +397,15 @@ static int read_delay_line(char *buf)
ee76479d
WD
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 }
fdf967c7 230@@ -477,7 +486,7 @@ static void delete_in_dir(struct file_li
ee76479d
WD
231 if (!remember_delete(fp, delbuf))
232 break;
233 } else
f813befd
WD
234- delete_item(delbuf, fp->mode, NULL, DEL_RECURSE);
235+ delete_item(delbuf, fp->mode, FILEFLAGS(fp->fileflags), NULL, DEL_RECURSE);
f90a882e
WD
236 }
237 }
238
fdf967c7 239@@ -1181,7 +1190,7 @@ static void recv_generator(char *fname,
0461b869 240 * we need to delete it. If it doesn't exist, then
f90a882e
WD
241 * (perhaps recursively) create it. */
242 if (statret == 0 && !S_ISDIR(st.st_mode)) {
87d0091c
WD
243- if (delete_item(fname, st.st_mode, "directory", del_opts) != 0)
244+ if (delete_item(fname, st.st_mode, FILEFLAGS(st.st_flags), "directory", del_opts) != 0)
f90a882e
WD
245 return;
246 statret = -1;
247 }
fdf967c7 248@@ -1278,7 +1287,7 @@ static void recv_generator(char *fname,
f90a882e
WD
249 }
250 /* Not the right symlink (or not a symlink), so
251 * delete it. */
87d0091c
WD
252- if (delete_item(fname, st.st_mode, "symlink", del_opts) != 0)
253+ if (delete_item(fname, st.st_mode, FILEFLAGS(st.st_flags), "symlink", del_opts) != 0)
f90a882e 254 return;
05031682
WD
255 } else if (basis_dir[0] != NULL) {
256 int j = try_dests_non(file, fname, ndx, fnamecmpbuf, &st,
fdf967c7 257@@ -1355,7 +1364,7 @@ static void recv_generator(char *fname,
05031682
WD
258 goto return_with_success;
259 return;
260 }
87d0091c
WD
261- if (delete_item(fname, st.st_mode, t, del_opts) != 0)
262+ if (delete_item(fname, st.st_mode, FILEFLAGS(st.st_flags), t, del_opts) != 0)
f90a882e 263 return;
05031682
WD
264 } else if (basis_dir[0] != NULL) {
265 int j = try_dests_non(file, fname, ndx, fnamecmpbuf, &st,
fdf967c7 266@@ -1444,7 +1453,7 @@ static void recv_generator(char *fname,
f90a882e
WD
267 fnamecmp_type = FNAMECMP_FNAME;
268
269 if (statret == 0 && !S_ISREG(st.st_mode)) {
87d0091c
WD
270- if (delete_item(fname, st.st_mode, "regular file", del_opts) != 0)
271+ if (delete_item(fname, st.st_mode, FILEFLAGS(st.st_flags), "regular file", del_opts) != 0)
f90a882e
WD
272 return;
273 statret = -1;
274 stat_errno = ENOENT;
31611b92
WD
275--- old/options.c
276+++ new/options.c
1898c899 277@@ -48,6 +48,7 @@ int copy_links = 0;
31611b92
WD
278 int preserve_links = 0;
279 int preserve_hard_links = 0;
280 int preserve_perms = 0;
5e3c6c93 281+int preserve_fileflags = 0;
31611b92
WD
282 int preserve_executability = 0;
283 int preserve_devices = 0;
284 int preserve_specials = 0;
fdf967c7 285@@ -200,6 +201,7 @@ static void print_rsync_version(enum log
31611b92
WD
286 char const *hardlinks = "no ";
287 char const *links = "no ";
288 char const *ipv6 = "no ";
5e3c6c93 289+ char const *fileflags = "no ";
31611b92
WD
290 STRUCT_STAT *dumstat;
291
292 #ifdef HAVE_SOCKETPAIR
fdf967c7 293@@ -222,6 +224,10 @@ static void print_rsync_version(enum log
31611b92
WD
294 ipv6 = "";
295 #endif
296
297+#ifdef SUPPORT_FLAGS
5e3c6c93 298+ fileflags = "";
31611b92
WD
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-2006 by Andrew Tridgell, Wayne Davison, and others.\n");
fdf967c7 304@@ -232,8 +238,8 @@ static void print_rsync_version(enum log
5e3c6c93
WD
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\n",
309- have_inplace);
310+ rprintf(f, " %sappend, %sfile-flags\n",
311+ have_inplace, fileflags);
312
31611b92 313 #ifdef MAINTAINER_MODE
5e3c6c93 314 rprintf(f, "Panic Action: \"%s\"\n", get_panic_action());
fdf967c7 315@@ -299,6 +305,7 @@ void usage(enum logcode F)
31611b92
WD
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");
5e3c6c93 319+ rprintf(F," --fileflags preserve file-flags\n");
31611b92 320 rprintf(F," -E, --executability preserve the file's executability\n");
063cf77b 321 rprintf(F," --chmod=CHMOD affect file and/or directory permissions\n");
31611b92 322 rprintf(F," -o, --owner preserve owner (super-user only)\n");
fdf967c7 323@@ -420,6 +427,8 @@ static struct poptOption long_options[]
31611b92
WD
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 },
5e3c6c93
WD
327+ {"fileflags", 0, POPT_ARG_VAL, &preserve_fileflags, 1, 0, 0 },
328+ {"no-fileflags", 0, POPT_ARG_VAL, &preserve_fileflags, 0, 0, 0 },
31611b92
WD
329 {"executability", 'E', POPT_ARG_NONE, &preserve_executability, 0, 0, 0 },
330 {"times", 't', POPT_ARG_VAL, &preserve_times, 1, 0, 0 },
331 {"no-times", 0, POPT_ARG_VAL, &preserve_times, 0, 0, 0 },
fdf967c7 332@@ -1125,6 +1134,15 @@ int parse_arguments(int *argc, const cha
31611b92
WD
333 }
334 #endif
335
336+#ifndef SUPPORT_FLAGS
5e3c6c93 337+ if (preserve_fileflags) {
31611b92
WD
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");
fdf967c7 348@@ -1579,6 +1597,9 @@ void server_options(char **args,int *arg
31611b92
WD
349 if (xfer_dirs && !recurse && delete_mode && am_sender)
350 args[ac++] = "--no-r";
351
5e3c6c93 352+ if (preserve_fileflags)
31611b92
WD
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
f90a882e
WD
360@@ -30,9 +30,12 @@
361 #include <langinfo.h>
362 #endif
363
364+#define NOCHANGE_FLAGS (UF_IMMUTABLE|UF_APPEND|UF_NOUNLINK|SF_IMMUTABLE|SF_APPEND|SF_NOUNLINK)
365+
ff318e90 366 extern int verbose;
31611b92 367 extern int dry_run;
31611b92 368 extern int preserve_perms;
5e3c6c93 369+extern int preserve_fileflags;
31611b92
WD
370 extern int preserve_executability;
371 extern int preserve_times;
372 extern int omit_dir_times;
70891d26 373@@ -176,6 +179,41 @@ mode_t dest_mode(mode_t flist_mode, mode
f90a882e
WD
374 return new_mode;
375 }
376
377+#ifdef SUPPORT_FLAGS
378+/* Set a file's st_flags. */
379+static int set_fileflags(const char *fname, uint32 fileflags)
380+{
381+ if (do_chflags(fname, fileflags) != 0) {
382+ rsyserr(FERROR, errno,
383+ "failed to set file flags on %s",
384+ full_fname(fname));
385+ return 0;
386+ }
387+
388+ return 1;
389+}
390+
391+/* Remove immutable flags from an object, so it can be altered/removed. */
392+void make_mutable(char *fname, mode_t mode, uint32 fileflags)
393+{
5e3c6c93 394+ if (!preserve_fileflags && S_ISLNK(mode))
f90a882e
WD
395+ return;
396+
397+ if (fileflags & NOCHANGE_FLAGS)
398+ set_fileflags(fname, fileflags & ~NOCHANGE_FLAGS);
399+}
400+
401+/* Undo a prior make_mutable() call. */
402+void undo_make_mutable(char *fname, mode_t mode, uint32 fileflags)
403+{
5e3c6c93 404+ if (!preserve_fileflags && S_ISLNK(mode))
f90a882e
WD
405+ return;
406+
407+ if (fileflags & NOCHANGE_FLAGS)
408+ set_fileflags(fname, fileflags);
409+}
410+#endif
411+
412 int set_file_attrs(char *fname, struct file_struct *file, STRUCT_STAT *st,
413 int flags)
414 {
70891d26 415@@ -274,6 +312,15 @@ int set_file_attrs(char *fname, struct f
31611b92
WD
416 }
417 #endif
418
419+#ifdef SUPPORT_FLAGS
5e3c6c93 420+ if (preserve_fileflags && !S_ISLNK(st->st_mode)
31611b92 421+ && st->st_flags != file->fileflags) {
f90a882e 422+ if (!set_fileflags(fname, file->fileflags))
31611b92 423+ return 0;
31611b92
WD
424+ updated = 1;
425+ }
426+#endif
427+
428 if (verbose > 1 && flags & ATTRS_REPORT) {
ff318e90
WD
429 if (updated)
430 rprintf(FCLIENT, "%s\n", fname);
70891d26 431@@ -321,6 +368,9 @@ void finish_transfer(char *fname, char *
f90a882e
WD
432 set_file_attrs(fnametmp, file, NULL,
433 ok_to_set_time ? 0 : ATTRS_SKIP_MTIME);
31611b92
WD
434
435+#ifdef SUPPORT_FLAGS
9f62ddf8 436+ make_mutable(fnametmp, file->mode, file->fileflags);
31611b92 437+#endif
f90a882e
WD
438 /* move tmp file over real file */
439 if (verbose > 2)
440 rprintf(FINFO, "renaming %s to %s\n", fnametmp, fname);
70891d26 441@@ -335,6 +385,9 @@ void finish_transfer(char *fname, char *
f90a882e
WD
442 }
443 if (ret == 0) {
444 /* The file was moved into place (not copied), so it's done. */
31611b92 445+#ifdef SUPPORT_FLAGS
f90a882e 446+ undo_make_mutable(fname, file->mode, file->fileflags);
31611b92 447+#endif
f90a882e
WD
448 return;
449 }
450 /* The file was copied, so tweak the perms of the copied file. If it
31611b92
WD
451--- old/rsync.h
452+++ new/rsync.h
fdf967c7
WD
453@@ -55,6 +55,7 @@
454 #define XMIT_SAME_DEV_pre30 (1<<10) /* protocols < 30 */
455 #define XMIT_HLINK_FIRST (1<<10) /* protocols >= 30 */
31611b92
WD
456 #define XMIT_RDEV_MINOR_IS_SMALL (1<<11)
457+#define XMIT_SAME_FLAGS (1<<12)
458
459 /* These flags are used in the live flist data. */
460
fdf967c7 461@@ -355,6 +356,10 @@ enum msgcode {
6e6f514c
WD
462 #define schar char
463 #endif
464
465+#ifdef HAVE_CHFLAGS
466+#define SUPPORT_FLAGS 1
467+#endif
468+
469 /* Find a variable that is either exactly 32-bits or longer.
470 * If some code depends on 32-bit truncation, it will need to
471 * take special action in a "#if SIZEOF_INT32 > 4" section. */
fdf967c7
WD
472@@ -522,6 +527,7 @@ struct file_struct {
473 extern int flist_extra_cnt;
474 extern int preserve_uid;
475 extern int preserve_gid;
476+extern int preserve_fileflags;
477
478 #define FILE_STRUCT_LEN (offsetof(struct file_struct, basename))
479 #define EXTRA_LEN (sizeof (union file_extras))
480@@ -554,6 +560,7 @@ extern int preserve_gid;
1aa236e1 481 /* When the associated option is on, all entries will have these present: */
fdf967c7
WD
482 #define F_UID(f) REQ_EXTRA(f, preserve_uid)->unum
483 #define F_GID(f) REQ_EXTRA(f, preserve_gid)->unum
1aa236e1 484+#define F_FFLAGS(f) REQ_EXTRA(f, preserve_fileflags).num
70891d26 485
ee76479d 486 /* These items are per-entry optional and mutally exclusive: */
fdf967c7 487 #define F_HL_GNUM(f) OPT_EXTRA(f, LEN64_BUMP(f))->num
31611b92
WD
488--- old/rsync.yo
489+++ new/rsync.yo
03019e41 490@@ -321,6 +321,7 @@ to the detailed description below for a
1ed0b5c9
WD
491 -K, --keep-dirlinks treat symlinked dir on receiver as dir
492 -H, --hard-links preserve hard links
31611b92 493 -p, --perms preserve permissions
31611b92 494+ --flags preserve file flags
1ed0b5c9 495 -E, --executability preserve executability
063cf77b 496 --chmod=CHMOD affect file and/or directory permissions
31611b92 497 -o, --owner preserve owner (super-user only)
f813befd 498@@ -510,7 +511,9 @@ specified, in which case bf(-r) is not i
31611b92
WD
499
500 Note that bf(-a) bf(does not preserve hardlinks), because
501 finding multiply-linked files is expensive. You must separately
502-specify bf(-H).
503+specify bf(-H). Note also that for compatibility, bf(-a)
504+currently bf(does not include --flags) (see there) to include preserving
505+change file flags (if supported by the OS).
506
507 dit(--no-OPTION) You may turn off one or more implied options by prefixing
508 the option name with "no-". Not all options may be prefixed with a "no-":
f813befd 509@@ -805,6 +808,13 @@ quote(itemization(
31611b92
WD
510
511 If bf(--perms) is enabled, this option is ignored.
512
513+dit(bf(--flags)) This option causes rsync to update the change file flags
f90a882e 514+to be the same as the source file, if your OS supports the bf(chflags)(2)
31611b92
WD
515+system call. In any case, an attempt is made to remove flags that would
516+prevent a file to be altered. Some flags can only be altered by the
517+super-user and can only be unset below a certain secure-level (usually
518+single-user mode).
519+
520 dit(bf(--chmod)) This option tells rsync to apply one or more
521 comma-separated "chmod" strings to the permission of the files in the
522 transfer. The resulting value is treated as though it was the permissions
523--- old/syscall.c
524+++ new/syscall.c
f813befd 525@@ -153,6 +153,15 @@ int do_chmod(const char *path, mode_t mo
31611b92
WD
526 }
527 #endif
528
529+#ifdef SUPPORT_FLAGS
530+int do_chflags(const char *path, u_long flags)
531+{
532+ if (dry_run) return 0;
533+ RETURN_ERROR_IF_RO_OR_LO;
534+ return chflags(path, flags);
535+}
536+#endif
537+
538 int do_rename(const char *fname1, const char *fname2)
539 {
540 if (dry_run) return 0;