diff -up a/config.h.in b/config.h.in
--- a/config.h.in
+++ b/config.h.in
@@ -64,6 +64,9 @@
/* Define to 1 if vsprintf has a C99-compatible return value */
#undef HAVE_C99_VSNPRINTF
+/* Define to 1 if you have the `chflags' function. */
+#undef HAVE_CHFLAGS
+
/* Define to 1 if you have the `chmod' function. */
#undef HAVE_CHMOD
diff -up a/configure.sh b/configure.sh
--- a/configure.sh
+++ b/configure.sh
@@ -14789,12 +14789,13 @@ fi
+
for ac_func in waitpid wait4 getcwd strdup chown chmod lchmod mknod
mkfifo \
fchmod fstat ftruncate strchr readlink link utime utimes
lutimes strftime \
memmove lchown vsnprintf snprintf vasprintf asprintf setsid
glob strpbrk \
strlcat strlcpy strtol mallinfo getgroups setgroups geteuid
getegid \
setlocale setmode open64 lseek64 mkstemp64 mtrace va_copy
__va_copy \
- strerror putenv iconv_open locale_charset nl_langinfo getxattr \
+ chflags strerror putenv iconv_open locale_charset nl_langinfo
getxattr \
extattr_get_link sigaction sigprocmask setattrlist
do
as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
diff -up a/proto.h b/proto.h
--- a/proto.h
+++ b/proto.h
@@ -269,6 +269,8 @@ int read_ndx_and_attrs(int f_in, int *if
void free_sums(struct sum_struct *s);
mode_t dest_mode(mode_t flist_mode, mode_t stat_mode, int dflt_perms,
int exists);
+int make_mutable(const char *fname, mode_t mode, uint32 fileflags,
uint32 iflags);
+int undo_make_mutable(const char *fname, uint32 fileflags);
int set_file_attrs(const char *fname, struct file_struct *file,
stat_x *sxp,
const char *fnamecmp, int flags);
RETSIGTYPE sig_int(UNUSED(int val));
@@ -293,11 +295,12 @@ int sock_exec(const char *prog);
int do_unlink(const char *fname);
int do_symlink(const char *fname1, const char *fname2);
int do_link(const char *fname1, const char *fname2);
-int do_lchown(const char *path, uid_t owner, gid_t group);
+int do_lchown(const char *path, uid_t owner, gid_t group, mode_t
mode, uint32 fileflags);
int do_mknod(const char *pathname, mode_t mode, dev_t dev);
int do_rmdir(const char *pathname);
int do_open(const char *pathname, int flags, mode_t mode);
-int do_chmod(const char *path, mode_t mode);
+int do_chmod(const char *path, mode_t mode, uint32 fileflags);
+int do_chflags(const char *path, uint32 fileflags);
int do_rename(const char *fname1, const char *fname2);
void trim_trailing_slashes(char *name);
int do_mkdir(char *fname, mode_t mode);
@@ -326,7 +329,7 @@ int fd_pair(int fd[2]);
void print_child_argv(const char *prefix, char **cmd);
NORETURN void out_of_memory(const char *str);
NORETURN void overflow_exit(const char *str);
-int set_modtime(const char *fname, time_t modtime, mode_t mode);
+int set_modtime(const char *fname, time_t modtime, mode_t mode,
uint32 fileflags);
int mkdir_defmode(char *fname);
int create_directory_path(char *fname);
int full_write(int desc, const char *ptr, size_t len);
diff -up a/rsync.1 b/rsync.1
--- a/rsync.1
+++ b/rsync.1
@@ -413,6 +413,7 @@ to the detailed description below for a
\-K, \-\-keep\-dirlinks treat symlinked dir on receiver as
dir
\-H, \-\-hard\-links preserve hard links
\-p, \-\-perms preserve permissions
+ \-\-fileflags preserve file-flags (aka chflags)
\-E, \-\-executability preserve executability
\-\-chmod=CHMOD affect file and/or directory
permissions
\-A, \-\-acls preserve ACLs (implies \-p)
@@ -444,7 +445,10 @@ to the detailed description below for a
\-\-delete\-after receiver deletes after transfer,
not before
\-\-delete\-excluded also delete excluded files from
dest dirs
\-\-ignore\-errors delete even if there are I/O errors
- \-\-force force deletion of dirs even if not
empty
+ \-\-force\-delete force deletion of dirs even if not
empty
+ \-\-force\-change affect user/system immutable files/
dirs
+ \-\-force\-uchange affect user-immutable files/dirs
+ \-\-force\-schange affect system-immutable files/dirs
\-\-max\-delete=NUM don't delete more than NUM files
\-\-max\-size=SIZE don't transfer any file larger than
SIZE
\-\-min\-size=SIZE don't transfer any file smaller
than SIZE
@@ -631,7 +635,8 @@ specified, in which case \fB\-r\fP is no
.IP
Note that \fB\-a\fP \fBdoes not preserve hardlinks\fP, because
finding multiply-linked files is expensive. You must separately
-specify \fB\-H\fP.
+specify \fB\-H\fP. Note also that for backward compatibility, \fB\-
a\fP
+currently does \fBnot\fP imply the \fB\-\-fileflags\fP option.
.IP
.IP "\-\-no\-OPTION"
You may turn off one or more implied options by prefixing
@@ -907,7 +912,7 @@ they would be using \fB\-\-copy\-links\f
Without this option, if the sending side has replaced a directory
with a
symlink to a directory, the receiving side will delete anything
that is in
the way of the new symlink, including a directory hierarchy (as
long as
-\fB\-\-force\fP or \fB\-\-delete\fP is in effect).
+\fB\-\-force\-delete\fP or \fB\-\-delete\fP is in effect).
.IP
See also \fB\-\-keep\-dirlinks\fP for an analogous option for the
receiving
side.
@@ -1062,6 +1067,33 @@ super-user copies all namespaces except
the user.* namespace. To be able to backup and restore non-user
namespaces as
a normal user, see the \fB\-\-fake\-super\fP option.
.IP
+.IP "\fB\-\-fileflags\fP"
+This option causes rsync to update the file-flags to be
+the same as the source files and directories (if your OS supports the
+\fBchflags\fP(2) system call). Some flags can only be altered by
the super-user
+and some might only be unset below a certain secure-level (usually
single-user
+mode). It will not make files alterable that are set to immutable
on the
+receiver. To do that, see \fB\-\-force\-change\fP, \fB\-\-force\-
uchange\fP, and
+\fB\-\-force\-schange\fP.
+.IP
+.IP "\fB\-\-force\-change\fP"
+This option causes rsync to disable both user-immutable
+and system-immutable flags on files and directories that are being
updated or
+deleted on the receiving side. This option overrides \fB\-\-force\-
uchange\fP and
+\fB\-\-force\-schange\fP.
+.IP
+.IP "\fB\-\-force\-uchange\fP"
+This option causes rsync to disable user-immutable
+flags on files and directories that are being updated or deleted on
the
+receiving side. It does not try to affect system flags. This
option overrides
+\fB\-\-force\-change\fP and \fB\-\-force\-schange\fP.
+.IP
+.IP "\fB\-\-force\-schange\fP"
+This option causes rsync to disable system-immutable
+flags on files and directories that are being updated or deleted on
the
+receiving side. It does not try to affect user flags. This option
overrides
+\fB\-\-force\-change\fP and \fB\-\-force\-schange\fP.
+.IP
.IP "\fB\-\-chmod\fP"
This option tells rsync to apply one or more
comma-separated \(lqchmod\(rq strings to the permission of the
files in the
@@ -1347,13 +1379,14 @@ See \fB\-\-delete\fP (which is implied)
Tells \fB\-\-delete\fP to go ahead and delete files
even when there are I/O errors.
.IP
-.IP "\fB\-\-force\fP"
+.IP "\fB\-\-force\-delete\fP"
This option tells rsync to delete a non-empty directory
when it is to be replaced by a non-directory. This is only
relevant if
deletions are not active (see \fB\-\-delete\fP for details).
.IP
-Note for older rsync versions: \fB\-\-force\fP used to still be
required when
-using \fB\-\-delete\-after\fP, and it used to be non-functional
unless the
+This option can be abbreviated \fB\-\-force\fP for backward
compatibility.
+Note that some older rsync versions used to still require \fB\-\-
force\fP
+when using \fB\-\-delete\-after\fP, and it used to be non-
functional unless the
\fB\-\-recursive\fP option was also enabled.
.IP
.IP "\fB\-\-max\-delete=NUM\fP"
@@ -1880,7 +1913,7 @@ with older versions of rsync, but that a
verbose messages).
.IP
The \(lq%i\(rq escape has a cryptic output that is 11 letters
long. The general
-format is like the string \fBYXcstpoguax\fP, where \fBY\fP is
replaced by the
+format is like the string \fBYXcstpogfax\fP, where \fBY\fP is
replaced by the
type of update being done, \fBX\fP is replaced by the file-type,
and the
other letters represent attributes that may be output if they are
being
modified.
@@ -1945,7 +1978,7 @@ sender's value (requires \fB\-\-owner\fP
A \fBg\fP means the group is different and is being updated to the
sender's value (requires \fB\-\-group\fP and the authority to set
the group).
.IP o
-The \fBu\fP slot is reserved for future use.
+The \fBf\fP means that the fileflags information changed.
.IP o
The \fBa\fP means that the ACL information changed.
.IP o