Index: files/patch-fileflags.diff
===================================================================
--- files/patch-fileflags.diff	(revision 50817)
+++ files/patch-fileflags.diff	(working copy)
@@ -65,7 +65,7 @@
 diff --git a/configure.in b/configure.in
 --- a/configure.in
 +++ b/configure.in
-@@ -553,7 +553,7 @@ AC_CHECK_FUNCS(waitpid wait4 getcwd strdup chown chmod lchmod mknod mkfifo \
+@@ -551,7 +551,7 @@ AC_CHECK_FUNCS(waitpid wait4 getcwd strdup chown chmod lchmod mknod mkfifo \
      memmove lchown vsnprintf snprintf vasprintf asprintf setsid strpbrk \
      strlcat strlcpy strtol mallinfo getgroups setgroups geteuid getegid \
      setlocale setmode open64 lseek64 mkstemp64 mtrace va_copy __va_copy \
@@ -108,9 +108,9 @@
 +	}
 +#endif
  
- 	if ((preserve_devices && IS_DEVICE(mode))
- 	 || (preserve_specials && IS_SPECIAL(mode))) {
-@@ -538,6 +550,10 @@ static void send_file_entry(int f, const char *fname, struct file_struct *file,
+ 	if (preserve_devices && IS_DEVICE(mode)) {
+ 		if (protocol_version < 28) {
+@@ -548,6 +560,10 @@ static void send_file_entry(int f, const char *fname, struct file_struct *file,
  	}
  	if (!(xflags & XMIT_SAME_MODE))
  		write_int(f, to_wire_mode(mode));
@@ -121,7 +121,7 @@
  	if (preserve_uid && !(xflags & XMIT_SAME_UID)) {
  		if (protocol_version < 30)
  			write_int(f, uid);
-@@ -624,6 +640,9 @@ static struct file_struct *recv_file_entry(struct file_list *flist,
+@@ -634,6 +650,9 @@ static struct file_struct *recv_file_entry(struct file_list *flist,
  {
  	static int64 modtime;
  	static mode_t mode;
@@ -131,7 +131,7 @@
  #ifdef SUPPORT_HARD_LINKS
  	static int64 dev;
  #endif
-@@ -759,6 +778,10 @@ static struct file_struct *recv_file_entry(struct file_list *flist,
+@@ -768,6 +787,10 @@ static struct file_struct *recv_file_entry(struct file_list *flist,
  
  	if (chmod_modes && !S_ISLNK(mode))
  		mode = tweak_mode(mode, chmod_modes);
@@ -142,7 +142,7 @@
  
  	if (preserve_uid && !(xflags & XMIT_SAME_UID)) {
  		if (protocol_version < 30)
-@@ -899,6 +922,10 @@ static struct file_struct *recv_file_entry(struct file_list *flist,
+@@ -909,6 +932,10 @@ static struct file_struct *recv_file_entry(struct file_list *flist,
  	}
  #endif
  	file->mode = mode;
@@ -153,7 +153,7 @@
  	if (preserve_uid)
  		F_OWNER(file) = uid;
  	if (preserve_gid) {
-@@ -1273,6 +1300,10 @@ struct file_struct *make_file(const char *fname, struct file_list *flist,
+@@ -1283,6 +1310,10 @@ struct file_struct *make_file(const char *fname, struct file_list *flist,
  	}
  #endif
  	file->mode = st.st_mode;
@@ -164,7 +164,7 @@
  	if (uid_ndx) /* Check uid_ndx instead of preserve_uid for del support */
  		F_OWNER(file) = st.st_uid;
  	if (gid_ndx) /* Check gid_ndx instead of preserve_gid for del support */
-@@ -1408,6 +1439,7 @@ static struct file_struct *send_file_name(int f, struct file_list *flist,
+@@ -1426,6 +1457,7 @@ static struct file_struct *send_file_name(int f, struct file_list *flist,
  #endif
  #ifdef SUPPORT_XATTRS
  		if (preserve_xattrs) {
@@ -286,7 +286,7 @@
  
  #ifdef SUPPORT_HARD_LINKS
  	if (preserve_hard_links && F_HLINK_NOT_FIRST(file)
-@@ -2054,13 +2090,17 @@ static void touch_up_dirs(struct file_list *flist, int ndx)
+@@ -2058,13 +2094,17 @@ static void touch_up_dirs(struct file_list *flist, int ndx)
  			continue;
  		fname = f_name(file, NULL);
  		if (!(file->mode & S_IWUSR))
@@ -416,7 +416,7 @@
    {"ignore-errors",    0,  POPT_ARG_VAL,    &ignore_errors, 1, 0, 0 },
    {"no-ignore-errors", 0,  POPT_ARG_VAL,    &ignore_errors, 0, 0, 0 },
    {"max-delete",       0,  POPT_ARG_INT,    &max_delete, 0, 0, 0 },
-@@ -1868,6 +1894,9 @@ void server_options(char **args, int *argc_p)
+@@ -1874,6 +1900,9 @@ void server_options(char **args, int *argc_p)
  	if (xfer_dirs && !recurse && delete_mode && am_sender)
  		args[ac++] = "--no-r";
  
@@ -426,7 +426,7 @@
  	if (do_compression && def_compress_level != Z_DEFAULT_COMPRESSION) {
  		if (asprintf(&arg, "--compress-level=%d", def_compress_level) < 0)
  			goto oom;
-@@ -1955,6 +1984,16 @@ void server_options(char **args, int *argc_p)
+@@ -1961,6 +1990,16 @@ void server_options(char **args, int *argc_p)
  			args[ac++] = "--delete-excluded";
  		if (force_delete)
  			args[ac++] = "--force";
@@ -662,7 +662,7 @@
       --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
-@@ -544,7 +548,8 @@ specified, in which case bf(-r) is not implied.
+@@ -547,7 +551,8 @@ specified, in which case bf(-r) is not implied.
  
  Note that bf(-a) bf(does not preserve hardlinks), because
  finding multiply-linked files is expensive.  You must separately
@@ -672,7 +672,7 @@
  
  dit(--no-OPTION) You may turn off one or more implied options by prefixing
  the option name with "no-".  Not all options may be prefixed with a "no-":
-@@ -802,7 +807,7 @@ they would be using bf(--copy-links).
+@@ -809,7 +814,7 @@ they would be using bf(--copy-links).
  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
@@ -681,7 +681,7 @@
  
  See also bf(--keep-dirlinks) for an analogous option for the receiving
  side.
-@@ -939,6 +944,29 @@ super-user copies all namespaces except system.*.  A normal user only copies
+@@ -946,6 +951,29 @@ super-user copies all namespaces except system.*.  A normal user only copies
  the user.* namespace.  To be able to backup and restore non-user namespaces as
  a normal user, see the bf(--fake-super) option.
  
@@ -711,7 +711,7 @@
  dit(bf(--chmod)) This option tells rsync to apply one or more
  comma-separated "chmod" strings to the permission of the files in the
  transfer.  The resulting value is treated as though it was the permissions
-@@ -1201,12 +1229,13 @@ See bf(--delete) (which is implied) for more details on file-deletion.
+@@ -1216,12 +1244,13 @@ See bf(--delete) (which is implied) for more details on file-deletion.
  dit(bf(--ignore-errors)) Tells bf(--delete) to go ahead and delete files
  even when there are I/O errors.
  
@@ -728,7 +728,7 @@
  bf(--recursive) option was also enabled.
  
  dit(bf(--max-delete=NUM)) This tells rsync not to delete more than NUM
-@@ -1667,7 +1696,7 @@ with older versions of rsync, but that also turns on the output of other
+@@ -1686,7 +1715,7 @@ with older versions of rsync, but that also turns on the output of other
  verbose messages).
  
  The "%i" escape has a cryptic output that is 11 letters long.  The general
@@ -737,7 +737,7 @@
  type of update being done, bf(X) is replaced by the file-type, and the
  other letters represent attributes that may be output if they are being
  modified.
-@@ -1723,7 +1752,7 @@ quote(itemization(
+@@ -1742,7 +1771,7 @@ quote(itemization(
    sender's value (requires bf(--owner) and super-user privileges).
    it() A bf(g) means the group is different and is being updated to the
    sender's value (requires bf(--group) and the authority to set the group).
@@ -1049,7 +1049,7 @@
 diff --git a/xattrs.c b/xattrs.c
 --- a/xattrs.c
 +++ b/xattrs.c
-@@ -281,6 +281,10 @@ int get_xattr(const char *fname, stat_x *sxp)
+@@ -283,6 +283,10 @@ int get_xattr(const char *fname, stat_x *sxp)
  {
  	sxp->xattr = new(item_list);
  	*sxp->xattr = empty_xattr;
@@ -1060,7 +1060,7 @@
  	if (rsync_xal_get(fname, sxp->xattr) < 0) {
  		free_xattr(sxp);
  		return -1;
-@@ -864,6 +868,11 @@ int set_xattr(const char *fname, const struct file_struct *file,
+@@ -883,6 +887,11 @@ int set_xattr(const char *fname, const struct file_struct *file,
  		return -1;
  	}
  
@@ -1072,12 +1072,191 @@
  	ndx = F_XATTR(file);
  	return rsync_xal_set(fname, lst + ndx, fnamecmp, sxp);
  }
-@@ -980,7 +989,7 @@ int set_stat_xattr(const char *fname, struct file_struct *file, mode_t new_mode)
+@@ -999,7 +1008,7 @@ int set_stat_xattr(const char *fname, struct file_struct *file, mode_t new_mode)
  	mode = (fst.st_mode & _S_IFMT) | (fmode & ACCESSPERMS)
  	     | (S_ISDIR(fst.st_mode) ? 0700 : 0600);
  	if (fst.st_mode != mode)
 -		do_chmod(fname, mode);
 +		do_chmod(fname, mode, ST_FLAGS(fst));
- 	if (!IS_DEVICE(fst.st_mode) && !IS_SPECIAL(fst.st_mode))
+ 	if (!IS_DEVICE(fst.st_mode))
  		fst.st_rdev = 0; /* just in case */
  
+diff -up a/config.h.in b/config.h.in
+--- a/config.h.in
++++ b/config.h.in
+@@ -70,6 +70,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
+@@ -15031,12 +15031,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 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=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
+diff -up a/proto.h b/proto.h
+--- a/proto.h
++++ b/proto.h
+@@ -274,6 +274,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));
+@@ -298,11 +300,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);
+@@ -330,7 +333,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
+@@ -417,6 +417,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)
+@@ -448,7 +449,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
+@@ -638,7 +642,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
+@@ -931,7 +936,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.
+@@ -1086,6 +1091,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
+@@ -1386,13 +1418,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"
+@@ -1928,7 +1961,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.
+@@ -1998,7 +2031,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 
Index: files/patch-osx-xattr-nodev.diff
===================================================================
--- files/patch-osx-xattr-nodev.diff	(revision 0)
+++ files/patch-osx-xattr-nodev.diff	(revision 0)
@@ -0,0 +1,47 @@
+This patch makes the xattr functions skip devices and special files,
+because OS X returns the wrong errno when getting/setting xattrs on
+them (it returns EPERM instead of ENOTSUP).
+
+To use this patch, run these commands for a successful build:
+
+    patch -p1 <patches/osx-xattr-nodev.diff
+    ./configure                         (optional if already run)
+    make
+
+diff --git a/flist.c b/flist.c
+--- a/flist.c
++++ b/flist.c
+@@ -1426,6 +1426,7 @@ static struct file_struct *send_file_name(int f, struct file_list *flist,
+ #endif
+ #ifdef SUPPORT_XATTRS
+ 		if (preserve_xattrs) {
++			sx.st.st_mode = file->mode;
+ 			sx.xattr = NULL;
+ 			if (get_xattr(fname, &sx) < 0) {
+ 				io_error |= IOERR_GENERAL;
+diff --git a/xattrs.c b/xattrs.c
+--- a/xattrs.c
++++ b/xattrs.c
+@@ -283,6 +283,10 @@ int get_xattr(const char *fname, stat_x *sxp)
+ {
+ 	sxp->xattr = new(item_list);
+ 	*sxp->xattr = empty_xattr;
++
++	if (IS_SPECIAL(sxp->st.st_mode) || IS_DEVICE(sxp->st.st_mode))
++		return 0;
++
+ 	if (rsync_xal_get(fname, sxp->xattr) < 0) {
+ 		free_xattr(sxp);
+ 		return -1;
+@@ -883,6 +887,11 @@ int set_xattr(const char *fname, const struct file_struct *file,
+ 		return -1;
+ 	}
+ 
++	if (IS_SPECIAL(sxp->st.st_mode) || IS_DEVICE(sxp->st.st_mode)) {
++		errno = ENOTSUP;
++		return -1;
++	}
++
+ 	ndx = F_XATTR(file);
+ 	return rsync_xal_set(fname, lst + ndx, fnamecmp, sxp);
+ }
Index: files/patch-crtimes.diff
===================================================================
--- files/patch-crtimes.diff	(revision 50817)
+++ files/patch-crtimes.diff	(working copy)
@@ -57,7 +57,7 @@
  	static mode_t mode;
  #ifdef SUPPORT_FILEFLAGS
  	static uint32 fileflags;
-@@ -479,6 +480,13 @@ static void send_file_entry(int f, const char *fname, struct file_struct *file,
+@@ -489,6 +490,13 @@ static void send_file_entry(int f, const char *fname, struct file_struct *file,
  		xflags |= XMIT_SAME_TIME;
  	else
  		modtime = file->modtime;
@@ -71,7 +71,7 @@
  
  #ifdef SUPPORT_HARD_LINKS
  	if (tmp_dev != 0) {
-@@ -548,6 +556,8 @@ static void send_file_entry(int f, const char *fname, struct file_struct *file,
+@@ -558,6 +566,8 @@ static void send_file_entry(int f, const char *fname, struct file_struct *file,
  		else
  			write_int(f, modtime);
  	}
@@ -80,7 +80,7 @@
  	if (!(xflags & XMIT_SAME_MODE))
  		write_int(f, to_wire_mode(mode));
  #ifdef SUPPORT_FILEFLAGS
-@@ -638,7 +648,7 @@ static void send_file_entry(int f, const char *fname, struct file_struct *file,
+@@ -648,7 +658,7 @@ static void send_file_entry(int f, const char *fname, struct file_struct *file,
  static struct file_struct *recv_file_entry(struct file_list *flist,
  					   int xflags, int f)
  {
@@ -89,16 +89,16 @@
  	static mode_t mode;
  #ifdef SUPPORT_FILEFLAGS
  	static uint32 fileflags;
-@@ -744,6 +754,8 @@ static struct file_struct *recv_file_entry(struct file_list *flist,
+@@ -754,6 +764,8 @@ static struct file_struct *recv_file_entry(struct file_list *flist,
  				uid = F_OWNER(first);
  			if (preserve_gid)
  				gid = F_GROUP(first);
 +			if (crtimes_ndx)
 +				crtime = f_crtime(first);
- 			if ((preserve_devices && IS_DEVICE(mode))
- 			 || (preserve_specials && IS_SPECIAL(mode))) {
+ 			if (preserve_devices && IS_DEVICE(mode)) {
  				uint32 *devp = F_RDEV_P(first);
-@@ -773,6 +785,19 @@ static struct file_struct *recv_file_entry(struct file_list *flist,
+ 				rdev = MAKEDEV(DEV_MAJOR(devp), DEV_MINOR(devp));
+@@ -782,6 +794,19 @@ static struct file_struct *recv_file_entry(struct file_list *flist,
  		} else
  			modtime = read_int(f);
  	}
@@ -118,7 +118,7 @@
  	if (!(xflags & XMIT_SAME_MODE))
  		mode = from_wire_mode(read_int(f));
  
-@@ -932,6 +957,8 @@ static struct file_struct *recv_file_entry(struct file_list *flist,
+@@ -942,6 +967,8 @@ static struct file_struct *recv_file_entry(struct file_list *flist,
  		F_GROUP(file) = gid;
  		file->flags |= gid_flags;
  	}
@@ -127,7 +127,7 @@
  	if (unsort_ndx)
  		F_NDX(file) = flist->used + flist->ndx_start;
  
-@@ -1308,6 +1335,8 @@ struct file_struct *make_file(const char *fname, struct file_list *flist,
+@@ -1318,6 +1345,8 @@ struct file_struct *make_file(const char *fname, struct file_list *flist,
  		F_OWNER(file) = st.st_uid;
  	if (gid_ndx) /* Check gid_ndx instead of preserve_gid for del support */
  		F_GROUP(file) = st.st_gid;
@@ -182,34 +182,45 @@
  #if !defined HAVE_LCHMOD && !defined HAVE_SETATTRLIST
  		if (S_ISLNK(file->mode)) {
  			;
-@@ -1226,6 +1241,7 @@ static int try_dests_non(struct file_struct *file, char *fname, int ndx,
+@@ -1225,7 +1240,7 @@ static int try_dests_non(struct file_struct *file, char *fname, int ndx,
+ 
  static void list_file_entry(struct file_struct *f)
  {
- 	char permbuf[PERMSTRING_SIZE];
-+	time_t crtime = crtimes_ndx ? f_crtime(f) : 0;
+-	char permbuf[PERMSTRING_SIZE];
++	char permbuf[PERMSTRING_SIZE], crtime_buf[32];
  	double len;
  
  	if (!F_IS_ACTIVE(f)) {
-@@ -1240,14 +1256,16 @@ static void list_file_entry(struct file_struct *f)
+@@ -1236,19 +1251,24 @@ static void list_file_entry(struct file_struct *f)
+ 	permstring(permbuf, f->mode);
+ 	len = F_LENGTH(f);
  
++	if (crtimes_ndx)
++		snprintf(crtime_buf, sizeof crtime_buf, " %s", timestring(f_crtime(f)));
++	else
++		*crtime_buf = '\0';
++
+ 	/* TODO: indicate '+' if the entry has an ACL. */
+ 
  #ifdef SUPPORT_LINKS
  	if (preserve_links && S_ISLNK(f->mode)) {
 -		rprintf(FINFO, "%s %11.0f %s %s -> %s\n",
-+		rprintf(FINFO, "%s %11.0f %s %s %s -> %s\n",
++		rprintf(FINFO, "%s %11.0f %s%s %s -> %s\n",
  			permbuf, len, timestring(f->modtime),
-+			crtimes_ndx ? timestring(crtime) : "",
- 			f_name(f, NULL), F_SYMLINK(f));
+-			f_name(f, NULL), F_SYMLINK(f));
++			crtime_buf, f_name(f, NULL), F_SYMLINK(f));
  	} else
  #endif
  	{
 -		rprintf(FINFO, "%s %11.0f %s %s\n",
-+		rprintf(FINFO, "%s %11.0f %s %s %s\n",
++		rprintf(FINFO, "%s %11.0f %s%s %s\n",
  			permbuf, len, timestring(f->modtime),
-+			crtimes_ndx ? timestring(crtime) : "",
- 			f_name(f, NULL));
+-			f_name(f, NULL));
++			crtime_buf, f_name(f, NULL));
  	}
  }
-@@ -1339,6 +1357,7 @@ static void recv_generator(char *fname, struct file_struct *file, int ndx,
+ 
+@@ -1339,6 +1359,7 @@ static void recv_generator(char *fname, struct file_struct *file, int ndx,
  			return;
  		}
  	}
@@ -310,7 +321,7 @@
    {"omit-dir-times",  'O', POPT_ARG_VAL,    &omit_dir_times, 1, 0, 0 },
    {"no-omit-dir-times",0,  POPT_ARG_VAL,    &omit_dir_times, 0, 0, 0 },
    {"no-O",             0,  POPT_ARG_VAL,    &omit_dir_times, 0, 0, 0 },
-@@ -1800,6 +1805,8 @@ void server_options(char **args, int *argc_p)
+@@ -1806,6 +1811,8 @@ void server_options(char **args, int *argc_p)
  		argstr[x++] = 'D';
  	if (preserve_times)
  		argstr[x++] = 't';
@@ -426,7 +437,7 @@
       --super                 receiver attempts super-user activities
       --fake-super            store/recover privileged attrs using xattrs
   -S, --sparse                handle sparse files efficiently
-@@ -1032,6 +1033,9 @@ it is preserving modification times (see bf(--times)).  If NFS is sharing
+@@ -1039,6 +1040,9 @@ it is preserving modification times (see bf(--times)).  If NFS is sharing
  the directories on the receiving side, it is a good idea to use bf(-O).
  This option is inferred if you use bf(--backup) without bf(--backup-dir).
  
@@ -436,7 +447,7 @@
  dit(bf(--super)) This tells the receiving side to attempt super-user
  activities even if the receiving rsync wasn't run by the super-user.  These
  activities include: preserving users via the bf(--owner) option, preserving
-@@ -1696,7 +1700,7 @@ with older versions of rsync, but that also turns on the output of other
+@@ -1715,7 +1719,7 @@ with older versions of rsync, but that also turns on the output of other
  verbose messages).
  
  The "%i" escape has a cryptic output that is 11 letters long.  The general
@@ -445,7 +456,7 @@
  type of update being done, bf(X) is replaced by the file-type, and the
  other letters represent attributes that may be output if they are being
  modified.
-@@ -1755,6 +1759,8 @@ quote(itemization(
+@@ -1774,6 +1778,8 @@ quote(itemization(
    it() The bf(f) means that the fileflags information changed.
    it() The bf(a) means that the ACL information changed.
    it() The bf(x) means that the extended attribute information changed.
@@ -649,3 +660,56 @@
    fprintf(F," -l, --link-times            display the time on a symlink\n");
    fprintf(F," -L, --link-owner            display the owner+group on a symlink\n");
  #ifdef SUPPORT_XATTRS
+diff -up a/proto.h b/proto.h
+--- a/proto.h
++++ b/proto.h
+@@ -314,6 +314,8 @@ int do_stat(const char *fname, STRUCT_ST
+ int do_lstat(const char *fname, STRUCT_STAT *st);
+ int do_fstat(int fd, STRUCT_STAT *st);
+ OFF_T do_lseek(int fd, OFF_T offset, int whence);
++time_t get_create_time(const char *path);
++int set_create_time(const char *path, time_t crtime);
+ void set_compression(const char *fname);
+ void send_token(int f, int32 token, struct map_struct *buf, OFF_T offset,
+ 		int32 n, int32 toklen);
+diff -up a/rsync.1 b/rsync.1
+--- a/rsync.1
++++ b/rsync.1
+@@ -429,6 +429,7 @@ to the detailed description below for a 
+  \-D                          same as \-\-devices \-\-specials
+  \-t, \-\-times                 preserve modification times
+  \-O, \-\-omit\-dir\-times        omit directories from \-\-times
++ \-N, \-\-crtimes               preserve create times (newness)
+      \-\-super                 receiver attempts super-user activities
+      \-\-fake\-super            store/recover privileged attrs using xattrs
+  \-S, \-\-sparse                handle sparse files efficiently
+@@ -1194,6 +1195,10 @@ it is preserving modification times (see
+ the directories on the receiving side, it is a good idea to use \fB\-O\fP.
+ This option is inferred if you use \fB\-\-backup\fP without \fB\-\-backup\-dir\fP.
+ .IP 
++.IP "\fB\-N, \-\-crtimes\fP"
++This tells rsync to set the create times (newness) of
++the destination files to the same value as the source files.
++.IP 
+ .IP "\fB\-\-super\fP"
+ This tells the receiving side to attempt super-user
+ activities even if the receiving rsync wasn't run by the super-user.  These
+@@ -1961,7 +1966,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 \fBYXcstpogfax\fP, where \fBY\fP is replaced by the
++format is like the string \fBYXcstpogfaxn\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.
+@@ -2036,6 +2041,9 @@ The \fBf\fP means that the fileflags inf
+ The \fBa\fP means that the ACL information changed.
+ .IP o 
+ The \fBx\fP means that the extended attribute information changed.
++.IP o 
++A \fBn\fP means the create time (newness) is different and is being
++updated to the sender's value (requires \fB\-\-crtimes\fP).
+ .RE
+ 
+ .IP 
Index: Portfile
===================================================================
--- Portfile	(revision 50817)
+++ Portfile	(working copy)
@@ -3,7 +3,7 @@
 PortSystem          1.0
 
 name                rsync
-version             3.0.5
+version             3.0.6
 categories          net
 platforms           darwin freebsd sunos
 maintainers         simon openmaintainer
@@ -13,7 +13,7 @@
                     under the GNU General Public License and is currently \
                     being maintained by Wayne Davison. \
                     \
-                    Rsync version 3.0.5 has been released. This is a \
+                    Rsync version 3.0.6 has been released. This is a \
                     bug-fix release. Related pages: \
                     http://rsync.samba.org/ftp/rsync/rsync-${version}-NEWS
 
@@ -21,9 +21,9 @@
 master_sites        http://rsync.samba.org/ftp/rsync/ \
                     http://rsync.samba.org/ftp/rsync/src/
 checksums           ${distname}${extract.suffix} \
-                        md5 a130e736c011572cb423b6245e97fc4b \
-                        sha1 d95e75af9456b0edca68bde17260c98261b4b8c5 \
-                        rmd160 c2a223c7afc29be413b593deaa2187f5d000f7a6
+                        md5 e9865d093a18e4668b9d31b635dc8e99 \
+                        sha1 8853dfd291b3850aafa60169d2eea8601498f713 \
+                        rmd160 881ecea519b97d1a7f326b021ebac939ac2fe091
 distname            rsync-${version}
 
 depends_lib         port:popt port:libiconv
