<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[121462] trunk/dports/net/rsync</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="https://trac.macports.org/changeset/121462">121462</a></dd>
<dt>Author</dt> <dd>mojca@macports.org</dd>
<dt>Date</dt> <dd>2014-06-25 18:16:27 -0700 (Wed, 25 Jun 2014)</dd>
</dl>

<h3>Log Message</h3>
<pre>rsync: upgrade to 3.1.1 (maintainer, #44117)</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkdportsnetrsyncPortfile">trunk/dports/net/rsync/Portfile</a></li>
<li><a href="#trunkdportsnetrsyncfilespatchcrtimesdiff">trunk/dports/net/rsync/files/patch-crtimes.diff</a></li>
<li><a href="#trunkdportsnetrsyncfilespatchfileflagsdiff">trunk/dports/net/rsync/files/patch-fileflags.diff</a></li>
<li><a href="#trunkdportsnetrsyncfilespatchhfscompressionoptionsdiff">trunk/dports/net/rsync/files/patch-hfs-compression-options.diff</a></li>
<li><a href="#trunkdportsnetrsyncfilespatchhfscompressiondiff">trunk/dports/net/rsync/files/patch-hfs-compression.diff</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkdportsnetrsyncPortfile"></a>
<div class="modfile"><h4>Modified: trunk/dports/net/rsync/Portfile (121461 => 121462)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/dports/net/rsync/Portfile        2014-06-26 00:50:01 UTC (rev 121461)
+++ trunk/dports/net/rsync/Portfile        2014-06-26 01:16:27 UTC (rev 121462)
</span><span class="lines">@@ -4,8 +4,8 @@
</span><span class="cx"> PortSystem          1.0
</span><span class="cx"> 
</span><span class="cx"> name                rsync
</span><del>-version             3.0.9
-revision            2
</del><ins>+version             3.1.1
+revision            0
</ins><span class="cx"> categories          net
</span><span class="cx"> license             GPL-3+
</span><span class="cx"> installs_libs       no
</span><span class="lines">@@ -21,14 +21,14 @@
</span><span class="cx"> master_sites        http://rsync.samba.org/ftp/rsync/ \
</span><span class="cx">                     http://rsync.samba.org/ftp/rsync/src/
</span><span class="cx"> 
</span><del>-checksums           md5     5ee72266fe2c1822333c407e1761b92b \
-                    sha1    c64c8341984aea647506eb504496999fd968ddfc \
-                    rmd160  e5ee8d786defb0d8f937c8d027466f418c63c97e \
-                    sha256  30f10f8dd5490d28240d4271bb652b1da7a60b22ed2b9ae28090668de9247c05
</del><ins>+checksums           md5     43bd6676f0b404326eee2d63be3cdcfe \
+                    sha1    c84faba04f721d393feccfa0476bfeed9b5b5250 \
+                    rmd160  de7ad955cb05d481a963aa30423790f3d82efe7b \
+                    sha256  7de4364fcf5fe42f3bdb514417f1c40d10bbca896abe7e7f2c581c6ea08a2621
</ins><span class="cx"> 
</span><span class="cx"> depends_lib         port:popt port:libiconv
</span><span class="cx"> 
</span><del>-# these come from http://rsync.samba.org/ftp/rsync/rsync-patches-3.0.9.tar.gz
</del><ins>+# these come from http://rsync.samba.org/ftp/rsync/rsync-patches-3.1.1.tar.gz
</ins><span class="cx"> # and need to be updated with each release
</span><span class="cx"> patchfiles          patch-fileflags.diff \
</span><span class="cx">                     patch-crtimes.diff \
</span><span class="lines">@@ -38,7 +38,6 @@
</span><span class="cx"> patch.pre_args      -p1
</span><span class="cx"> 
</span><span class="cx"> configure.args      --with-rsyncd-conf=${prefix}/etc/rsyncd.conf
</span><del>-configure.cflags   &quot;-Os -I${prefix}/include&quot;
</del><span class="cx"> 
</span><span class="cx"> pre-configure {
</span><span class="cx">     system &quot;cd ${worksrcpath}; ./prepare-source&quot;
</span></span></pre></div>
<a id="trunkdportsnetrsyncfilespatchcrtimesdiff"></a>
<div class="modfile"><h4>Modified: trunk/dports/net/rsync/files/patch-crtimes.diff (121461 => 121462)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/dports/net/rsync/files/patch-crtimes.diff        2014-06-26 00:50:01 UTC (rev 121461)
+++ trunk/dports/net/rsync/files/patch-crtimes.diff        2014-06-26 01:16:27 UTC (rev 121462)
</span><span class="lines">@@ -9,11 +9,11 @@
</span><span class="cx">     ./configure
</span><span class="cx">     make
</span><span class="cx"> 
</span><del>-based-on: patch/b3.0.x/fileflags
</del><ins>+based-on: patch/master/fileflags
</ins><span class="cx"> diff --git a/compat.c b/compat.c
</span><span class="cx"> --- a/compat.c
</span><span class="cx"> +++ b/compat.c
</span><del>-@@ -47,6 +47,7 @@ extern int force_change;
</del><ins>+@@ -48,6 +48,7 @@ extern int force_change;
</ins><span class="cx">  extern int protect_args;
</span><span class="cx">  extern int preserve_uid;
</span><span class="cx">  extern int preserve_gid;
</span><span class="lines">@@ -21,7 +21,7 @@
</span><span class="cx">  extern int preserve_fileflags;
</span><span class="cx">  extern int preserve_acls;
</span><span class="cx">  extern int preserve_xattrs;
</span><del>-@@ -65,7 +66,7 @@ extern char *iconv_opt;
</del><ins>+@@ -66,7 +67,7 @@ extern char *iconv_opt;
</ins><span class="cx">  #endif
</span><span class="cx">  
</span><span class="cx">  /* These index values are for the file-list's extra-attribute array. */
</span><span class="lines">@@ -30,7 +30,7 @@
</span><span class="cx">  
</span><span class="cx">  int receiver_symlink_times = 0; /* receiver can set the time on a symlink */
</span><span class="cx">  int sender_symlink_iconv = 0;        /* sender should convert symlink content */
</span><del>-@@ -142,6 +143,8 @@ void setup_protocol(int f_out,int f_in)
</del><ins>+@@ -144,6 +145,8 @@ void setup_protocol(int f_out,int f_in)
</ins><span class="cx">                  uid_ndx = ++file_extra_cnt;
</span><span class="cx">          if (preserve_gid)
</span><span class="cx">                  gid_ndx = ++file_extra_cnt;
</span><span class="lines">@@ -42,15 +42,15 @@
</span><span class="cx"> diff --git a/flist.c b/flist.c
</span><span class="cx"> --- a/flist.c
</span><span class="cx"> +++ b/flist.c
</span><del>-@@ -54,6 +54,7 @@ extern int preserve_specials;
- extern int preserve_fileflags;
</del><ins>+@@ -54,6 +54,7 @@ extern int preserve_fileflags;
</ins><span class="cx">  extern int delete_during;
</span><ins>+ extern int missing_args;
</ins><span class="cx">  extern int eol_nulls;
</span><span class="cx"> +extern int crtimes_ndx;
</span><span class="cx">  extern int relative_paths;
</span><span class="cx">  extern int implied_dirs;
</span><span class="cx">  extern int ignore_perishable;
</span><del>-@@ -393,7 +394,7 @@ static void send_file_entry(int f, const char *fname, struct file_struct *file,
</del><ins>+@@ -398,7 +399,7 @@ static void send_file_entry(int f, const char *fname, struct file_struct *file,
</ins><span class="cx">  #endif
</span><span class="cx">                              int ndx, int first_ndx)
</span><span class="cx">  {
</span><span class="lines">@@ -59,10 +59,10 @@
</span><span class="cx">          static mode_t mode;
</span><span class="cx">  #ifdef SUPPORT_FILEFLAGS
</span><span class="cx">          static uint32 fileflags;
</span><del>-@@ -488,6 +489,13 @@ static void send_file_entry(int f, const char *fname, struct file_struct *file,
-                 xflags |= XMIT_SAME_TIME;
-         else
</del><ins>+@@ -509,6 +510,13 @@ static void send_file_entry(int f, const char *fname, struct file_struct *file,
</ins><span class="cx">                  modtime = file-&gt;modtime;
</span><ins>+         if (NSEC_BUMP(file) &amp;&amp; protocol_version &gt;= 31)
+                 xflags |= XMIT_MOD_NSEC;
</ins><span class="cx"> +        if (crtimes_ndx) {
</span><span class="cx"> +                time_t file_crtime = f_crtime(file);
</span><span class="cx"> +                if (file_crtime == modtime)
</span><span class="lines">@@ -73,16 +73,16 @@
</span><span class="cx">  
</span><span class="cx">  #ifdef SUPPORT_HARD_LINKS
</span><span class="cx">          if (tmp_dev != -1) {
</span><del>-@@ -557,6 +565,8 @@ static void send_file_entry(int f, const char *fname, struct file_struct *file,
-                 else
-                         write_int(f, modtime);
</del><ins>+@@ -593,6 +601,8 @@ static void send_file_entry(int f, const char *fname, struct file_struct *file,
</ins><span class="cx">          }
</span><ins>+         if (xflags &amp; XMIT_MOD_NSEC)
+                 write_varint(f, F_MOD_NSEC(file));
</ins><span class="cx"> +        if (crtimes_ndx &amp;&amp; !(xflags &amp; XMIT_CRTIME_EQ_MTIME))
</span><span class="cx"> +                write_varlong(f, crtime, 4);
</span><span class="cx">          if (!(xflags &amp; XMIT_SAME_MODE))
</span><span class="cx">                  write_int(f, to_wire_mode(mode));
</span><span class="cx">  #ifdef SUPPORT_FILEFLAGS
</span><del>-@@ -648,7 +658,7 @@ static void send_file_entry(int f, const char *fname, struct file_struct *file,
</del><ins>+@@ -686,7 +696,7 @@ static void send_file_entry(int f, const char *fname, struct file_struct *file,
</ins><span class="cx">  
</span><span class="cx">  static struct file_struct *recv_file_entry(int f, struct file_list *flist, int xflags)
</span><span class="cx">  {
</span><span class="lines">@@ -91,19 +91,10 @@
</span><span class="cx">          static mode_t mode;
</span><span class="cx">  #ifdef SUPPORT_FILEFLAGS
</span><span class="cx">          static uint32 fileflags;
</span><del>-@@ -758,6 +768,8 @@ static struct file_struct *recv_file_entry(int f, struct file_list *flist, int x
-                                 uid = F_OWNER(first);
-                         if (preserve_gid)
-                                 gid = F_GROUP(first);
-+                        if (crtimes_ndx)
-+                                crtime = f_crtime(first);
-                         if (preserve_devices &amp;&amp; IS_DEVICE(mode)) {
-                                 uint32 *devp = F_RDEV_P(first);
-                                 rdev = MAKEDEV(DEV_MAJOR(devp), DEV_MINOR(devp));
-@@ -786,6 +798,19 @@ static struct file_struct *recv_file_entry(int f, struct file_list *flist, int x
-                 } else
-                         modtime = read_int(f);
-         }
</del><ins>+@@ -838,6 +848,19 @@ static struct file_struct *recv_file_entry(int f, struct file_list *flist, int x
+                 modtime_nsec = read_varint(f);
+         else
+                 modtime_nsec = 0;
</ins><span class="cx"> +        if (crtimes_ndx) {
</span><span class="cx"> +                if (!(xflags &amp; XMIT_CRTIME_EQ_MTIME)) {
</span><span class="cx"> +                        crtime = read_varlong(f, 4);
</span><span class="lines">@@ -120,7 +111,7 @@
</span><span class="cx">          if (!(xflags &amp; XMIT_SAME_MODE))
</span><span class="cx">                  mode = from_wire_mode(read_int(f));
</span><span class="cx">  
</span><del>-@@ -946,6 +971,8 @@ static struct file_struct *recv_file_entry(int f, struct file_list *flist, int x
</del><ins>+@@ -1015,6 +1038,8 @@ static struct file_struct *recv_file_entry(int f, struct file_list *flist, int x
</ins><span class="cx">                  F_GROUP(file) = gid;
</span><span class="cx">                  file-&gt;flags |= gid_flags;
</span><span class="cx">          }
</span><span class="lines">@@ -129,7 +120,7 @@
</span><span class="cx">          if (unsort_ndx)
</span><span class="cx">                  F_NDX(file) = flist-&gt;used + flist-&gt;ndx_start;
</span><span class="cx">  
</span><del>-@@ -1324,6 +1351,8 @@ struct file_struct *make_file(const char *fname, struct file_list *flist,
</del><ins>+@@ -1416,6 +1441,8 @@ struct file_struct *make_file(const char *fname, struct file_list *flist,
</ins><span class="cx">                  F_GROUP(file) = st.st_gid;
</span><span class="cx">          if (am_generator &amp;&amp; st.st_uid == our_uid)
</span><span class="cx">                  file-&gt;flags |= FLAG_OWNED_BY_US;
</span><span class="lines">@@ -141,15 +132,7 @@
</span><span class="cx"> diff --git a/generator.c b/generator.c
</span><span class="cx"> --- a/generator.c
</span><span class="cx"> +++ b/generator.c
</span><del>-@@ -21,6 +21,7 @@
-  */

- #include &quot;rsync.h&quot;
-+#include &quot;ifuncs.h&quot;

- extern int verbose;
- extern int dry_run;
-@@ -41,6 +42,7 @@ extern int preserve_xattrs;
</del><ins>+@@ -40,6 +40,7 @@ extern int preserve_xattrs;
</ins><span class="cx">  extern int preserve_links;
</span><span class="cx">  extern int preserve_devices;
</span><span class="cx">  extern int preserve_specials;
</span><span class="lines">@@ -157,7 +140,7 @@
</span><span class="cx">  extern int preserve_hard_links;
</span><span class="cx">  extern int preserve_executability;
</span><span class="cx">  extern int preserve_fileflags;
</span><del>-@@ -576,8 +578,15 @@ static void do_delete_pass(void)
</del><ins>+@@ -384,8 +385,15 @@ static void do_delete_pass(void)
</ins><span class="cx">                  rprintf(FINFO, &quot;                    \r&quot;);
</span><span class="cx">  }
</span><span class="cx">  
</span><span class="lines">@@ -174,7 +157,7 @@
</span><span class="cx">          return cmp_time(sxp-&gt;st.st_mtime, file-&gt;modtime);
</span><span class="cx">  }
</span><span class="cx">  
</span><del>-@@ -635,7 +644,7 @@ int unchanged_attrs(const char *fname, struct file_struct *file, stat_x *sxp)
</del><ins>+@@ -443,7 +451,7 @@ int unchanged_attrs(const char *fname, struct file_struct *file, stat_x *sxp)
</ins><span class="cx">  {
</span><span class="cx">          if (S_ISLNK(file-&gt;mode)) {
</span><span class="cx">  #ifdef CAN_SET_SYMLINK_TIMES
</span><span class="lines">@@ -183,7 +166,7 @@
</span><span class="cx">                          return 0;
</span><span class="cx">  #endif
</span><span class="cx">  #ifdef CAN_CHMOD_SYMLINK
</span><del>-@@ -655,7 +664,7 @@ int unchanged_attrs(const char *fname, struct file_struct *file, stat_x *sxp)
</del><ins>+@@ -463,7 +471,7 @@ int unchanged_attrs(const char *fname, struct file_struct *file, stat_x *sxp)
</ins><span class="cx">                          return 0;
</span><span class="cx">  #endif
</span><span class="cx">          } else {
</span><span class="lines">@@ -192,7 +175,7 @@
</span><span class="cx">                          return 0;
</span><span class="cx">                  if (perms_differ(file, sxp))
</span><span class="cx">                          return 0;
</span><del>-@@ -698,6 +707,12 @@ void itemize(const char *fnamecmp, struct file_struct *file, int ndx, int statre
</del><ins>+@@ -506,6 +514,12 @@ void itemize(const char *fnamecmp, struct file_struct *file, int ndx, int statre
</ins><span class="cx">                   : iflags &amp; (ITEM_TRANSFER|ITEM_LOCAL_CHANGE) &amp;&amp; !(iflags &amp; ITEM_MATCHED)
</span><span class="cx">                    &amp;&amp; (!(iflags &amp; ITEM_XNAME_FOLLOWS) || *xname))
</span><span class="cx">                          iflags |= ITEM_REPORT_TIME;
</span><span class="lines">@@ -205,76 +188,58 @@
</span><span class="cx">  #if !defined HAVE_LCHMOD &amp;&amp; !defined HAVE_SETATTRLIST
</span><span class="cx">                  if (S_ISLNK(file-&gt;mode)) {
</span><span class="cx">                          
</span><del>-@@ -1263,7 +1278,7 @@ static int try_dests_non(struct file_struct *file, char *fname, int ndx,

</del><ins>+@@ -1130,6 +1144,7 @@ static int try_dests_non(struct file_struct *file, char *fname, int ndx,
</ins><span class="cx">  static void list_file_entry(struct file_struct *f)
</span><span class="cx">  {
</span><del>--        char permbuf[PERMSTRING_SIZE];
-+        char permbuf[PERMSTRING_SIZE], crtime_buf[32];
-         double len;
</del><ins>+         char permbuf[PERMSTRING_SIZE];
++        time_t crtime = crtimes_ndx ? f_crtime(f) : 0;
+         int64 len;
+         int colwidth = human_readable ? 14 : 11;
</ins><span class="cx">  
</span><del>-         if (!F_IS_ACTIVE(f)) {
-@@ -1274,19 +1289,24 @@ static void list_file_entry(struct file_struct *f)
-         permstring(permbuf, f-&gt;mode);
-         len = F_LENGTH(f);
</del><ins>+@@ -1145,10 +1160,12 @@ static void list_file_entry(struct file_struct *f)
</ins><span class="cx">  
</span><del>-+        if (crtimes_ndx)
-+                snprintf(crtime_buf, sizeof crtime_buf, &quot; %s&quot;, timestring(f_crtime(f)));
-+        else
-+                *crtime_buf = '\0';
-+
-         /* TODO: indicate '+' if the entry has an ACL. */

</del><span class="cx">  #ifdef SUPPORT_LINKS
</span><span class="cx">          if (preserve_links &amp;&amp; S_ISLNK(f-&gt;mode)) {
</span><del>--                rprintf(FINFO, &quot;%s %11.0f %s %s -&gt; %s\n&quot;,
-+                rprintf(FINFO, &quot;%s %11.0f %s%s %s -&gt; %s\n&quot;,
-                         permbuf, len, timestring(f-&gt;modtime),
--                        f_name(f, NULL), F_SYMLINK(f));
-+                        crtime_buf, f_name(f, NULL), F_SYMLINK(f));
</del><ins>+-                rprintf(FINFO, &quot;%s %*s %s %s -&gt; %s\n&quot;,
++                rprintf(FINFO, &quot;%s %*s %s%s%s %s -&gt; %s\n&quot;,
+                         permbuf, colwidth, human_num(len),
+-                        timestring(f-&gt;modtime), f_name(f, NULL),
+-                        F_SYMLINK(f));
++                        timestring(f-&gt;modtime),
++                        crtimes_ndx ? &quot; &quot; : &quot;&quot;,
++                        crtimes_ndx ? timestring(crtime) : &quot;&quot;,
++                        f_name(f, NULL), F_SYMLINK(f));
</ins><span class="cx">          } else
</span><span class="cx">  #endif
</span><del>-         {
--                rprintf(FINFO, &quot;%s %11.0f %s %s\n&quot;,
-+                rprintf(FINFO, &quot;%s %11.0f %s%s %s\n&quot;,
-                         permbuf, len, timestring(f-&gt;modtime),
--                        f_name(f, NULL));
-+                        crtime_buf, f_name(f, NULL));
</del><ins>+         if (missing_args == 2 &amp;&amp; f-&gt;mode == 0) {
+@@ -1156,9 +1173,12 @@ static void list_file_entry(struct file_struct *f)
+                         colwidth + 31, &quot;*missing&quot;,
+                         f_name(f, NULL));
+         } else {
+-                rprintf(FINFO, &quot;%s %*s %s %s\n&quot;,
++                rprintf(FINFO, &quot;%s %*s %s%s%s %s\n&quot;,
+                         permbuf, colwidth, human_num(len),
+-                        timestring(f-&gt;modtime), f_name(f, NULL));
++                        timestring(f-&gt;modtime),
++                        crtimes_ndx ? &quot; &quot; : &quot;&quot;,
++                        crtimes_ndx ? timestring(crtime) : &quot;&quot;,
++                        f_name(f, NULL));
</ins><span class="cx">          }
</span><span class="cx">  }
</span><span class="cx">  
</span><del>-@@ -1383,6 +1403,7 @@ static void recv_generator(char *fname, struct file_struct *file, int ndx,
</del><ins>+@@ -1250,6 +1270,7 @@ static void recv_generator(char *fname, struct file_struct *file, int ndx,
</ins><span class="cx">                          return;
</span><span class="cx">                  }
</span><span class="cx">          }
</span><span class="cx"> +        sx.crtime = 0;
</span><span class="cx">  
</span><span class="cx">          if (dry_run &gt; 1 || (dry_missing_dir &amp;&amp; is_below(file, dry_missing_dir))) {
</span><del>-           parent_is_dry_missing:
-diff --git a/hlink.c b/hlink.c
---- a/hlink.c
-+++ b/hlink.c
-@@ -371,6 +371,7 @@ int hard_link_check(struct file_struct *file, int ndx, const char *fname,
-                 char cmpbuf[MAXPATHLEN];
-                 stat_x alt_sx;
-                 int j = 0;
-+                alt_sx.crtime = 0;
- #ifdef SUPPORT_ACLS
-                 alt_sx.acc_acl = alt_sx.def_acl = NULL;
- #endif
-@@ -499,6 +500,7 @@ void finish_hard_link(struct file_struct *file, const char *fname, int fin_ndx,
-         } else
-                 our_name = fname;

-+        prev_sx.crtime = 0;
- #ifdef SUPPORT_ACLS
-         prev_sx.acc_acl = prev_sx.def_acl = NULL;
- #endif
</del><ins>+                 int i;
</ins><span class="cx"> diff --git a/ifuncs.h b/ifuncs.h
</span><span class="cx"> --- a/ifuncs.h
</span><span class="cx"> +++ b/ifuncs.h
</span><del>-@@ -67,6 +67,28 @@ d_name(struct dirent *di)
- #endif
</del><ins>+@@ -43,6 +43,28 @@ free_xbuf(xbuf *xb)
+         memset(xb, 0, sizeof (xbuf));
</ins><span class="cx">  }
</span><span class="cx">  
</span><span class="cx"> +static inline time_t
</span><span class="lines">@@ -300,12 +265,12 @@
</span><span class="cx"> +}
</span><span class="cx"> +
</span><span class="cx">  static inline int
</span><del>- isDigit(const char *ptr)
</del><ins>+ to_wire_mode(mode_t mode)
</ins><span class="cx">  {
</span><span class="cx"> diff --git a/log.c b/log.c
</span><span class="cx"> --- a/log.c
</span><span class="cx"> +++ b/log.c
</span><del>-@@ -661,7 +661,8 @@ static void log_formatted(enum logcode code, const char *format, const char *op,
</del><ins>+@@ -723,7 +723,8 @@ static void log_formatted(enum logcode code, const char *format, const char *op,
</ins><span class="cx">                          c[8] = !(iflags &amp; ITEM_REPORT_FFLAGS) ? '.' : 'f';
</span><span class="cx">                          c[9] = !(iflags &amp; ITEM_REPORT_ACL) ? '.' : 'a';
</span><span class="cx">                          c[10] = !(iflags &amp; ITEM_REPORT_XATTR) ? '.' : 'x';
</span><span class="lines">@@ -318,7 +283,7 @@
</span><span class="cx"> diff --git a/options.c b/options.c
</span><span class="cx"> --- a/options.c
</span><span class="cx"> +++ b/options.c
</span><del>-@@ -60,6 +60,7 @@ int preserve_specials = 0;
</del><ins>+@@ -62,6 +62,7 @@ int preserve_specials = 0;
</ins><span class="cx">  int preserve_uid = 0;
</span><span class="cx">  int preserve_gid = 0;
</span><span class="cx">  int preserve_times = 0;
</span><span class="lines">@@ -326,15 +291,15 @@
</span><span class="cx">  int update_only = 0;
</span><span class="cx">  int cvs_exclude = 0;
</span><span class="cx">  int dry_run = 0;
</span><del>-@@ -361,6 +362,7 @@ void usage(enum logcode F)
</del><ins>+@@ -718,6 +719,7 @@ void usage(enum logcode F)
+   rprintf(F,&quot;     --specials              preserve special files\n&quot;);
</ins><span class="cx">    rprintf(F,&quot; -D                          same as --devices --specials\n&quot;);
</span><span class="cx">    rprintf(F,&quot; -t, --times                 preserve modification times\n&quot;);
</span><del>-   rprintf(F,&quot; -O, --omit-dir-times        omit directories from --times\n&quot;);
</del><span class="cx"> +  rprintf(F,&quot; -N, --crtimes               preserve create times (newness)\n&quot;);
</span><ins>+   rprintf(F,&quot; -O, --omit-dir-times        omit directories from --times\n&quot;);
+   rprintf(F,&quot; -J, --omit-link-times       omit symlinks from --times\n&quot;);
</ins><span class="cx">    rprintf(F,&quot;     --super                 receiver attempts super-user activities\n&quot;);
</span><del>- #ifdef SUPPORT_XATTRS
-   rprintf(F,&quot;     --fake-super            store/recover privileged attrs using xattrs\n&quot;);
-@@ -507,6 +509,9 @@ static struct poptOption long_options[] = {
</del><ins>+@@ -885,6 +887,9 @@ static struct poptOption long_options[] = {
</ins><span class="cx">    {&quot;times&quot;,           't', POPT_ARG_VAL,    &amp;preserve_times, 1, 0, 0 },
</span><span class="cx">    {&quot;no-times&quot;,         0,  POPT_ARG_VAL,    &amp;preserve_times, 0, 0, 0 },
</span><span class="cx">    {&quot;no-t&quot;,             0,  POPT_ARG_VAL,    &amp;preserve_times, 0, 0, 0 },
</span><span class="lines">@@ -344,7 +309,7 @@
</span><span class="cx">    {&quot;omit-dir-times&quot;,  'O', POPT_ARG_VAL,    &amp;omit_dir_times, 1, 0, 0 },
</span><span class="cx">    {&quot;no-omit-dir-times&quot;,0,  POPT_ARG_VAL,    &amp;omit_dir_times, 0, 0, 0 },
</span><span class="cx">    {&quot;no-O&quot;,             0,  POPT_ARG_VAL,    &amp;omit_dir_times, 0, 0, 0 },
</span><del>-@@ -1810,6 +1815,8 @@ void server_options(char **args, int *argc_p)
</del><ins>+@@ -2465,6 +2470,8 @@ void server_options(char **args, int *argc_p)
</ins><span class="cx">                  argstr[x++] = 'D';
</span><span class="cx">          if (preserve_times)
</span><span class="cx">                  argstr[x++] = 't';
</span><span class="lines">@@ -356,15 +321,7 @@
</span><span class="cx"> diff --git a/rsync.c b/rsync.c
</span><span class="cx"> --- a/rsync.c
</span><span class="cx"> +++ b/rsync.c
</span><del>-@@ -464,6 +464,7 @@ int set_file_attrs(const char *fname, struct file_struct *file, stat_x *sxp,
-                                 full_fname(fname));
-                         return 0;
-                 }
-+                sx2.crtime = 0;
- #ifdef SUPPORT_ACLS
-                 sx2.acc_acl = sx2.def_acl = NULL;
- #endif
-@@ -505,6 +506,9 @@ int set_file_attrs(const char *fname, struct file_struct *file, stat_x *sxp,
</del><ins>+@@ -581,6 +581,9 @@ int set_file_attrs(const char *fname, struct file_struct *file, stat_x *sxp,
</ins><span class="cx">           || (!(preserve_times &amp; PRESERVE_DIR_TIMES) &amp;&amp; S_ISDIR(sxp-&gt;st.st_mode))
</span><span class="cx">           || (!(preserve_times &amp; PRESERVE_LINK_TIMES) &amp;&amp; S_ISLNK(sxp-&gt;st.st_mode)))
</span><span class="cx">                  flags |= ATTRS_SKIP_MTIME;
</span><span class="lines">@@ -373,8 +330,8 @@
</span><span class="cx"> +                flags |= ATTRS_SKIP_CRTIME;
</span><span class="cx">          if (!(flags &amp; ATTRS_SKIP_MTIME)
</span><span class="cx">              &amp;&amp; cmp_time(sxp-&gt;st.st_mtime, file-&gt;modtime) != 0) {
</span><del>-                 int ret = set_modtime(fname, file-&gt;modtime, sxp-&gt;st.st_mode, ST_FLAGS(sxp-&gt;st));
-@@ -518,6 +522,14 @@ int set_file_attrs(const char *fname, struct file_struct *file, stat_x *sxp,
</del><ins>+                 int ret = set_modtime(fname, file-&gt;modtime, F_MOD_NSEC(file), sxp-&gt;st.st_mode, ST_FLAGS(sxp-&gt;st));
+@@ -594,6 +597,14 @@ int set_file_attrs(const char *fname, struct file_struct *file, stat_x *sxp,
</ins><span class="cx">                  else
</span><span class="cx">                          file-&gt;flags |= FLAG_TIME_FAILED;
</span><span class="cx">          }
</span><span class="lines">@@ -387,9 +344,9 @@
</span><span class="cx"> +                        updated = 1;
</span><span class="cx"> +        }
</span><span class="cx">  
</span><del>-         change_uid = am_root &amp;&amp; uid_ndx &amp;&amp; sxp-&gt;st.st_uid != (uid_t)F_OWNER(file);
-         change_gid = gid_ndx &amp;&amp; !(file-&gt;flags &amp; FLAG_SKIP_GROUP)
-@@ -675,7 +687,7 @@ int finish_transfer(const char *fname, const char *fnametmp,
</del><ins>+ #ifdef SUPPORT_ACLS
+         /* It's OK to call set_acl() now, even for a dir, as the generator
+@@ -710,7 +721,7 @@ int finish_transfer(const char *fname, const char *fnametmp,
</ins><span class="cx">          /* Change permissions before putting the file into place. */
</span><span class="cx">          set_file_attrs(fnametmp, file, NULL, fnamecmp,
</span><span class="cx">                         ATTRS_DELAY_IMMUTABLE
</span><span class="lines">@@ -397,8 +354,8 @@
</span><span class="cx"> +                       | (ok_to_set_time ? 0 : ATTRS_SKIP_MTIME | ATTRS_SKIP_CRTIME));
</span><span class="cx">  
</span><span class="cx">          /* move tmp file over real file */
</span><del>-         if (verbose &gt; 2)
-@@ -706,7 +718,7 @@ int finish_transfer(const char *fname, const char *fnametmp,
</del><ins>+         if (DEBUG_GTE(RECV, 1))
+@@ -739,7 +750,7 @@ int finish_transfer(const char *fname, const char *fnametmp,
</ins><span class="cx">  
</span><span class="cx">    do_set_file_attrs:
</span><span class="cx">          set_file_attrs(fnametmp, file, NULL, fnamecmp,
</span><span class="lines">@@ -410,15 +367,17 @@
</span><span class="cx"> diff --git a/rsync.h b/rsync.h
</span><span class="cx"> --- a/rsync.h
</span><span class="cx"> +++ b/rsync.h
</span><del>-@@ -61,6 +61,7 @@
- #define XMIT_GROUP_NAME_FOLLOWS (1&lt;&lt;11) /* protocols 30 - now */
</del><ins>+@@ -62,7 +62,8 @@
</ins><span class="cx">  #define XMIT_HLINK_FIRST (1&lt;&lt;12)        /* protocols 30 - now (HLINKED files only) */
</span><span class="cx">  #define XMIT_IO_ERROR_ENDLIST (1&lt;&lt;12)        /* protocols 31*- now (w/XMIT_EXTENDED_FLAGS) (also protocol 30 w/'f' compat flag) */
</span><del>-+#define XMIT_CRTIME_EQ_MTIME (1&lt;&lt;13)        /* protocols ?? - now */
- #define XMIT_SAME_FLAGS (1&lt;&lt;14)                /* protocols ?? - now */
</del><ins>+ #define XMIT_MOD_NSEC (1&lt;&lt;13)                /* protocols 31 - now */
+-#define XMIT_SAME_FLAGS (1&lt;&lt;14)                /* protocols ?? - now */
++#define XMIT_CRTIME_EQ_MTIME (1&lt;&lt;14)        /* protocols ?? - now */
++#define XMIT_SAME_FLAGS (1&lt;&lt;15)                /* protocols ?? - now */
</ins><span class="cx">  
</span><span class="cx">  /* These flags are used in the live flist data. */
</span><del>-@@ -162,6 +163,7 @@
</del><ins>+ 
+@@ -167,6 +168,7 @@
</ins><span class="cx">  #define ATTRS_REPORT                (1&lt;&lt;0)
</span><span class="cx">  #define ATTRS_SKIP_MTIME        (1&lt;&lt;1)
</span><span class="cx">  #define ATTRS_DELAY_IMMUTABLE        (1&lt;&lt;2)
</span><span class="lines">@@ -426,7 +385,7 @@
</span><span class="cx">  
</span><span class="cx">  #define FULL_FLUSH        1
</span><span class="cx">  #define NORMAL_FLUSH        0
</span><del>-@@ -178,7 +180,7 @@
</del><ins>+@@ -183,7 +185,7 @@
</ins><span class="cx">  #define FNAMECMP_FUZZY                0x83
</span><span class="cx">  
</span><span class="cx">  /* For use by the itemize_changes code */
</span><span class="lines">@@ -435,7 +394,7 @@
</span><span class="cx">  #define ITEM_REPORT_CHANGE (1&lt;&lt;1)
</span><span class="cx">  #define ITEM_REPORT_SIZE (1&lt;&lt;2)     /* regular files only */
</span><span class="cx">  #define ITEM_REPORT_TIMEFAIL (1&lt;&lt;2) /* symlinks only */
</span><del>-@@ -677,6 +679,7 @@ extern int file_extra_cnt;
</del><ins>+@@ -734,6 +736,7 @@ extern int file_extra_cnt;
</ins><span class="cx">  extern int inc_recurse;
</span><span class="cx">  extern int uid_ndx;
</span><span class="cx">  extern int gid_ndx;
</span><span class="lines">@@ -443,7 +402,7 @@
</span><span class="cx">  extern int fileflags_ndx;
</span><span class="cx">  extern int acls_ndx;
</span><span class="cx">  extern int xattrs_ndx;
</span><del>-@@ -684,6 +687,7 @@ extern int xattrs_ndx;
</del><ins>+@@ -741,6 +744,7 @@ extern int xattrs_ndx;
</ins><span class="cx">  #define FILE_STRUCT_LEN (offsetof(struct file_struct, basename))
</span><span class="cx">  #define EXTRA_LEN (sizeof (union file_extras))
</span><span class="cx">  #define PTR_EXTRA_CNT ((sizeof (char *) + EXTRA_LEN - 1) / EXTRA_LEN)
</span><span class="lines">@@ -451,7 +410,7 @@
</span><span class="cx">  #define DEV_EXTRA_CNT 2
</span><span class="cx">  #define DIRNODE_EXTRA_CNT 3
</span><span class="cx">  #define SUM_EXTRA_CNT ((MAX_DIGEST_LEN + EXTRA_LEN - 1) / EXTRA_LEN)
</span><del>-@@ -951,6 +955,7 @@ typedef struct {
</del><ins>+@@ -1022,6 +1026,7 @@ typedef struct {
</ins><span class="cx">  
</span><span class="cx">  typedef struct {
</span><span class="cx">      STRUCT_STAT st;
</span><span class="lines">@@ -462,25 +421,25 @@
</span><span class="cx"> diff --git a/rsync.yo b/rsync.yo
</span><span class="cx"> --- a/rsync.yo
</span><span class="cx"> +++ b/rsync.yo
</span><del>-@@ -367,6 +367,7 @@ to the detailed description below for a complete description.  verb(
</del><ins>+@@ -373,6 +373,7 @@ to the detailed description below for a complete description.  verb(
+      --specials              preserve special files
</ins><span class="cx">   -D                          same as --devices --specials
</span><span class="cx">   -t, --times                 preserve modification times
</span><del>-  -O, --omit-dir-times        omit directories from --times
</del><span class="cx"> + -N, --crtimes               preserve create times (newness)
</span><ins>+  -O, --omit-dir-times        omit directories from --times
+  -J, --omit-link-times       omit symlinks from --times
</ins><span class="cx">       --super                 receiver attempts super-user activities
</span><del>-      --fake-super            store/recover privileged attrs using xattrs
-  -S, --sparse                handle sparse files efficiently
-@@ -1105,6 +1106,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).
</del><ins>+@@ -1201,6 +1202,9 @@ cause the next transfer to behave as if it used bf(-I), causing all files to be
+ updated (though rsync's delta-transfer algorithm will make the update fairly efficient
+ if the files haven't actually changed, you're much better off using bf(-t)).
</ins><span class="cx">  
</span><span class="cx"> +dit(bf(-N, --crtimes)) This tells rsync to set the create times (newness) of
</span><span class="cx"> +the destination files to the same value as the source files.
</span><span class="cx"> +
</span><del>- 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
-@@ -1811,7 +1815,7 @@ with older versions of rsync, but that also turns on the output of other
</del><ins>+ dit(bf(-O, --omit-dir-times)) This tells rsync to omit directories when
+ 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).
+@@ -2103,7 +2107,7 @@ with older versions of rsync, but that also turns on the output of other
</ins><span class="cx">  verbose messages).
</span><span class="cx">  
</span><span class="cx">  The &quot;%i&quot; escape has a cryptic output that is 11 letters long.  The general
</span><span class="lines">@@ -489,7 +448,7 @@
</span><span class="cx">  type of update being done, bf(X) is replaced by the file-type, and the
</span><span class="cx">  other letters represent attributes that may be output if they are being
</span><span class="cx">  modified.
</span><del>-@@ -1870,6 +1874,8 @@ quote(itemization(
</del><ins>+@@ -2162,6 +2166,8 @@ quote(itemization(
</ins><span class="cx">    it() The bf(f) means that the fileflags information changed.
</span><span class="cx">    it() The bf(a) means that the ACL information changed.
</span><span class="cx">    it() The bf(x) means that the extended attribute information changed.
</span><span class="lines">@@ -501,7 +460,7 @@
</span><span class="cx"> diff --git a/syscall.c b/syscall.c
</span><span class="cx"> --- a/syscall.c
</span><span class="cx"> +++ b/syscall.c
</span><del>-@@ -37,6 +37,13 @@ extern int force_change;
</del><ins>+@@ -42,6 +42,13 @@ extern int force_change;
</ins><span class="cx">  extern int preserve_perms;
</span><span class="cx">  extern int preserve_executability;
</span><span class="cx">  
</span><span class="lines">@@ -515,7 +474,7 @@
</span><span class="cx">  #define RETURN_ERROR_IF(x,e) \
</span><span class="cx">          do { \
</span><span class="cx">                  if (x) { \
</span><del>-@@ -529,6 +536,36 @@ OFF_T do_lseek(int fd, OFF_T offset, int whence)
</del><ins>+@@ -460,6 +467,36 @@ OFF_T do_lseek(int fd, OFF_T offset, int whence)
</ins><span class="cx">  #endif
</span><span class="cx">  }
</span><span class="cx">  
</span><span class="lines">@@ -550,7 +509,7 @@
</span><span class="cx"> +}
</span><span class="cx"> +
</span><span class="cx">  #ifdef HAVE_UTIMENSAT
</span><del>- int do_utimensat(const char *fname, time_t modtime, uint32 mod_nsec, mode_t mode, uint32 fileflags)
</del><ins>+ int do_utimensat(const char *fname, time_t modtime, uint32 mod_nsec)
</ins><span class="cx">  {
</span><span class="cx"> diff --git a/testsuite/crtimes.test b/testsuite/crtimes.test
</span><span class="cx"> new file mode 100644
</span><span class="lines">@@ -584,7 +543,7 @@
</span><span class="cx"> diff --git a/testsuite/rsync.fns b/testsuite/rsync.fns
</span><span class="cx"> --- a/testsuite/rsync.fns
</span><span class="cx"> +++ b/testsuite/rsync.fns
</span><del>-@@ -24,9 +24,9 @@ todir=&quot;$tmpdir/to&quot;
</del><ins>+@@ -23,9 +23,9 @@ todir=&quot;$tmpdir/to&quot;
</ins><span class="cx">  chkdir=&quot;$tmpdir/chk&quot;
</span><span class="cx">  
</span><span class="cx">  # For itemized output:
</span><span class="lines">@@ -600,7 +559,7 @@
</span><span class="cx"> diff --git a/tls.c b/tls.c
</span><span class="cx"> --- a/tls.c
</span><span class="cx"> +++ b/tls.c
</span><del>-@@ -107,6 +107,8 @@ static int stat_xattr(const char *fname, STRUCT_STAT *fst)
</del><ins>+@@ -109,6 +109,8 @@ static int stat_xattr(const char *fname, STRUCT_STAT *fst)
</ins><span class="cx">  
</span><span class="cx">  #endif
</span><span class="cx">  
</span><span class="lines">@@ -609,25 +568,32 @@
</span><span class="cx">  static void failed(char const *what, char const *where)
</span><span class="cx">  {
</span><span class="cx">          fprintf(stderr, PROGRAM &quot;: %s %s: %s\n&quot;,
</span><del>-@@ -114,16 +116,36 @@ static void failed(char const *what, char const *where)
</del><ins>+@@ -116,16 +118,44 @@ static void failed(char const *what, char const *where)
</ins><span class="cx">          exit(1);
</span><span class="cx">  }
</span><span class="cx">  
</span><del>-+static void storetime(char *dest, time_t t, size_t destsize)
</del><ins>++static void storetime(char *dest, size_t destsize, time_t t, int nsecs)
</ins><span class="cx"> +{
</span><span class="cx"> +        if (t) {
</span><ins>++                int len;
</ins><span class="cx"> +                struct tm *mt = gmtime(&amp;t);
</span><span class="cx"> +
</span><del>-+                snprintf(dest, destsize,
-+                        &quot;%04d-%02d-%02d %02d:%02d:%02d &quot;,
</del><ins>++                len = snprintf(dest, destsize,
++                        &quot;%04d-%02d-%02d %02d:%02d:%02d&quot;,
</ins><span class="cx"> +                        (int)mt-&gt;tm_year + 1900,
</span><span class="cx"> +                        (int)mt-&gt;tm_mon + 1,
</span><span class="cx"> +                        (int)mt-&gt;tm_mday,
</span><span class="cx"> +                        (int)mt-&gt;tm_hour,
</span><span class="cx"> +                        (int)mt-&gt;tm_min,
</span><span class="cx"> +                        (int)mt-&gt;tm_sec);
</span><del>-+        } else
-+                strlcpy(dest, &quot;                    &quot;, destsize);
</del><ins>++                if (nsecs &gt;= 0 &amp;&amp; len &gt;= 0)
++                        snprintf(dest + len, destsize - len, &quot;.%09d&quot;, nsecs);
++        } else {
++                int has_nsecs = nsecs &gt;= 0 ? 1 : 0;
++                int len = MIN(19 + 9*has_nsecs, (int)destsize - 1);
++                memset(dest, ' ', len);
++                dest[len] = '\0';
++        }
</ins><span class="cx"> +}
</span><span class="cx"> +
</span><span class="cx">  static void list_file(const char *fname)
</span><span class="lines">@@ -640,6 +606,7 @@
</span><span class="cx"> +        char mtimebuf[50];
</span><span class="cx"> +        char crtimebuf[50];
</span><span class="cx">          char linkbuf[4096];
</span><ins>++        int nsecs;
</ins><span class="cx">  
</span><span class="cx">          if (do_lstat(fname, &amp;buf) &lt; 0)
</span><span class="cx">                  failed(&quot;stat&quot;, fname);
</span><span class="lines">@@ -648,14 +615,16 @@
</span><span class="cx">  #ifdef SUPPORT_XATTRS
</span><span class="cx">          if (am_root &lt; 0)
</span><span class="cx">                  stat_xattr(fname, &amp;buf);
</span><del>-@@ -158,19 +180,11 @@ static void list_file(const char *fname)
</del><ins>+@@ -159,30 +189,17 @@ static void list_file(const char *fname)
+         }
</ins><span class="cx">  
</span><span class="cx">          permstring(permbuf, buf.st_mode);
</span><del>- 
</del><ins>+-
</ins><span class="cx"> -        if (buf.st_mtime) {
</span><ins>+-                int len;
</ins><span class="cx"> -                mt = gmtime(&amp;buf.st_mtime);
</span><span class="cx"> -
</span><del>--                snprintf(datebuf, sizeof datebuf,
</del><ins>+-                len = snprintf(datebuf, sizeof datebuf,
</ins><span class="cx"> -                        &quot;%04d-%02d-%02d %02d:%02d:%02d&quot;,
</span><span class="cx"> -                        (int)mt-&gt;tm_year + 1900,
</span><span class="cx"> -                        (int)mt-&gt;tm_mon + 1,
</span><span class="lines">@@ -663,20 +632,33 @@
</span><span class="cx"> -                        (int)mt-&gt;tm_hour,
</span><span class="cx"> -                        (int)mt-&gt;tm_min,
</span><span class="cx"> -                        (int)mt-&gt;tm_sec);
</span><del>--        } else
--                strlcpy(datebuf, &quot;                   &quot;, sizeof datebuf);
-+        storetime(mtimebuf, buf.st_mtime, sizeof mtimebuf);
</del><ins>+ #ifdef ST_MTIME_NSEC
+-                if (nsec_times) {
+-                        snprintf(datebuf + len, sizeof datebuf - len,
+-                                &quot;.%09d&quot;, (int)buf.ST_MTIME_NSEC);
+-                }
++        if (nsec_times)
++                nsecs = (int)buf.ST_MTIME_NSEC;
++        else
+ #endif
+-        } else {
+-                int len = MIN(19 + 9*nsec_times, (int)sizeof datebuf - 1);
+-                memset(datebuf, ' ', len);
+-                datebuf[len] = '\0';
+-        }
++                nsecs = -1;
++        storetime(mtimebuf, sizeof mtimebuf, buf.st_mtime, nsecs);
</ins><span class="cx"> +        if (display_crtimes)
</span><del>-+                storetime(crtimebuf, crtime, sizeof crtimebuf);
</del><ins>++                storetime(crtimebuf, sizeof crtimebuf, crtime, -1);
</ins><span class="cx"> +        else
</span><span class="cx"> +                crtimebuf[0] = '\0';
</span><span class="cx">  
</span><span class="cx">          /* TODO: Perhaps escape special characters in fname? */
</span><span class="cx">  
</span><del>-@@ -181,13 +195,14 @@ static void list_file(const char *fname)
</del><ins>+@@ -193,13 +210,14 @@ static void list_file(const char *fname)
</ins><span class="cx">                      (long)minor(buf.st_rdev));
</span><del>-         } else /* NB: use double for size since it might not fit in a long. */
-                 printf(&quot;%12.0f&quot;, (double)buf.st_size);
</del><ins>+         } else
+                 printf(&quot;%15s&quot;, do_big_num(buf.st_size, 1, NULL));
</ins><span class="cx"> -        printf(&quot; %6ld.%-6ld %6ld %s %s%s\n&quot;,
</span><span class="cx"> +        printf(&quot; %6ld.%-6ld %6ld %s%s%s%s\n&quot;,
</span><span class="cx">                 (long)buf.st_uid, (long)buf.st_gid, (long)buf.st_nlink,
</span><span class="lines">@@ -690,7 +672,7 @@
</span><span class="cx">    {&quot;link-times&quot;,      'l', POPT_ARG_NONE,   &amp;link_times, 0, 0, 0 },
</span><span class="cx">    {&quot;link-owner&quot;,      'L', POPT_ARG_NONE,   &amp;link_owner, 0, 0, 0 },
</span><span class="cx">  #ifdef SUPPORT_XATTRS
</span><del>-@@ -203,6 +218,7 @@ static void tls_usage(int ret)
</del><ins>+@@ -218,6 +236,7 @@ static void tls_usage(int ret)
</ins><span class="cx">    fprintf(F,&quot;usage: &quot; PROGRAM &quot; [OPTIONS] FILE ...\n&quot;);
</span><span class="cx">    fprintf(F,&quot;Trivial file listing program for portably checking rsync\n&quot;);
</span><span class="cx">    fprintf(F,&quot;\nOptions:\n&quot;);
</span><span class="lines">@@ -698,41 +680,41 @@
</span><span class="cx">    fprintf(F,&quot; -l, --link-times            display the time on a symlink\n&quot;);
</span><span class="cx">    fprintf(F,&quot; -L, --link-owner            display the owner+group on a symlink\n&quot;);
</span><span class="cx">  #ifdef SUPPORT_XATTRS
</span><del>-diff -up a/proto.h b/proto.h
</del><ins>+diff -Nurp a/proto.h b/proto.h
</ins><span class="cx"> --- a/proto.h
</span><span class="cx"> +++ b/proto.h
</span><del>-@@ -315,6 +315,8 @@ int do_stat(const char *fname, STRUCT_ST
</del><ins>+@@ -327,6 +327,8 @@ int do_stat(const char *fname, STRUCT_ST
</ins><span class="cx">  int do_lstat(const char *fname, STRUCT_STAT *st);
</span><span class="cx">  int do_fstat(int fd, STRUCT_STAT *st);
</span><span class="cx">  OFF_T do_lseek(int fd, OFF_T offset, int whence);
</span><span class="cx"> +time_t get_create_time(const char *path);
</span><span class="cx"> +int set_create_time(const char *path, time_t crtime);
</span><del>- int do_utimensat(const char *fname, time_t modtime, uint32 mod_nsec, mode_t mode, uint32 fileflags);
- int do_lutimes(const char *fname, time_t modtime, uint32 mod_nsec, mode_t mode, uint32 fileflags);
- int do_utimes(const char *fname, time_t modtime, uint32 mod_nsec, mode_t mode, uint32 fileflags);
-diff -up a/rsync.1 b/rsync.1
</del><ins>+ int do_utimensat(const char *fname, time_t modtime, uint32 mod_nsec);
+ int do_lutimes(const char *fname, time_t modtime, uint32 mod_nsec);
+ int do_utimes(const char *fname, time_t modtime, uint32 mod_nsec);
+diff -Nurp a/rsync.1 b/rsync.1
</ins><span class="cx"> --- a/rsync.1
</span><span class="cx"> +++ b/rsync.1
</span><del>-@@ -443,6 +443,7 @@ to the detailed description below for a
</del><ins>+@@ -449,6 +449,7 @@ to the detailed description below for a
+      \-\-specials              preserve special files
</ins><span class="cx">   \-D                          same as \-\-devices \-\-specials
</span><span class="cx">   \-t, \-\-times                 preserve modification times
</span><del>-  \-O, \-\-omit\-dir\-times        omit directories from \-\-times
</del><span class="cx"> + \-N, \-\-crtimes               preserve create times (newness)
</span><ins>+  \-O, \-\-omit\-dir\-times        omit directories from \-\-times
+  \-J, \-\-omit\-link\-times       omit symlinks from \-\-times
</ins><span class="cx">       \-\-super                 receiver attempts super\-user activities
</span><del>-      \-\-fake\-super            store/recover privileged attrs using xattrs
-  \-S, \-\-sparse                handle sparse files efficiently
-@@ -1273,6 +1274,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.
</del><ins>+@@ -1379,6 +1380,10 @@ cause the next transfer to behave as if
+ updated (though rsync\(cq\&amp;s delta\-transfer algorithm will make the update fairly efficient
+ if the files haven\(cq\&amp;t actually changed, you\(cq\&amp;re much better off using \fB\-t\fP).
</ins><span class="cx">  .IP 
</span><span class="cx"> +.IP &quot;\fB\-N, \-\-crtimes\fP&quot;
</span><span class="cx"> +This tells rsync to set the create times (newness) of
</span><span class="cx"> +the destination files to the same value as the source files.
</span><span class="cx"> +.IP 
</span><del>- .IP &quot;\fB\-\-super\fP&quot;
- This tells the receiving side to attempt super\-user
- activities even if the receiving rsync wasn\(cq\&amp;t run by the super\-user.  These
-@@ -2067,7 +2072,7 @@ with older versions of rsync, but that a
</del><ins>+ .IP &quot;\fB\-O, \-\-omit\-dir\-times\fP&quot;
+ This tells rsync to omit directories when
+ it is preserving modification times (see \fB\-\-times\fP).  If NFS is sharing
+@@ -2390,7 +2395,7 @@ with older versions of rsync, but that a
</ins><span class="cx">  verbose messages).
</span><span class="cx">  .IP 
</span><span class="cx">  The \(dq\&amp;%i\(dq\&amp; escape has a cryptic output that is 11 letters long.  The general
</span><span class="lines">@@ -741,7 +723,7 @@
</span><span class="cx">  type of update being done, \fBX\fP is replaced by the file\-type, and the
</span><span class="cx">  other letters represent attributes that may be output if they are being
</span><span class="cx">  modified.
</span><del>-@@ -2142,6 +2147,9 @@ The \fBf\fP means that the fileflags inf
</del><ins>+@@ -2465,6 +2470,9 @@ The \fBf\fP means that the fileflags inf
</ins><span class="cx">  The \fBa\fP means that the ACL information changed.
</span><span class="cx">  .IP o 
</span><span class="cx">  The \fBx\fP means that the extended attribute information changed.
</span></span></pre></div>
<a id="trunkdportsnetrsyncfilespatchfileflagsdiff"></a>
<div class="modfile"><h4>Modified: trunk/dports/net/rsync/files/patch-fileflags.diff (121461 => 121462)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/dports/net/rsync/files/patch-fileflags.diff        2014-06-26 00:50:01 UTC (rev 121461)
+++ trunk/dports/net/rsync/files/patch-fileflags.diff        2014-06-26 01:16:27 UTC (rev 121462)
</span><span class="lines">@@ -8,20 +8,20 @@
</span><span class="cx">     ./configure
</span><span class="cx">     make
</span><span class="cx"> 
</span><del>-based-on: 40afd365cc8ca968fd16e161d24df5b8a8a520cc
</del><ins>+based-on: 7cb0de6326c915a72253fd103dae93308031ec3f
</ins><span class="cx"> diff --git a/Makefile.in b/Makefile.in
</span><span class="cx"> --- a/Makefile.in
</span><span class="cx"> +++ b/Makefile.in
</span><del>-@@ -42,7 +42,7 @@ popt_OBJS=popt/findme.o  popt/popt.o  popt/poptconfig.o \
</del><ins>+@@ -45,7 +45,7 @@ popt_OBJS=popt/findme.o  popt/popt.o  popt/poptconfig.o \
</ins><span class="cx">          popt/popthelp.o popt/poptparse.o
</span><del>- OBJS=$(OBJS1) $(OBJS2) $(OBJS3) $(DAEMON_OBJ) $(LIBOBJ) $(ZLIBOBJ) @BUILD_POPT@
</del><ins>+ OBJS=$(OBJS1) $(OBJS2) $(OBJS3) $(DAEMON_OBJ) $(LIBOBJ) @BUILD_ZLIB@ @BUILD_POPT@
</ins><span class="cx">  
</span><span class="cx"> -TLS_OBJ = tls.o syscall.o lib/compat.o lib/snprintf.o lib/permstring.o lib/sysxattrs.o @BUILD_POPT@
</span><span class="cx"> +TLS_OBJ = tls.o syscall.o t_stub.o lib/compat.o lib/snprintf.o lib/permstring.o lib/sysxattrs.o @BUILD_POPT@
</span><span class="cx">  
</span><span class="cx">  # Programs we must have to run the test cases
</span><span class="cx">  CHECK_PROGS = rsync$(EXEEXT) tls$(EXEEXT) getgroups$(EXEEXT) getfsdev$(EXEEXT) \
</span><del>-@@ -107,7 +107,7 @@ getgroups$(EXEEXT): getgroups.o
</del><ins>+@@ -127,7 +127,7 @@ getgroups$(EXEEXT): getgroups.o
</ins><span class="cx">  getfsdev$(EXEEXT): getfsdev.o
</span><span class="cx">          $(CC) $(CFLAGS) $(LDFLAGS) -o $@ getfsdev.o $(LIBS)
</span><span class="cx">  
</span><span class="lines">@@ -33,7 +33,7 @@
</span><span class="cx"> diff --git a/compat.c b/compat.c
</span><span class="cx"> --- a/compat.c
</span><span class="cx"> +++ b/compat.c
</span><del>-@@ -43,9 +43,11 @@ extern int checksum_seed;
</del><ins>+@@ -44,9 +44,11 @@ extern int checksum_seed;
</ins><span class="cx">  extern int basis_dir_cnt;
</span><span class="cx">  extern int prune_empty_dirs;
</span><span class="cx">  extern int protocol_version;
</span><span class="lines">@@ -45,7 +45,7 @@
</span><span class="cx">  extern int preserve_acls;
</span><span class="cx">  extern int preserve_xattrs;
</span><span class="cx">  extern int need_messages_from_generator;
</span><del>-@@ -63,7 +65,7 @@ extern char *iconv_opt;
</del><ins>+@@ -64,7 +66,7 @@ extern char *iconv_opt;
</ins><span class="cx">  #endif
</span><span class="cx">  
</span><span class="cx">  /* These index values are for the file-list's extra-attribute array. */
</span><span class="lines">@@ -54,7 +54,7 @@
</span><span class="cx">  
</span><span class="cx">  int receiver_symlink_times = 0; /* receiver can set the time on a symlink */
</span><span class="cx">  int sender_symlink_iconv = 0;        /* sender should convert symlink content */
</span><del>-@@ -140,6 +142,8 @@ void setup_protocol(int f_out,int f_in)
</del><ins>+@@ -142,6 +144,8 @@ void setup_protocol(int f_out,int f_in)
</ins><span class="cx">                  uid_ndx = ++file_extra_cnt;
</span><span class="cx">          if (preserve_gid)
</span><span class="cx">                  gid_ndx = ++file_extra_cnt;
</span><span class="lines">@@ -66,7 +66,7 @@
</span><span class="cx"> diff --git a/configure.ac b/configure.ac
</span><span class="cx"> --- a/configure.ac
</span><span class="cx"> +++ b/configure.ac
</span><del>-@@ -569,6 +569,7 @@ AC_FUNC_UTIME_NULL
</del><ins>+@@ -597,6 +597,7 @@ AC_FUNC_UTIME_NULL
</ins><span class="cx">  AC_FUNC_ALLOCA
</span><span class="cx">  AC_CHECK_FUNCS(waitpid wait4 getcwd strdup chown chmod lchmod mknod mkfifo \
</span><span class="cx">      fchmod fstat ftruncate strchr readlink link utime utimes lutimes strftime \
</span><span class="lines">@@ -74,18 +74,63 @@
</span><span class="cx">      memmove lchown vsnprintf snprintf vasprintf asprintf setsid strpbrk \
</span><span class="cx">      strlcat strlcpy strtol mallinfo getgroups setgroups geteuid getegid \
</span><span class="cx">      setlocale setmode open64 lseek64 mkstemp64 mtrace va_copy __va_copy \
</span><ins>+diff --git a/delete.c b/delete.c
+--- a/delete.c
++++ b/delete.c
+@@ -25,6 +25,7 @@
+ extern int am_root;
+ extern int make_backups;
+ extern int max_delete;
++extern int force_change;
+ extern char *backup_dir;
+ extern char *backup_suffix;
+ extern int backup_suffix_len;
+@@ -97,8 +98,12 @@ static enum delret delete_dir_contents(char *fname, uint16 flags)
+                 }

+                 strlcpy(p, fp-&gt;basename, remainder);
++#ifdef SUPPORT_FORCE_CHANGE
++                if (force_change)
++                        make_mutable(fname, fp-&gt;mode, F_FFLAGS(fp), force_change);
++#endif
+                 if (!(fp-&gt;mode &amp; S_IWUSR) &amp;&amp; !am_root &amp;&amp; fp-&gt;flags &amp; FLAG_OWNED_BY_US)
+-                        do_chmod(fname, fp-&gt;mode | S_IWUSR);
++                        do_chmod(fname, fp-&gt;mode | S_IWUSR, NO_FFLAGS);
+                 /* Save stack by recursing to ourself directly. */
+                 if (S_ISDIR(fp-&gt;mode)) {
+                         if (delete_dir_contents(fname, flags | DEL_RECURSE) != DR_SUCCESS)
+@@ -139,11 +144,18 @@ enum delret delete_item(char *fbuf, uint16 mode, uint16 flags)
+         }

+         if (flags &amp; DEL_NO_UID_WRITE)
+-                do_chmod(fbuf, mode | S_IWUSR);
++                do_chmod(fbuf, mode | S_IWUSR, NO_FFLAGS);

+         if (S_ISDIR(mode) &amp;&amp; !(flags &amp; DEL_DIR_IS_EMPTY)) {
+                 /* This only happens on the first call to delete_item() since
+                  * delete_dir_contents() always calls us w/DEL_DIR_IS_EMPTY. */
++#ifdef SUPPORT_FORCE_CHANGE
++                if (force_change) {
++                        STRUCT_STAT st;
++                        if (x_lstat(fbuf, &amp;st, NULL) == 0)
++                                make_mutable(fbuf, st.st_mode, st.st_flags, force_change);
++                }
++#endif
+                 ignore_perishable = 1;
+                 /* If DEL_RECURSE is not set, this just reports emptiness. */
+                 ret = delete_dir_contents(fbuf, flags);
</ins><span class="cx"> diff --git a/flist.c b/flist.c
</span><span class="cx"> --- a/flist.c
</span><span class="cx"> +++ b/flist.c
</span><del>-@@ -51,6 +51,7 @@ extern int preserve_links;
</del><ins>+@@ -50,6 +50,7 @@ extern int preserve_links;
</ins><span class="cx">  extern int preserve_hard_links;
</span><span class="cx">  extern int preserve_devices;
</span><span class="cx">  extern int preserve_specials;
</span><span class="cx"> +extern int preserve_fileflags;
</span><span class="cx">  extern int delete_during;
</span><ins>+ extern int missing_args;
</ins><span class="cx">  extern int eol_nulls;
</span><del>- extern int relative_paths;
-@@ -394,6 +395,9 @@ static void send_file_entry(int f, const char *fname, struct file_struct *file,
</del><ins>+@@ -399,6 +400,9 @@ static void send_file_entry(int f, const char *fname, struct file_struct *file,
</ins><span class="cx">  {
</span><span class="cx">          static time_t modtime;
</span><span class="cx">          static mode_t mode;
</span><span class="lines">@@ -95,7 +140,7 @@
</span><span class="cx">  #ifdef SUPPORT_HARD_LINKS
</span><span class="cx">          static int64 dev;
</span><span class="cx">  #endif
</span><del>-@@ -423,6 +427,14 @@ static void send_file_entry(int f, const char *fname, struct file_struct *file,
</del><ins>+@@ -442,6 +446,14 @@ static void send_file_entry(int f, const char *fname, struct file_struct *file,
</ins><span class="cx">                  xflags |= XMIT_SAME_MODE;
</span><span class="cx">          else
</span><span class="cx">                  mode = file-&gt;mode;
</span><span class="lines">@@ -110,8 +155,8 @@
</span><span class="cx">  
</span><span class="cx">          if (preserve_devices &amp;&amp; IS_DEVICE(mode)) {
</span><span class="cx">                  if (protocol_version &lt; 28) {
</span><del>-@@ -547,6 +559,10 @@ static void send_file_entry(int f, const char *fname, struct file_struct *file,
-         }
</del><ins>+@@ -583,6 +595,10 @@ static void send_file_entry(int f, const char *fname, struct file_struct *file,
+                 write_varint(f, F_MOD_NSEC(file));
</ins><span class="cx">          if (!(xflags &amp; XMIT_SAME_MODE))
</span><span class="cx">                  write_int(f, to_wire_mode(mode));
</span><span class="cx"> +#ifdef SUPPORT_FILEFLAGS
</span><span class="lines">@@ -121,7 +166,7 @@
</span><span class="cx">          if (preserve_uid &amp;&amp; !(xflags &amp; XMIT_SAME_UID)) {
</span><span class="cx">                  if (protocol_version &lt; 30)
</span><span class="cx">                          write_int(f, uid);
</span><del>-@@ -634,6 +650,9 @@ static struct file_struct *recv_file_entry(int f, struct file_list *flist, int x
</del><ins>+@@ -672,6 +688,9 @@ static struct file_struct *recv_file_entry(int f, struct file_list *flist, int x
</ins><span class="cx">  {
</span><span class="cx">          static int64 modtime;
</span><span class="cx">          static mode_t mode;
</span><span class="lines">@@ -131,9 +176,9 @@
</span><span class="cx">  #ifdef SUPPORT_HARD_LINKS
</span><span class="cx">          static int64 dev;
</span><span class="cx">  #endif
</span><del>-@@ -731,6 +750,10 @@ static struct file_struct *recv_file_entry(int f, struct file_list *flist, int x
-                         file_length = F_LENGTH(first);
</del><ins>+@@ -779,6 +798,10 @@ static struct file_struct *recv_file_entry(int f, struct file_list *flist, int x
</ins><span class="cx">                          modtime = first-&gt;modtime;
</span><ins>+                         modtime_nsec = F_MOD_NSEC(first);
</ins><span class="cx">                          mode = first-&gt;mode;
</span><span class="cx"> +#ifdef SUPPORT_FILEFLAGS
</span><span class="cx"> +                        if (preserve_fileflags)
</span><span class="lines">@@ -142,9 +187,9 @@
</span><span class="cx">                          if (preserve_uid)
</span><span class="cx">                                  uid = F_OWNER(first);
</span><span class="cx">                          if (preserve_gid)
</span><del>-@@ -768,6 +791,10 @@ static struct file_struct *recv_file_entry(int f, struct file_list *flist, int x
</del><ins>+@@ -820,6 +843,10 @@ static struct file_struct *recv_file_entry(int f, struct file_list *flist, int x
</ins><span class="cx">  
</span><del>-         if (chmod_modes &amp;&amp; !S_ISLNK(mode))
</del><ins>+         if (chmod_modes &amp;&amp; !S_ISLNK(mode) &amp;&amp; mode)
</ins><span class="cx">                  mode = tweak_mode(mode, chmod_modes);
</span><span class="cx"> +#ifdef SUPPORT_FILEFLAGS
</span><span class="cx"> +        if (preserve_fileflags &amp;&amp; !(xflags &amp; XMIT_SAME_FLAGS))
</span><span class="lines">@@ -153,18 +198,18 @@
</span><span class="cx">  
</span><span class="cx">          if (preserve_uid &amp;&amp; !(xflags &amp; XMIT_SAME_UID)) {
</span><span class="cx">                  if (protocol_version &lt; 30)
</span><del>-@@ -909,6 +936,10 @@ static struct file_struct *recv_file_entry(int f, struct file_list *flist, int x
</del><ins>+@@ -978,6 +1005,10 @@ static struct file_struct *recv_file_entry(int f, struct file_list *flist, int x
</ins><span class="cx">          }
</span><span class="cx">  #endif
</span><span class="cx">          file-&gt;mode = mode;
</span><span class="cx"> +#ifdef SUPPORT_FILEFLAGS
</span><del>-+        if (fileflags_ndx) /* check the ndx for force_change w/o preserve_fileflags */
</del><ins>++        if (preserve_fileflags)
</ins><span class="cx"> +                F_FFLAGS(file) = fileflags;
</span><span class="cx"> +#endif
</span><span class="cx">          if (preserve_uid)
</span><span class="cx">                  F_OWNER(file) = uid;
</span><span class="cx">          if (preserve_gid) {
</span><del>-@@ -1283,6 +1314,10 @@ struct file_struct *make_file(const char *fname, struct file_list *flist,
</del><ins>+@@ -1375,6 +1406,10 @@ struct file_struct *make_file(const char *fname, struct file_list *flist,
</ins><span class="cx">          }
</span><span class="cx">  #endif
</span><span class="cx">          file-&gt;mode = st.st_mode;
</span><span class="lines">@@ -175,69 +220,21 @@
</span><span class="cx">          if (preserve_uid)
</span><span class="cx">                  F_OWNER(file) = st.st_uid;
</span><span class="cx">          if (preserve_gid)
</span><del>-@@ -1429,6 +1464,9 @@ static struct file_struct *send_file_name(int f, struct file_list *flist,
- #ifdef SUPPORT_XATTRS
-                 if (preserve_xattrs) {
-                         sx.st.st_mode = file-&gt;mode;
-+#ifdef SUPPORT_FILEFLAGS
-+                        sx.st.st_flags = preserve_fileflags ? F_FFLAGS(file) : 0;
-+#endif
-                         sx.xattr = NULL;
-                         if (get_xattr(fname, &amp;sx) &lt; 0) {
-                                 io_error |= IOERR_GENERAL;
</del><span class="cx"> diff --git a/generator.c b/generator.c
</span><span class="cx"> --- a/generator.c
</span><span class="cx"> +++ b/generator.c
</span><del>-@@ -35,6 +35,7 @@ extern int do_progress;
- extern int relative_paths;
- extern int implied_dirs;
- extern int keep_dirlinks;
-+extern int force_change;
- extern int preserve_acls;
- extern int preserve_xattrs;
- extern int preserve_links;
-@@ -42,6 +43,7 @@ extern int preserve_devices;
</del><ins>+@@ -42,8 +42,10 @@ extern int preserve_devices;
</ins><span class="cx">  extern int preserve_specials;
</span><span class="cx">  extern int preserve_hard_links;
</span><span class="cx">  extern int preserve_executability;
</span><span class="cx"> +extern int preserve_fileflags;
</span><span class="cx">  extern int preserve_perms;
</span><span class="cx">  extern int preserve_times;
</span><ins>++extern int force_change;
</ins><span class="cx">  extern int delete_mode;
</span><del>-@@ -164,11 +166,15 @@ static enum delret delete_item(char *fbuf, uint16 mode, uint16 flags)
-         }

-         if (flags &amp; DEL_NO_UID_WRITE)
--                do_chmod(fbuf, mode | S_IWUSR);
-+                do_chmod(fbuf, mode | S_IWUSR, NO_FFLAGS);

-         if (S_ISDIR(mode) &amp;&amp; !(flags &amp; DEL_DIR_IS_EMPTY)) {
-                 /* This only happens on the first call to delete_item() since
-                  * delete_dir_contents() always calls us w/DEL_DIR_IS_EMPTY. */
-+#ifdef SUPPORT_FORCE_CHANGE
-+                if (force_change)
-+                        make_mutable(fbuf, NULL, NO_FFLAGS, force_change);
-+#endif
-                 ignore_perishable = 1;
-                 /* If DEL_RECURSE is not set, this just reports emptiness. */
-                 ret = delete_dir_contents(fbuf, flags);
-@@ -285,8 +291,14 @@ static enum delret delete_dir_contents(char *fname, uint16 flags)
-                 }

-                 strlcpy(p, fp-&gt;basename, remainder);
-+#ifdef SUPPORT_FORCE_CHANGE
-+                if (force_change) {
-+                        mode_t mode = fp-&gt;mode;
-+                        make_mutable(fname, &amp;mode, F_FFLAGS(fp), force_change);
-+                }
-+#endif
-                 if (!(fp-&gt;mode &amp; S_IWUSR) &amp;&amp; !am_root &amp;&amp; fp-&gt;flags &amp; FLAG_OWNED_BY_US)
--                        do_chmod(fname, fp-&gt;mode | S_IWUSR);
-+                        do_chmod(fname, fp-&gt;mode | S_IWUSR, NO_FFLAGS);
-                 /* Save stack by recursing to ourself directly. */
-                 if (S_ISDIR(fp-&gt;mode)) {
-                         if (delete_dir_contents(fname, flags | DEL_RECURSE) != DR_SUCCESS)
-@@ -647,6 +659,10 @@ int unchanged_attrs(const char *fname, struct file_struct *file, stat_x *sxp)
</del><ins>+ extern int delete_before;
+ extern int delete_during;
+@@ -465,6 +467,10 @@ int unchanged_attrs(const char *fname, struct file_struct *file, stat_x *sxp)
</ins><span class="cx">                          return 0;
</span><span class="cx">                  if (perms_differ(file, sxp))
</span><span class="cx">                          return 0;
</span><span class="lines">@@ -248,7 +245,7 @@
</span><span class="cx">                  if (ownership_differs(file, sxp))
</span><span class="cx">                          return 0;
</span><span class="cx">  #ifdef SUPPORT_ACLS
</span><del>-@@ -698,6 +714,11 @@ void itemize(const char *fnamecmp, struct file_struct *file, int ndx, int statre
</del><ins>+@@ -516,6 +522,11 @@ void itemize(const char *fnamecmp, struct file_struct *file, int ndx, int statre
</ins><span class="cx">                  if (gid_ndx &amp;&amp; !(file-&gt;flags &amp; FLAG_SKIP_GROUP)
</span><span class="cx">                      &amp;&amp; sxp-&gt;st.st_gid != (gid_t)F_GROUP(file))
</span><span class="cx">                          iflags |= ITEM_REPORT_GROUP;
</span><span class="lines">@@ -260,7 +257,7 @@
</span><span class="cx">  #ifdef SUPPORT_ACLS
</span><span class="cx">                  if (preserve_acls &amp;&amp; !S_ISLNK(file-&gt;mode)) {
</span><span class="cx">                          if (!ACL_READY(*sxp))
</span><del>-@@ -1491,6 +1512,10 @@ static void recv_generator(char *fname, struct file_struct *file, int ndx,
</del><ins>+@@ -1395,6 +1406,10 @@ static void recv_generator(char *fname, struct file_struct *file, int ndx,
</ins><span class="cx">                          file-&gt;mode = dest_mode(file-&gt;mode, sx.st.st_mode,
</span><span class="cx">                                                 dflt_perms, statret == 0);
</span><span class="cx">                  }
</span><span class="lines">@@ -271,16 +268,14 @@
</span><span class="cx">                  if (statret != 0 &amp;&amp; basis_dir[0] != NULL) {
</span><span class="cx">                          int j = try_dests_non(file, fname, ndx, fnamecmpbuf, &amp;sx,
</span><span class="cx">                                                itemizing, code);
</span><del>-@@ -1535,10 +1560,17 @@ static void recv_generator(char *fname, struct file_struct *file, int ndx,
</del><ins>+@@ -1439,10 +1454,15 @@ static void recv_generator(char *fname, struct file_struct *file, int ndx,
</ins><span class="cx">                   * readable and writable permissions during the time we are
</span><span class="cx">                   * putting files within them.  This is then restored to the
</span><span class="cx">                   * former permissions after the transfer is done. */
</span><span class="cx"> +#ifdef SUPPORT_FORCE_CHANGE
</span><del>-+                if (force_change &amp;&amp; F_FFLAGS(file) &amp; force_change) {
-+                        mode_t mode = file-&gt;mode;
-+                        if (make_mutable(fname, &amp;mode, F_FFLAGS(file), force_change))
-+                                need_retouch_dir_perms = 1;
-+                }
</del><ins>++                if (force_change &amp;&amp; F_FFLAGS(file) &amp; force_change
++                 &amp;&amp; make_mutable(fname, file-&gt;mode, F_FFLAGS(file), force_change))
++                        need_retouch_dir_perms = 1;
</ins><span class="cx"> +#endif
</span><span class="cx">  #ifdef HAVE_CHMOD
</span><span class="cx">                  if (!am_root &amp;&amp; (file-&gt;mode &amp; S_IRWXU) != S_IRWXU &amp;&amp; dir_tweaking) {
</span><span class="lines">@@ -290,7 +285,7 @@
</span><span class="cx">                                  rsyserr(FERROR_XFER, errno,
</span><span class="cx">                                          &quot;failed to modify permissions on %s&quot;,
</span><span class="cx">                                          full_fname(fname));
</span><del>-@@ -1573,6 +1605,10 @@ static void recv_generator(char *fname, struct file_struct *file, int ndx,
</del><ins>+@@ -1477,6 +1497,10 @@ static void recv_generator(char *fname, struct file_struct *file, int ndx,
</ins><span class="cx">                  file-&gt;mode = dest_mode(file-&gt;mode, sx.st.st_mode, dflt_perms,
</span><span class="cx">                                         exists);
</span><span class="cx">          }
</span><span class="lines">@@ -301,7 +296,7 @@
</span><span class="cx">  
</span><span class="cx">  #ifdef SUPPORT_HARD_LINKS
</span><span class="cx">          if (preserve_hard_links &amp;&amp; F_HLINK_NOT_FIRST(file)
</span><del>-@@ -2116,13 +2152,17 @@ static void touch_up_dirs(struct file_list *flist, int ndx)
</del><ins>+@@ -2045,13 +2069,17 @@ static void touch_up_dirs(struct file_list *flist, int ndx)
</ins><span class="cx">                          continue;
</span><span class="cx">                  fname = f_name(file, NULL);
</span><span class="cx">                  if (fix_dir_perms)
</span><span class="lines">@@ -311,8 +306,8 @@
</span><span class="cx">                          STRUCT_STAT st;
</span><span class="cx">                          if (link_stat(fname, &amp;st, 0) == 0
</span><span class="cx">                           &amp;&amp; cmp_time(st.st_mtime, file-&gt;modtime) != 0)
</span><del>--                                set_modtime(fname, file-&gt;modtime, file-&gt;mode);
-+                                set_modtime(fname, file-&gt;modtime, file-&gt;mode, 0);
</del><ins>+-                                set_modtime(fname, file-&gt;modtime, F_MOD_NSEC(file), file-&gt;mode);
++                                set_modtime(fname, file-&gt;modtime, F_MOD_NSEC(file), file-&gt;mode, 0);
</ins><span class="cx">                  }
</span><span class="cx"> +#ifdef SUPPORT_FORCE_CHANGE
</span><span class="cx"> +                if (force_change &amp;&amp; F_FFLAGS(file) &amp; force_change)
</span><span class="lines">@@ -320,11 +315,11 @@
</span><span class="cx"> +#endif
</span><span class="cx">                  if (counter &gt;= loopchk_limit) {
</span><span class="cx">                          if (allowed_lull)
</span><del>-                                 maybe_send_keepalive();
</del><ins>+                                 maybe_send_keepalive(time(NULL), MSK_ALLOW_FLUSH);
</ins><span class="cx"> diff --git a/log.c b/log.c
</span><span class="cx"> --- a/log.c
</span><span class="cx"> +++ b/log.c
</span><del>-@@ -658,7 +658,7 @@ static void log_formatted(enum logcode code, const char *format, const char *op,
</del><ins>+@@ -720,7 +720,7 @@ static void log_formatted(enum logcode code, const char *format, const char *op,
</ins><span class="cx">                          c[5] = !(iflags &amp; ITEM_REPORT_PERMS) ? '.' : 'p';
</span><span class="cx">                          c[6] = !(iflags &amp; ITEM_REPORT_OWNER) ? '.' : 'o';
</span><span class="cx">                          c[7] = !(iflags &amp; ITEM_REPORT_GROUP) ? '.' : 'g';
</span><span class="lines">@@ -344,17 +339,17 @@
</span><span class="cx"> +#include &lt;sys/sysctl.h&gt;
</span><span class="cx"> +#endif
</span><span class="cx">  
</span><del>- extern int verbose;
</del><span class="cx">  extern int dry_run;
</span><del>-@@ -51,6 +54,7 @@ extern int protocol_version;
</del><ins>+ extern int list_only;
+@@ -51,6 +54,7 @@ extern int copy_unsafe_links;
+ extern int keep_dirlinks;
+ extern int preserve_hard_links;
+ extern int protocol_version;
++extern int force_change;
</ins><span class="cx">  extern int file_total;
</span><span class="cx">  extern int recurse;
</span><span class="cx">  extern int xfer_dirs;
</span><del>-+extern int force_change;
- extern int protect_args;
- extern int relative_paths;
- extern int sanitize_paths;
-@@ -753,6 +757,22 @@ static int do_recv(int f_in, int f_out, char *local_name)
</del><ins>+@@ -839,6 +843,22 @@ static int do_recv(int f_in, int f_out, char *local_name)
</ins><span class="cx">           * points to an identical file won't be replaced by the referent. */
</span><span class="cx">          copy_links = copy_dirlinks = copy_unsafe_links = 0;
</span><span class="cx">  
</span><span class="lines">@@ -380,7 +375,7 @@
</span><span class="cx"> diff --git a/options.c b/options.c
</span><span class="cx"> --- a/options.c
</span><span class="cx"> +++ b/options.c
</span><del>-@@ -53,6 +53,7 @@ int preserve_hard_links = 0;
</del><ins>+@@ -55,6 +55,7 @@ int preserve_hard_links = 0;
</ins><span class="cx">  int preserve_acls = 0;
</span><span class="cx">  int preserve_xattrs = 0;
</span><span class="cx">  int preserve_perms = 0;
</span><span class="lines">@@ -388,15 +383,15 @@
</span><span class="cx">  int preserve_executability = 0;
</span><span class="cx">  int preserve_devices = 0;
</span><span class="cx">  int preserve_specials = 0;
</span><del>-@@ -84,6 +85,7 @@ int implied_dirs = 1;
- int numeric_ids = 0;
</del><ins>+@@ -89,6 +90,7 @@ int numeric_ids = 0;
+ int msgs2stderr = 0;
</ins><span class="cx">  int allow_8bit_chars = 0;
</span><span class="cx">  int force_delete = 0;
</span><span class="cx"> +int force_change = 0;
</span><span class="cx">  int io_timeout = 0;
</span><span class="cx">  int prune_empty_dirs = 0;
</span><span class="cx">  int use_qsort = 0;
</span><del>-@@ -223,6 +225,7 @@ static void print_rsync_version(enum logcode f)
</del><ins>+@@ -574,6 +576,7 @@ static void print_rsync_version(enum logcode f)
</ins><span class="cx">          char const *links = &quot;no &quot;;
</span><span class="cx">          char const *iconv = &quot;no &quot;;
</span><span class="cx">          char const *ipv6 = &quot;no &quot;;
</span><span class="lines">@@ -404,7 +399,7 @@
</span><span class="cx">          STRUCT_STAT *dumstat;
</span><span class="cx">  
</span><span class="cx">  #if SUBPROTOCOL_VERSION != 0
</span><del>-@@ -256,6 +259,9 @@ static void print_rsync_version(enum logcode f)
</del><ins>+@@ -610,6 +613,9 @@ static void print_rsync_version(enum logcode f)
</ins><span class="cx">  #ifdef CAN_SET_SYMLINK_TIMES
</span><span class="cx">          symtimes = &quot;&quot;;
</span><span class="cx">  #endif
</span><span class="lines">@@ -414,18 +409,18 @@
</span><span class="cx">  
</span><span class="cx">          rprintf(f, &quot;%s  version %s  protocol version %d%s\n&quot;,
</span><span class="cx">                  RSYNC_NAME, RSYNC_VERSION, PROTOCOL_VERSION, subprotocol);
</span><del>-@@ -269,8 +275,8 @@ static void print_rsync_version(enum logcode f)
</del><ins>+@@ -623,8 +629,8 @@ static void print_rsync_version(enum logcode f)
</ins><span class="cx">                  (int)(sizeof (int64) * 8));
</span><span class="cx">          rprintf(f, &quot;    %ssocketpairs, %shardlinks, %ssymlinks, %sIPv6, batchfiles, %sinplace,\n&quot;,
</span><span class="cx">                  got_socketpair, hardlinks, links, ipv6, have_inplace);
</span><del>--        rprintf(f, &quot;    %sappend, %sACLs, %sxattrs, %siconv, %ssymtimes\n&quot;,
--                have_inplace, acls, xattrs, iconv, symtimes);
-+        rprintf(f, &quot;    %sappend, %sACLs, %sxattrs, %siconv, %ssymtimes, %sfile-flags\n&quot;,
-+                have_inplace, acls, xattrs, iconv, symtimes, fileflags);
</del><ins>+-        rprintf(f, &quot;    %sappend, %sACLs, %sxattrs, %siconv, %ssymtimes, %sprealloc\n&quot;,
+-                have_inplace, acls, xattrs, iconv, symtimes, prealloc);
++        rprintf(f, &quot;    %sappend, %sACLs, %sxattrs, %siconv, %ssymtimes, %sprealloc, %sfile-flags\n&quot;,
++                have_inplace, acls, xattrs, iconv, symtimes, prealloc, fileflags);
</ins><span class="cx">  
</span><span class="cx">  #ifdef MAINTAINER_MODE
</span><span class="cx">          rprintf(f, &quot;Panic Action: \&quot;%s\&quot;\n&quot;, get_panic_action());
</span><del>-@@ -337,6 +343,9 @@ void usage(enum logcode F)
</del><ins>+@@ -695,6 +701,9 @@ void usage(enum logcode F)
</ins><span class="cx">    rprintf(F,&quot; -K, --keep-dirlinks         treat symlinked dir on receiver as dir\n&quot;);
</span><span class="cx">    rprintf(F,&quot; -H, --hard-links            preserve hard links\n&quot;);
</span><span class="cx">    rprintf(F,&quot; -p, --perms                 preserve permissions\n&quot;);
</span><span class="lines">@@ -435,9 +430,9 @@
</span><span class="cx">    rprintf(F,&quot; -E, --executability         preserve the file's executability\n&quot;);
</span><span class="cx">    rprintf(F,&quot;     --chmod=CHMOD           affect file and/or directory permissions\n&quot;);
</span><span class="cx">  #ifdef SUPPORT_ACLS
</span><del>-@@ -374,7 +383,12 @@ void usage(enum logcode F)
-   rprintf(F,&quot;     --delete-after          receiver deletes after transfer, not during\n&quot;);
-   rprintf(F,&quot;     --delete-excluded       also delete excluded files from destination dirs\n&quot;);
</del><ins>+@@ -740,7 +749,12 @@ void usage(enum logcode F)
+   rprintf(F,&quot;     --ignore-missing-args   ignore missing source args without error\n&quot;);
+   rprintf(F,&quot;     --delete-missing-args   delete missing source args from destination\n&quot;);
</ins><span class="cx">    rprintf(F,&quot;     --ignore-errors         delete even if there are I/O errors\n&quot;);
</span><span class="cx"> -  rprintf(F,&quot;     --force                 force deletion of directories even if not empty\n&quot;);
</span><span class="cx"> +  rprintf(F,&quot;     --force-delete          force deletion of directories even if not empty\n&quot;);
</span><span class="lines">@@ -449,7 +444,7 @@
</span><span class="cx">    rprintf(F,&quot;     --max-delete=NUM        don't delete more than NUM files\n&quot;);
</span><span class="cx">    rprintf(F,&quot;     --max-size=SIZE         don't transfer any file larger than SIZE\n&quot;);
</span><span class="cx">    rprintf(F,&quot;     --min-size=SIZE         don't transfer any file smaller than SIZE\n&quot;);
</span><del>-@@ -479,6 +493,10 @@ static struct poptOption long_options[] = {
</del><ins>+@@ -857,6 +871,10 @@ static struct poptOption long_options[] = {
</ins><span class="cx">    {&quot;perms&quot;,           'p', POPT_ARG_VAL,    &amp;preserve_perms, 1, 0, 0 },
</span><span class="cx">    {&quot;no-perms&quot;,         0,  POPT_ARG_VAL,    &amp;preserve_perms, 0, 0, 0 },
</span><span class="cx">    {&quot;no-p&quot;,             0,  POPT_ARG_VAL,    &amp;preserve_perms, 0, 0, 0 },
</span><span class="lines">@@ -460,7 +455,7 @@
</span><span class="cx">    {&quot;executability&quot;,   'E', POPT_ARG_NONE,   &amp;preserve_executability, 0, 0, 0 },
</span><span class="cx">    {&quot;acls&quot;,            'A', POPT_ARG_NONE,   0, 'A', 0, 0 },
</span><span class="cx">    {&quot;no-acls&quot;,          0,  POPT_ARG_VAL,    &amp;preserve_acls, 0, 0, 0 },
</span><del>-@@ -557,6 +575,14 @@ static struct poptOption long_options[] = {
</del><ins>+@@ -943,6 +961,14 @@ static struct poptOption long_options[] = {
</ins><span class="cx">    {&quot;remove-source-files&quot;,0,POPT_ARG_VAL,    &amp;remove_source_files, 1, 0, 0 },
</span><span class="cx">    {&quot;force&quot;,            0,  POPT_ARG_VAL,    &amp;force_delete, 1, 0, 0 },
</span><span class="cx">    {&quot;no-force&quot;,         0,  POPT_ARG_VAL,    &amp;force_delete, 0, 0, 0 },
</span><span class="lines">@@ -475,7 +470,7 @@
</span><span class="cx">    {&quot;ignore-errors&quot;,    0,  POPT_ARG_VAL,    &amp;ignore_errors, 1, 0, 0 },
</span><span class="cx">    {&quot;no-ignore-errors&quot;, 0,  POPT_ARG_VAL,    &amp;ignore_errors, 0, 0, 0 },
</span><span class="cx">    {&quot;max-delete&quot;,       0,  POPT_ARG_INT,    &amp;max_delete, 0, 0, 0 },
</span><del>-@@ -1879,6 +1905,9 @@ void server_options(char **args, int *argc_p)
</del><ins>+@@ -2537,6 +2563,9 @@ void server_options(char **args, int *argc_p)
</ins><span class="cx">          if (xfer_dirs &amp;&amp; !recurse &amp;&amp; delete_mode &amp;&amp; am_sender)
</span><span class="cx">                  args[ac++] = &quot;--no-r&quot;;
</span><span class="cx">  
</span><span class="lines">@@ -485,7 +480,7 @@
</span><span class="cx">          if (do_compression &amp;&amp; def_compress_level != Z_DEFAULT_COMPRESSION) {
</span><span class="cx">                  if (asprintf(&amp;arg, &quot;--compress-level=%d&quot;, def_compress_level) &lt; 0)
</span><span class="cx">                          goto oom;
</span><del>-@@ -1966,6 +1995,16 @@ void server_options(char **args, int *argc_p)
</del><ins>+@@ -2624,6 +2653,16 @@ void server_options(char **args, int *argc_p)
</ins><span class="cx">                          args[ac++] = &quot;--delete-excluded&quot;;
</span><span class="cx">                  if (force_delete)
</span><span class="cx">                          args[ac++] = &quot;--force&quot;;
</span><span class="lines">@@ -505,11 +500,7 @@
</span><span class="cx"> diff --git a/rsync.c b/rsync.c
</span><span class="cx"> --- a/rsync.c
</span><span class="cx"> +++ b/rsync.c
</span><del>-@@ -29,9 +29,11 @@

- extern int verbose;
- extern int dry_run;
-+extern int force_change;
</del><ins>+@@ -31,6 +31,7 @@ extern int dry_run;
</ins><span class="cx">  extern int preserve_acls;
</span><span class="cx">  extern int preserve_xattrs;
</span><span class="cx">  extern int preserve_perms;
</span><span class="lines">@@ -517,7 +508,7 @@
</span><span class="cx">  extern int preserve_executability;
</span><span class="cx">  extern int preserve_times;
</span><span class="cx">  extern int am_root;
</span><del>-@@ -374,6 +376,74 @@ mode_t dest_mode(mode_t flist_mode, mode_t stat_mode, int dflt_perms,
</del><ins>+@@ -452,6 +453,39 @@ mode_t dest_mode(mode_t flist_mode, mode_t stat_mode, int dflt_perms,
</ins><span class="cx">          return new_mode;
</span><span class="cx">  }
</span><span class="cx">  
</span><span class="lines">@@ -527,103 +518,37 @@
</span><span class="cx"> +{
</span><span class="cx"> +        if (do_chflags(fname, fileflags) != 0) {
</span><span class="cx"> +                rsyserr(FERROR_XFER, errno,
</span><del>-+                        &quot;failed to set fileflags (%x) on %s&quot;,
-+                        fileflags, full_fname(fname));
</del><ins>++                        &quot;failed to set file flags on %s&quot;,
++                        full_fname(fname));
</ins><span class="cx"> +                return 0;
</span><span class="cx"> +        }
</span><span class="cx"> +
</span><span class="cx"> +        return 1;
</span><span class="cx"> +}
</span><span class="cx"> +
</span><del>-+/* Remove immutable flags from an object, so it can be altered/removed.
-+ * Returns the fileflags if flags were removed, otherwise 0.  If the
-+ * fileflags value is NO_FFLAGS, we will stat the fname to figure out
-+ * what the flags are, and return the mode via *mode_ptr (if non-NULL). */
-+uint32 make_mutable(const char *fname, mode_t *mode_ptr, uint32 fileflags, uint32 iflags)
</del><ins>++/* Remove immutable flags from an object, so it can be altered/removed. */
++int make_mutable(const char *fname, mode_t mode, uint32 fileflags, uint32 iflags)
</ins><span class="cx"> +{
</span><del>-+        if (fileflags == NO_FFLAGS) {
-+                STRUCT_STAT st;
-+                if (x_lstat(fname, &amp;st, NULL) &lt; 0)
-+                        return 0;
-+                fileflags = st.st_flags;
-+                if (mode_ptr)
-+                        *mode_ptr = st.st_mode;
-+                else
-+                        mode_ptr = &amp;st.st_mode;
-+        }
-+
-+        if ((mode_ptr &amp;&amp; S_ISLNK(*mode_ptr)) || !(fileflags &amp; iflags))
</del><ins>++        if (S_ISLNK(mode) || !(fileflags &amp; iflags))
</ins><span class="cx"> +                return 0;
</span><del>-+
</del><span class="cx"> +        if (!set_fileflags(fname, fileflags &amp; ~iflags))
</span><del>-+                return 0;
-+
-+        return fileflags;
</del><ins>++                return -1;
++        return 1;
</ins><span class="cx"> +}
</span><span class="cx"> +
</span><span class="cx"> +/* Undo a prior make_mutable() call that returned a 1. */
</span><span class="cx"> +int undo_make_mutable(const char *fname, uint32 fileflags)
</span><span class="cx"> +{
</span><del>-+        if (!set_fileflags(fname, fileflags)) {
-+                rsyserr(FINFO, errno, &quot;failed to relock %s&quot;, full_fname(fname));
</del><ins>++        if (!set_fileflags(fname, fileflags))
</ins><span class="cx"> +                return -1;
</span><del>-+        }
</del><span class="cx"> +        return 1;
</span><span class="cx"> +}
</span><del>-+
-+/* This returns the st_flags value if the parent directory was made mutable, otherwise 0.
-+ * It stores the parent directory path into parent_dirbuf. */
-+int make_parentdir_mutable(const char *fname, uint32 iflags, char *parent_dirbuf, int parent_dirbuf_size)
-+{
-+        char *slash = strrchr(fname, '/');
-+
-+        if (slash) {
-+                int len = slash - fname;
-+                if (len &gt;= parent_dirbuf_size)
-+                        return 0;
-+                strlcpy(parent_dirbuf, fname, len+1);
-+        } else
-+                strlcpy(parent_dirbuf, &quot;.&quot;, parent_dirbuf_size);
-+
-+        return make_mutable(parent_dirbuf, NULL, NO_FFLAGS, iflags);
-+}
</del><span class="cx"> +#endif
</span><span class="cx"> +
</span><span class="cx">  int set_file_attrs(const char *fname, struct file_struct *file, stat_x *sxp,
</span><span class="cx">                     const char *fnamecmp, int flags)
</span><span class="cx">  {
</span><del>-@@ -382,6 +452,9 @@ int set_file_attrs(const char *fname, struct file_struct *file, stat_x *sxp,
-         int change_uid, change_gid;
-         mode_t new_mode = file-&gt;mode;
-         int inherit;
-+#ifdef SUPPORT_FORCE_CHANGE
-+        int became_mutable = 0;
-+#endif

-         if (!sxp) {
-                 if (dry_run)
-@@ -411,6 +484,11 @@ int set_file_attrs(const char *fname, struct file_struct *file, stat_x *sxp,
-         if (daemon_chmod_modes &amp;&amp; !S_ISLNK(new_mode))
-                 new_mode = tweak_mode(new_mode, daemon_chmod_modes);

-+#ifdef SUPPORT_FORCE_CHANGE
-+        if (force_change)
-+                became_mutable = make_mutable(fname, &amp;sxp-&gt;st.st_mode, sxp-&gt;st.st_flags, force_change);
-+#endif
-+
- #ifdef SUPPORT_ACLS
-         if (preserve_acls &amp;&amp; !S_ISLNK(file-&gt;mode) &amp;&amp; !ACL_READY(*sxp))
-                 get_acl(fname, sxp);
-@@ -429,7 +507,7 @@ int set_file_attrs(const char *fname, struct file_struct *file, stat_x *sxp,
-                 flags |= ATTRS_SKIP_MTIME;
-         if (!(flags &amp; ATTRS_SKIP_MTIME)
-             &amp;&amp; cmp_time(sxp-&gt;st.st_mtime, file-&gt;modtime) != 0) {
--                int ret = set_modtime(fname, file-&gt;modtime, sxp-&gt;st.st_mode);
-+                int ret = set_modtime(fname, file-&gt;modtime, sxp-&gt;st.st_mode, ST_FLAGS(sxp-&gt;st));
-                 if (ret &lt; 0) {
-                         rsyserr(FERROR_XFER, errno, &quot;failed to set times on %s&quot;,
-                                 full_fname(fname));
-@@ -465,7 +543,7 @@ int set_file_attrs(const char *fname, struct file_struct *file, stat_x *sxp,
</del><ins>+@@ -513,7 +547,7 @@ int set_file_attrs(const char *fname, struct file_struct *file, stat_x *sxp,
</ins><span class="cx">                  if (am_root &gt;= 0) {
</span><span class="cx">                          uid_t uid = change_uid ? (uid_t)F_OWNER(file) : sxp-&gt;st.st_uid;
</span><span class="cx">                          gid_t gid = change_gid ? (gid_t)F_GROUP(file) : sxp-&gt;st.st_gid;
</span><span class="lines">@@ -632,7 +557,16 @@
</span><span class="cx">                                  /* We shouldn't have attempted to change uid
</span><span class="cx">                                   * or gid unless have the privilege. */
</span><span class="cx">                                  rsyserr(FERROR_XFER, errno, &quot;%s %s failed&quot;,
</span><del>-@@ -503,7 +581,7 @@ int set_file_attrs(const char *fname, struct file_struct *file, stat_x *sxp,
</del><ins>+@@ -549,7 +583,7 @@ int set_file_attrs(const char *fname, struct file_struct *file, stat_x *sxp,
+                 flags |= ATTRS_SKIP_MTIME;
+         if (!(flags &amp; ATTRS_SKIP_MTIME)
+             &amp;&amp; cmp_time(sxp-&gt;st.st_mtime, file-&gt;modtime) != 0) {
+-                int ret = set_modtime(fname, file-&gt;modtime, F_MOD_NSEC(file), sxp-&gt;st.st_mode);
++                int ret = set_modtime(fname, file-&gt;modtime, F_MOD_NSEC(file), sxp-&gt;st.st_mode, ST_FLAGS(sxp-&gt;st));
+                 if (ret &lt; 0) {
+                         rsyserr(FERROR_XFER, errno, &quot;failed to set times on %s&quot;,
+                                 full_fname(fname));
+@@ -576,7 +610,7 @@ int set_file_attrs(const char *fname, struct file_struct *file, stat_x *sxp,
</ins><span class="cx">  
</span><span class="cx">  #ifdef HAVE_CHMOD
</span><span class="cx">          if (!BITS_EQUAL(sxp-&gt;st.st_mode, new_mode, CHMOD_BITS)) {
</span><span class="lines">@@ -641,15 +575,10 @@
</span><span class="cx">                  if (ret &lt; 0) {
</span><span class="cx">                          rsyserr(FERROR_XFER, errno,
</span><span class="cx">                                  &quot;failed to set permissions on %s&quot;,
</span><del>-@@ -515,6 +593,24 @@ int set_file_attrs(const char *fname, struct file_struct *file, stat_x *sxp,
</del><ins>+@@ -588,6 +622,19 @@ int set_file_attrs(const char *fname, struct file_struct *file, stat_x *sxp,
</ins><span class="cx">          }
</span><span class="cx">  #endif
</span><span class="cx">  
</span><del>-+#ifdef SUPPORT_FORCE_CHANGE
-+        if (became_mutable)
-+                undo_make_mutable(fname, sxp-&gt;st.st_flags);
-+#endif
-+
</del><span class="cx"> +#ifdef SUPPORT_FILEFLAGS
</span><span class="cx"> +        if (preserve_fileflags &amp;&amp; !S_ISLNK(sxp-&gt;st.st_mode)
</span><span class="cx"> +         &amp;&amp; sxp-&gt;st.st_flags != F_FFLAGS(file)) {
</span><span class="lines">@@ -663,10 +592,10 @@
</span><span class="cx"> +        }
</span><span class="cx"> +#endif
</span><span class="cx"> +
</span><del>-         if (verbose &gt; 1 &amp;&amp; flags &amp; ATTRS_REPORT) {
</del><ins>+         if (INFO_GTE(NAME, 2) &amp;&amp; flags &amp; ATTRS_REPORT) {
</ins><span class="cx">                  if (updated)
</span><span class="cx">                          rprintf(FCLIENT, &quot;%s\n&quot;, fname);
</span><del>-@@ -578,7 +674,8 @@ int finish_transfer(const char *fname, const char *fnametmp,
</del><ins>+@@ -662,7 +709,8 @@ int finish_transfer(const char *fname, const char *fnametmp,
</ins><span class="cx">  
</span><span class="cx">          /* Change permissions before putting the file into place. */
</span><span class="cx">          set_file_attrs(fnametmp, file, NULL, fnamecmp,
</span><span class="lines">@@ -675,8 +604,8 @@
</span><span class="cx"> +                       | (ok_to_set_time ? 0 : ATTRS_SKIP_MTIME));
</span><span class="cx">  
</span><span class="cx">          /* move tmp file over real file */
</span><del>-         if (verbose &gt; 2)
-@@ -597,6 +694,10 @@ int finish_transfer(const char *fname, const char *fnametmp,
</del><ins>+         if (DEBUG_GTE(RECV, 1))
+@@ -679,6 +727,10 @@ int finish_transfer(const char *fname, const char *fnametmp,
</ins><span class="cx">          }
</span><span class="cx">          if (ret == 0) {
</span><span class="cx">                  /* The file was moved into place (not copied), so it's done. */
</span><span class="lines">@@ -690,15 +619,15 @@
</span><span class="cx"> diff --git a/rsync.h b/rsync.h
</span><span class="cx"> --- a/rsync.h
</span><span class="cx"> +++ b/rsync.h
</span><del>-@@ -61,6 +61,7 @@
- #define XMIT_GROUP_NAME_FOLLOWS (1&lt;&lt;11) /* protocols 30 - now */
</del><ins>+@@ -62,6 +62,7 @@
</ins><span class="cx">  #define XMIT_HLINK_FIRST (1&lt;&lt;12)        /* protocols 30 - now (HLINKED files only) */
</span><span class="cx">  #define XMIT_IO_ERROR_ENDLIST (1&lt;&lt;12)        /* protocols 31*- now (w/XMIT_EXTENDED_FLAGS) (also protocol 30 w/'f' compat flag) */
</span><ins>+ #define XMIT_MOD_NSEC (1&lt;&lt;13)                /* protocols 31 - now */
</ins><span class="cx"> +#define XMIT_SAME_FLAGS (1&lt;&lt;14)                /* protocols ?? - now */
</span><span class="cx">  
</span><span class="cx">  /* These flags are used in the live flist data. */
</span><span class="cx">  
</span><del>-@@ -160,6 +161,7 @@
</del><ins>+@@ -165,6 +166,7 @@
</ins><span class="cx">  
</span><span class="cx">  #define ATTRS_REPORT                (1&lt;&lt;0)
</span><span class="cx">  #define ATTRS_SKIP_MTIME        (1&lt;&lt;1)
</span><span class="lines">@@ -706,7 +635,7 @@
</span><span class="cx">  
</span><span class="cx">  #define FULL_FLUSH        1
</span><span class="cx">  #define NORMAL_FLUSH        0
</span><del>-@@ -186,6 +188,7 @@
</del><ins>+@@ -191,6 +193,7 @@
</ins><span class="cx">  #define ITEM_REPORT_GROUP (1&lt;&lt;6)
</span><span class="cx">  #define ITEM_REPORT_ACL (1&lt;&lt;7)
</span><span class="cx">  #define ITEM_REPORT_XATTR (1&lt;&lt;8)
</span><span class="lines">@@ -714,7 +643,7 @@
</span><span class="cx">  #define ITEM_BASIS_TYPE_FOLLOWS (1&lt;&lt;11)
</span><span class="cx">  #define ITEM_XNAME_FOLLOWS (1&lt;&lt;12)
</span><span class="cx">  #define ITEM_IS_NEW (1&lt;&lt;13)
</span><del>-@@ -482,6 +485,28 @@ typedef unsigned int size_t;
</del><ins>+@@ -522,6 +525,28 @@ typedef unsigned int size_t;
</ins><span class="cx">  #endif
</span><span class="cx">  #endif
</span><span class="cx">  
</span><span class="lines">@@ -743,7 +672,7 @@
</span><span class="cx">  /* Find a variable that is either exactly 32-bits or longer.
</span><span class="cx">   * If some code depends on 32-bit truncation, it will need to
</span><span class="cx">   * take special action in a &quot;#if SIZEOF_INT32 &gt; 4&quot; section. */
</span><del>-@@ -652,6 +677,7 @@ extern int file_extra_cnt;
</del><ins>+@@ -709,6 +734,7 @@ extern int file_extra_cnt;
</ins><span class="cx">  extern int inc_recurse;
</span><span class="cx">  extern int uid_ndx;
</span><span class="cx">  extern int gid_ndx;
</span><span class="lines">@@ -751,7 +680,7 @@
</span><span class="cx">  extern int acls_ndx;
</span><span class="cx">  extern int xattrs_ndx;
</span><span class="cx">  
</span><del>-@@ -689,6 +715,11 @@ extern int xattrs_ndx;
</del><ins>+@@ -750,6 +776,11 @@ extern int xattrs_ndx;
</ins><span class="cx">  /* When the associated option is on, all entries will have these present: */
</span><span class="cx">  #define F_OWNER(f) REQ_EXTRA(f, uid_ndx)-&gt;unum
</span><span class="cx">  #define F_GROUP(f) REQ_EXTRA(f, gid_ndx)-&gt;unum
</span><span class="lines">@@ -766,7 +695,7 @@
</span><span class="cx"> diff --git a/rsync.yo b/rsync.yo
</span><span class="cx"> --- a/rsync.yo
</span><span class="cx"> +++ b/rsync.yo
</span><del>-@@ -355,6 +355,7 @@ to the detailed description below for a complete description.  verb(
</del><ins>+@@ -362,6 +362,7 @@ to the detailed description below for a complete description.  verb(
</ins><span class="cx">   -K, --keep-dirlinks         treat symlinked dir on receiver as dir
</span><span class="cx">   -H, --hard-links            preserve hard links
</span><span class="cx">   -p, --perms                 preserve permissions
</span><span class="lines">@@ -774,9 +703,9 @@
</span><span class="cx">   -E, --executability         preserve executability
</span><span class="cx">       --chmod=CHMOD           affect file and/or directory permissions
</span><span class="cx">   -A, --acls                  preserve ACLs (implies -p)
</span><del>-@@ -386,7 +387,10 @@ to the detailed description below for a complete description.  verb(
-      --delete-after          receiver deletes after transfer, not during
-      --delete-excluded       also delete excluded files from dest dirs
</del><ins>+@@ -397,7 +398,10 @@ to the detailed description below for a complete description.  verb(
+      --ignore-missing-args   ignore missing source args without error
+      --delete-missing-args   delete missing source args from destination
</ins><span class="cx">       --ignore-errors         delete even if there are I/O errors
</span><span class="cx"> -     --force                 force deletion of dirs even if not empty
</span><span class="cx"> +     --force-delete          force deletion of dirs even if not empty
</span><span class="lines">@@ -786,7 +715,7 @@
</span><span class="cx">       --max-delete=NUM        don't delete more than NUM files
</span><span class="cx">       --max-size=SIZE         don't transfer any file larger than SIZE
</span><span class="cx">       --min-size=SIZE         don't transfer any file smaller than SIZE
</span><del>-@@ -566,7 +570,8 @@ specified, in which case bf(-r) is not implied.
</del><ins>+@@ -644,7 +648,8 @@ specified, in which case bf(-r) is not implied.
</ins><span class="cx">  
</span><span class="cx">  Note that bf(-a) bf(does not preserve hardlinks), because
</span><span class="cx">  finding multiply-linked files is expensive.  You must separately
</span><span class="lines">@@ -796,7 +725,7 @@
</span><span class="cx">  
</span><span class="cx">  dit(--no-OPTION) You may turn off one or more implied options by prefixing
</span><span class="cx">  the option name with &quot;no-&quot;.  Not all options may be prefixed with a &quot;no-&quot;:
</span><del>-@@ -846,7 +851,7 @@ they would be using bf(--copy-links).
</del><ins>+@@ -943,7 +948,7 @@ they would be using bf(--copy-links).
</ins><span class="cx">  Without this option, if the sending side has replaced a directory with a
</span><span class="cx">  symlink to a directory, the receiving side will delete anything that is in
</span><span class="cx">  the way of the new symlink, including a directory hierarchy (as long as
</span><span class="lines">@@ -805,7 +734,7 @@
</span><span class="cx">  
</span><span class="cx">  See also bf(--keep-dirlinks) for an analogous option for the receiving
</span><span class="cx">  side.
</span><del>-@@ -1009,6 +1014,29 @@ Note that this option does not copy rsyncs special xattr values (e.g. those
</del><ins>+@@ -1106,6 +1111,29 @@ Note that this option does not copy rsyncs special xattr values (e.g. those
</ins><span class="cx">  used by bf(--fake-super)) unless you repeat the option (e.g. -XX).  This
</span><span class="cx">  &quot;copy all xattrs&quot; mode cannot be used with bf(--fake-super).
</span><span class="cx">  
</span><span class="lines">@@ -830,12 +759,12 @@
</span><span class="cx"> +dit(bf(--force-schange)) This option causes rsync to disable system-immutable
</span><span class="cx"> +flags on files and directories that are being updated or deleted on the
</span><span class="cx"> +receiving side.  It does not try to affect user flags.  This option overrides
</span><del>-+bf(--force-change) and bf(--force-schange).
</del><ins>++bf(--force-change) and bf(--force-uchange).
</ins><span class="cx"> +
</span><span class="cx">  dit(bf(--chmod)) This option tells rsync to apply one or more
</span><span class="cx">  comma-separated &quot;chmod&quot; modes to the permission of the files in the
</span><span class="cx">  transfer.  The resulting value is treated as though it were the permissions
</span><del>-@@ -1289,12 +1317,13 @@ See bf(--delete) (which is implied) for more details on file-deletion.
</del><ins>+@@ -1435,12 +1463,13 @@ display as a &quot;*missing&quot; entry in the bf(--list-only) output.
</ins><span class="cx">  dit(bf(--ignore-errors)) Tells bf(--delete) to go ahead and delete files
</span><span class="cx">  even when there are I/O errors.
</span><span class="cx">  
</span><span class="lines">@@ -852,7 +781,7 @@
</span><span class="cx">  bf(--recursive) option was also enabled.
</span><span class="cx">  
</span><span class="cx">  dit(bf(--max-delete=NUM)) This tells rsync not to delete more than NUM
</span><del>-@@ -1782,7 +1811,7 @@ with older versions of rsync, but that also turns on the output of other
</del><ins>+@@ -2074,7 +2103,7 @@ with older versions of rsync, but that also turns on the output of other
</ins><span class="cx">  verbose messages).
</span><span class="cx">  
</span><span class="cx">  The &quot;%i&quot; escape has a cryptic output that is 11 letters long.  The general
</span><span class="lines">@@ -861,7 +790,7 @@
</span><span class="cx">  type of update being done, bf(X) is replaced by the file-type, and the
</span><span class="cx">  other letters represent attributes that may be output if they are being
</span><span class="cx">  modified.
</span><del>-@@ -1838,7 +1867,7 @@ quote(itemization(
</del><ins>+@@ -2130,7 +2159,7 @@ quote(itemization(
</ins><span class="cx">    sender's value (requires bf(--owner) and super-user privileges).
</span><span class="cx">    it() A bf(g) means the group is different and is being updated to the
</span><span class="cx">    sender's value (requires bf(--group) and the authority to set the group).
</span><span class="lines">@@ -873,97 +802,40 @@
</span><span class="cx"> diff --git a/syscall.c b/syscall.c
</span><span class="cx"> --- a/syscall.c
</span><span class="cx"> +++ b/syscall.c
</span><del>-@@ -33,6 +33,7 @@ extern int dry_run;
- extern int am_root;
</del><ins>+@@ -38,6 +38,7 @@ extern int am_root;
+ extern int am_sender;
</ins><span class="cx">  extern int read_only;
</span><span class="cx">  extern int list_only;
</span><span class="cx"> +extern int force_change;
</span><span class="cx">  extern int preserve_perms;
</span><span class="cx">  extern int preserve_executability;
</span><span class="cx">  
</span><del>-@@ -50,14 +51,56 @@ int do_unlink(const char *fname)
</del><ins>+@@ -55,7 +56,23 @@ int do_unlink(const char *fname)
</ins><span class="cx">  {
</span><span class="cx">          if (dry_run) return 0;
</span><span class="cx">          RETURN_ERROR_IF_RO_OR_LO;
</span><span class="cx"> -        return unlink(fname);
</span><span class="cx"> +        if (unlink(fname) == 0)
</span><span class="cx"> +                return 0;
</span><del>-+
</del><span class="cx"> +#ifdef SUPPORT_FORCE_CHANGE
</span><del>-+        if (force_change &amp;&amp; (errno == EPERM || errno == EACCES)) {
-+                char parent[MAXPATHLEN];
-+                int parent_flags;
-+                int saved_errno = errno;
-+                int file_flags = make_mutable(fname, NULL, NO_FFLAGS, force_change);
-+                if (file_flags &amp;&amp; unlink(fname) == 0)
-+                        return 0;
-+                parent_flags = make_parentdir_mutable(fname, force_change, parent, sizeof parent);
-+                if (parent_flags) {
-+                        int ret = unlink(fname);
-+                        undo_make_mutable(parent, parent_flags);
-+                        if (ret == 0)
-+                                return 0;
-+                }
-+                if (file_flags)
-+                        undo_make_mutable(fname, file_flags);
-+                errno = saved_errno;
-+        }
-+#endif
</del><ins>++        if (force_change &amp;&amp; errno == EPERM) {
++                STRUCT_STAT st;
</ins><span class="cx"> +
</span><del>-+        return -1;
- }

- int do_symlink(const char *fname1, const char *fname2)
- {
-         if (dry_run) return 0;
-         RETURN_ERROR_IF_RO_OR_LO;
--        return symlink(fname1, fname2);
-+        if (symlink(fname1, fname2) == 0)
-+                return 0;
-+
-+#ifdef SUPPORT_FORCE_CHANGE
-+        if (force_change &amp;&amp; (errno == EPERM || errno == EACCES)) {
-+                char parent[MAXPATHLEN];
-+                int saved_errno = errno;
-+                int parent_flags = make_parentdir_mutable(fname2, force_change, parent, sizeof parent);
-+                if (parent_flags) {
-+                        int ret = symlink(fname1, fname2);
-+                        undo_make_mutable(parent, parent_flags);
-+                        if (ret == 0)
</del><ins>++                if (x_lstat(fname, &amp;st, NULL) == 0
++                 &amp;&amp; make_mutable(fname, st.st_mode, st.st_flags, force_change) &gt; 0) {
++                        if (unlink(fname) == 0)
</ins><span class="cx"> +                                return 0;
</span><ins>++                        undo_make_mutable(fname, st.st_flags);
</ins><span class="cx"> +                }
</span><del>-+                errno = saved_errno;
</del><ins>++                /* TODO: handle immutable directories */
++                errno = EPERM;
</ins><span class="cx"> +        }
</span><span class="cx"> +#endif
</span><del>-+
</del><span class="cx"> +        return -1;
</span><span class="cx">  }
</span><span class="cx">  
</span><del>- #ifdef HAVE_LINK
-@@ -65,18 +108,55 @@ int do_link(const char *fname1, const char *fname2)
- {
-         if (dry_run) return 0;
-         RETURN_ERROR_IF_RO_OR_LO;
--        return link(fname1, fname2);
-+        if (link(fname1, fname2) == 0)
-+                return 0;
-+
-+#ifdef SUPPORT_FORCE_CHANGE
-+        if (force_change &amp;&amp; (errno == EPERM || errno == EACCES)) {
-+                char parent[MAXPATHLEN];
-+                int saved_errno = errno;
-+                int parent_flags = make_parentdir_mutable(fname2, force_change, parent, sizeof parent);
-+                if (parent_flags) {
-+                        int ret = link(fname1, fname2);
-+                        undo_make_mutable(parent, parent_flags);
-+                        if (ret == 0)
-+                                return 0;
-+                }
-+                errno = saved_errno;
-+        }
-+#endif
-+
-+        return -1;
</del><ins>+ #ifdef SUPPORT_LINKS
+@@ -116,14 +133,37 @@ int do_link(const char *fname1, const char *fname2)
</ins><span class="cx">  }
</span><span class="cx">  #endif
</span><span class="cx">  
</span><span class="lines">@@ -978,28 +850,32 @@
</span><span class="cx"> -        return lchown(path, owner, group);
</span><span class="cx"> +        if (lchown(path, owner, group) == 0)
</span><span class="cx"> +                return 0;
</span><del>-+
</del><span class="cx"> +#ifdef SUPPORT_FORCE_CHANGE
</span><del>-+        if (force_change &amp;&amp; (errno == EPERM || errno == EACCES)) {
-+                int saved_errno = errno;
-+                fileflags = make_mutable(path, &amp;mode, fileflags, force_change);
-+                if (fileflags) {
</del><ins>++        if (force_change &amp;&amp; errno == EPERM) {
++                if (fileflags == NO_FFLAGS) {
++                        STRUCT_STAT st;
++                        if (x_lstat(path, &amp;st, NULL) == 0) {
++                                mode = st.st_mode;
++                                fileflags = st.st_flags;
++                        }
++                }
++                if (fileflags != NO_FFLAGS
++                 &amp;&amp; make_mutable(path, mode, fileflags, force_change) &gt; 0) {
</ins><span class="cx"> +                        int ret = lchown(path, owner, group);
</span><span class="cx"> +                        undo_make_mutable(path, fileflags);
</span><span class="cx"> +                        if (ret == 0)
</span><span class="cx"> +                                return 0;
</span><span class="cx"> +                }
</span><del>-+                errno = saved_errno;
</del><ins>++                errno = EPERM;
</ins><span class="cx"> +        }
</span><span class="cx"> +#else
</span><span class="cx"> +        mode = fileflags = 0; /* avoid compiler warning */
</span><span class="cx"> +#endif
</span><del>-+
</del><span class="cx"> +        return -1;
</span><span class="cx">  }
</span><span class="cx">  
</span><span class="cx">  int do_mknod(const char *pathname, mode_t mode, dev_t dev)
</span><del>-@@ -116,7 +196,7 @@ int do_mknod(const char *pathname, mode_t mode, dev_t dev)
</del><ins>+@@ -163,7 +203,7 @@ int do_mknod(const char *pathname, mode_t mode, dev_t dev)
</ins><span class="cx">                          return -1;
</span><span class="cx">                  close(sock);
</span><span class="cx">  #ifdef HAVE_CHMOD
</span><span class="lines">@@ -1008,65 +884,31 @@
</span><span class="cx">  #else
</span><span class="cx">                  return 0;
</span><span class="cx">  #endif
</span><del>-@@ -133,21 +213,63 @@ int do_rmdir(const char *pathname)
</del><ins>+@@ -180,7 +220,22 @@ int do_rmdir(const char *pathname)
</ins><span class="cx">  {
</span><span class="cx">          if (dry_run) return 0;
</span><span class="cx">          RETURN_ERROR_IF_RO_OR_LO;
</span><span class="cx"> -        return rmdir(pathname);
</span><span class="cx"> +        if (rmdir(pathname) == 0)
</span><span class="cx"> +                return 0;
</span><del>-+
</del><span class="cx"> +#ifdef SUPPORT_FORCE_CHANGE
</span><del>-+        if (force_change &amp;&amp; (errno == EPERM || errno == EACCES)) {
-+                char parent[MAXPATHLEN];
-+                int parent_flags;
-+                int saved_errno = errno;
-+                int file_flags = make_mutable(pathname, NULL, NO_FFLAGS, force_change);
-+                if (file_flags &amp;&amp; rmdir(pathname) == 0)
-+                        return 0;
-+                parent_flags = make_parentdir_mutable(pathname, force_change, parent, sizeof parent);
-+                if (parent_flags) {
-+                        int ret = rmdir(pathname);
-+                        undo_make_mutable(parent, parent_flags);
-+                        if (ret == 0)
</del><ins>++        if (force_change &amp;&amp; errno == EPERM) {
++                STRUCT_STAT st;
++
++                if (x_lstat(pathname, &amp;st, NULL) == 0
++                 &amp;&amp; make_mutable(pathname, st.st_mode, st.st_flags, force_change) &gt; 0) {
++                        if (rmdir(pathname) == 0)
</ins><span class="cx"> +                                return 0;
</span><ins>++                        undo_make_mutable(pathname, st.st_flags);
</ins><span class="cx"> +                }
</span><del>-+                if (file_flags)
-+                        undo_make_mutable(pathname, file_flags);
-+                errno = saved_errno;
</del><ins>++                errno = EPERM;
</ins><span class="cx"> +        }
</span><span class="cx"> +#endif
</span><del>-+
</del><span class="cx"> +        return -1;
</span><span class="cx">  }
</span><span class="cx">  
</span><span class="cx">  int do_open(const char *pathname, int flags, mode_t mode)
</span><del>- {
-+        int fd;
-         if (flags != O_RDONLY) {
-                 RETURN_ERROR_IF(dry_run, 0);
-                 RETURN_ERROR_IF_RO_OR_LO;
-         }
-+        if ((fd = open(pathname, flags | O_BINARY, mode)) &gt;= 0)
-+                return fd;
-+
-+#ifdef SUPPORT_FORCE_CHANGE
-+        if (force_change &amp;&amp; (errno == EPERM || errno == EACCES)) {
-+                char parent[MAXPATHLEN];
-+                int saved_errno = errno;
-+                int parent_flags = make_parentdir_mutable(pathname, force_change, parent, sizeof parent);
-+                if (parent_flags) {
-+                        fd = open(pathname, flags | O_BINARY, mode);
-+                        undo_make_mutable(parent, parent_flags);
-+                        if (fd &gt;= 0)
-+                                return fd;
-+                }
-+                errno = saved_errno;
-+        }
-+#endif

--        return open(pathname, flags | O_BINARY, mode);
-+        return -1;
</del><ins>+@@ -194,7 +249,7 @@ int do_open(const char *pathname, int flags, mode_t mode)
</ins><span class="cx">  }
</span><span class="cx">  
</span><span class="cx">  #ifdef HAVE_CHMOD
</span><span class="lines">@@ -1075,25 +917,25 @@
</span><span class="cx">  {
</span><span class="cx">          int code;
</span><span class="cx">          if (dry_run) return 0;
</span><del>-@@ -170,17 +292,93 @@ int do_chmod(const char *path, mode_t mode)
</del><ins>+@@ -217,17 +272,74 @@ int do_chmod(const char *path, mode_t mode)
</ins><span class="cx">          } else
</span><span class="cx">                  code = chmod(path, mode &amp; CHMOD_BITS); /* DISCOURAGED FUNCTION */
</span><span class="cx">  #endif /* !HAVE_LCHMOD */
</span><span class="cx"> +#ifdef SUPPORT_FORCE_CHANGE
</span><del>-+        if (code &lt; 0 &amp;&amp; force_change &amp;&amp; (errno == EPERM || errno == EACCES) &amp;&amp; !S_ISLNK(mode)) {
-+                int saved_errno = errno;
-+                fileflags = make_mutable(path, &amp;mode, fileflags, force_change);
-+                if (fileflags) {
-+#ifdef HAVE_LCHMOD
-+                        code = lchmod(path, mode &amp; CHMOD_BITS);
-+#else
</del><ins>++        if (code &lt; 0 &amp;&amp; force_change &amp;&amp; errno == EPERM &amp;&amp; !S_ISLNK(mode)) {
++                if (fileflags == NO_FFLAGS) {
++                        STRUCT_STAT st;
++                        if (x_lstat(path, &amp;st, NULL) == 0)
++                                fileflags = st.st_flags;
++                }
++                if (fileflags != NO_FFLAGS
++                 &amp;&amp; make_mutable(path, mode, fileflags, force_change) &gt; 0) {
</ins><span class="cx"> +                        code = chmod(path, mode &amp; CHMOD_BITS);
</span><del>-+#endif
</del><span class="cx"> +                        undo_make_mutable(path, fileflags);
</span><span class="cx"> +                        if (code == 0)
</span><span class="cx"> +                                return 0;
</span><span class="cx"> +                }
</span><del>-+                errno = saved_errno;
</del><ins>++                errno = EPERM;
</ins><span class="cx"> +        }
</span><span class="cx"> +#else
</span><span class="cx"> +        fileflags = 0; /* avoid compiler warning */
</span><span class="lines">@@ -1120,268 +962,64 @@
</span><span class="cx"> -        return rename(fname1, fname2);
</span><span class="cx"> +        if (rename(fname1, fname2) == 0)
</span><span class="cx"> +                return 0;
</span><del>-+
</del><span class="cx"> +#ifdef SUPPORT_FORCE_CHANGE
</span><del>-+        if (force_change &amp;&amp; (errno == EPERM || errno == EACCES)) {
-+                int saved_errno = errno;
-+                int ret = -1, file2_flags = 0;
-+                int file1_flags = make_mutable(fname1, NULL, NO_FFLAGS, force_change);
-+                if (file1_flags &amp;&amp; rename(fname1, fname2) == 0)
-+                        ret = 0;
-+                else {
-+                        file2_flags = make_mutable(fname2, NULL, NO_FFLAGS, force_change);
-+                        if (file2_flags &amp;&amp; rename(fname1, fname2) == 0)
-+                                ret = 0;
-+                        else {
-+                                char parent1[MAXPATHLEN];
-+                                int parent1_flags = make_parentdir_mutable(fname1, force_change,
-+                                                        parent1, sizeof parent1);
-+                                if (parent1_flags &amp;&amp; rename(fname1, fname2) == 0)
-+                                        ret = 0;
-+                                else {
-+                                        char parent2[MAXPATHLEN];
-+                                        int parent2_flags = make_parentdir_mutable(fname2, force_change,
-+                                                                parent2, sizeof parent2);
-+                                        if (parent2_flags) {
-+                                                if (rename(fname1, fname2) == 0)
-+                                                        ret = 0;
-+                                                undo_make_mutable(parent2, parent2_flags);
-+                                        }
-+                                }
-+                                if (parent1_flags)
-+                                        undo_make_mutable(parent1, parent1_flags);
-+                        }
-+                }
</del><ins>++        if (force_change &amp;&amp; errno == EPERM) {
++                STRUCT_STAT st1, st2;
++                int became_mutable;
</ins><span class="cx"> +
</span><del>-+                if (ret == 0)
-+                        file2_flags = file1_flags; /* file1 is now file2 */
-+                else if (file1_flags)
-+                        undo_make_mutable(fname1, file1_flags);
-+                if (file2_flags)
-+                        undo_make_mutable(fname2, file2_flags);
-+                if (ret == 0)
-+                        return 0;
-+
-+                errno = saved_errno;
-+        }
-+#endif
-+
-+        return -1;
- }

- #ifdef HAVE_FTRUNCATE
-@@ -222,7 +420,25 @@ int do_mkdir(char *fname, mode_t mode)
-         if (dry_run) return 0;
-         RETURN_ERROR_IF_RO_OR_LO;
-         trim_trailing_slashes(fname);
--        return mkdir(fname, mode);
-+        if (mkdir(fname, mode) == 0)
-+                return 0;
-+
-+#ifdef SUPPORT_FORCE_CHANGE
-+        if (force_change &amp;&amp; (errno == EPERM || errno == EACCES)) {
-+                char parent[MAXPATHLEN];
-+                int saved_errno = errno;
-+                int parent_flags = make_parentdir_mutable(fname, force_change, parent, sizeof parent);
-+                if (parent_flags) {
-+                        int ret = mkdir(fname, mode);
-+                        undo_make_mutable(parent, parent_flags);
-+                        if (ret == 0)
</del><ins>++                if (x_lstat(fname1, &amp;st1, NULL) != 0)
++                        goto failed;
++                became_mutable = make_mutable(fname1, st1.st_mode, st1.st_flags, force_change) &gt; 0;
++                if (became_mutable &amp;&amp; rename(fname1, fname2) == 0)
++                        goto success;
++                if (x_lstat(fname2, &amp;st2, NULL) == 0
++                 &amp;&amp; make_mutable(fname2, st2.st_mode, st2.st_flags, force_change) &gt; 0) {
++                        if (rename(fname1, fname2) == 0) {
++                          success:
++                                if (became_mutable) /* Yes, use fname2 and st1! */
++                                        undo_make_mutable(fname2, st1.st_flags);
</ins><span class="cx"> +                                return 0;
</span><del>-+                }
-+                errno = saved_errno;
-+        }
-+#endif
-+
-+        return -1;
- }

- /* like mkstemp but forces permissions */
-@@ -235,7 +451,19 @@ int do_mkstemp(char *template, mode_t perms)
- #if defined HAVE_SECURE_MKSTEMP &amp;&amp; defined HAVE_FCHMOD &amp;&amp; (!defined HAVE_OPEN64 || defined HAVE_MKSTEMP64)
-         {
-                 int fd = mkstemp(template);
--                if (fd == -1)
-+#ifdef SUPPORT_FORCE_CHANGE
-+                if (fd &lt; 0 &amp;&amp; force_change) {
-+                        char parent[MAXPATHLEN];
-+                        int saved_errno = errno;
-+                        int parent_flags = make_parentdir_mutable(template, force_change, parent, sizeof parent);
-+                        if (parent_flags) {
-+                                fd = mkstemp(template);
-+                                undo_make_mutable(parent, parent_flags);
</del><span class="cx"> +                        }
</span><del>-+                        errno = saved_errno;
</del><ins>++                        undo_make_mutable(fname2, st2.st_flags);
</ins><span class="cx"> +                }
</span><del>-+#endif
-+                if (fd &lt; 0)
-                         return -1;
-                 if (fchmod(fd, perms) != 0 &amp;&amp; preserve_perms) {
-                         int errno_save = errno;
-@@ -302,7 +530,7 @@ OFF_T do_lseek(int fd, OFF_T offset, int whence)
- }

- #ifdef HAVE_UTIMENSAT
--int do_utimensat(const char *fname, time_t modtime, uint32 mod_nsec)
-+int do_utimensat(const char *fname, time_t modtime, uint32 mod_nsec, mode_t mode, uint32 fileflags)
- {
-         struct timespec t[2];

-@@ -313,12 +541,26 @@ int do_utimensat(const char *fname, time_t modtime, uint32 mod_nsec)
-         t[0].tv_nsec = UTIME_NOW;
-         t[1].tv_sec = modtime;
-         t[1].tv_nsec = mod_nsec;
--        return utimensat(AT_FDCWD, fname, t, AT_SYMLINK_NOFOLLOW);
-+        if (utimensat(AT_FDCWD, fname, t, AT_SYMLINK_NOFOLLOW) == 0)
-+                return 0;
-+
-+#ifdef SUPPORT_FORCE_CHANGE
-+        fileflags = make_mutable(fname, &amp;mode, fileflags, force_change);
-+        if (fileflags) {
-+                if (utimensat(AT_FDCWD, fname, t, AT_SYMLINK_NOFOLLOW) == 0)
-+                        return 0;
-+                undo_make_mutable(fname, fileflags);
</del><ins>++                /* TODO: handle immutable directories */
++                if (became_mutable)
++                        undo_make_mutable(fname1, st1.st_flags);
++          failed:
++                errno = EPERM;
</ins><span class="cx"> +        }
</span><del>-+#else
-+        mode = fileflags; /* avoid compiler warning */
</del><span class="cx"> +#endif
</span><del>-+
</del><span class="cx"> +        return -1;
</span><span class="cx">  }
</span><del>- #endif
</del><span class="cx">  
</span><del>- #ifdef HAVE_LUTIMES
--int do_lutimes(const char *fname, time_t modtime, uint32 mod_nsec)
-+int do_lutimes(const char *fname, time_t modtime, uint32 mod_nsec, mode_t mode, uint32 fileflags)
- {
-         struct timeval t[2];

-@@ -329,12 +571,26 @@ int do_lutimes(const char *fname, time_t modtime, uint32 mod_nsec)
-         t[0].tv_usec = 0;
-         t[1].tv_sec = modtime;
-         t[1].tv_usec = mod_nsec / 1000;
--        return lutimes(fname, t);
-+        if (lutimes(fname, t) == 0)
-+                return 0;
-+
-+#ifdef SUPPORT_FORCE_CHANGE
-+        fileflags = make_mutable(fname, &amp;mode, fileflags, force_change);
-+        if (fileflags) {
-+                if (lutimes(fname, t) == 0)
-+                        return 0;
-+                undo_make_mutable(fname, fileflags);
-+        }
-+#else
-+        mode = fileflags; /* avoid compiler warning */
-+#endif
-+
-+        return -1;
- }
- #endif

- #ifdef HAVE_UTIMES
--int do_utimes(const char *fname, time_t modtime, uint32 mod_nsec)
-+int do_utimes(const char *fname, time_t modtime, uint32 mod_nsec, mode_t mode, uint32 fileflags)
- {
-         struct timeval t[2];

-@@ -345,14 +601,28 @@ int do_utimes(const char *fname, time_t modtime, uint32 mod_nsec)
-         t[0].tv_usec = 0;
-         t[1].tv_sec = modtime;
-         t[1].tv_usec = mod_nsec / 1000;
--        return utimes(fname, t);
-+        if (utimes(fname, t) == 0)
-+                return 0;
-+
-+#ifdef SUPPORT_FORCE_CHANGE
-+        fileflags = make_mutable(fname, &amp;mode, fileflags, force_change);
-+        if (fileflags) {
-+                if (utimes(fname, t) == 0)
-+                        return 0;
-+                undo_make_mutable(fname, fileflags);
-+        }
-+#else
-+        mode = fileflags; /* avoid compiler warning */
-+#endif
-+
-+        return -1;
- }

- #elif defined HAVE_UTIME
--int do_utime(const char *fname, time_t modtime, UNUSED(uint32 mod_nsec))
-+int do_utime(const char *fname, time_t modtime, UNUSED(uint32 mod_nsec), mode_t mode, uint32 fileflags)
- {
- #ifdef HAVE_STRUCT_UTIMBUF
--        struct utimbuf tbuf;
-+        struct utimbuf tbuf, *t = &amp;tbuf;
- #else
-         time_t t[2];
- #endif
-@@ -360,15 +630,28 @@ int do_utime(const char *fname, time_t modtime, UNUSED(uint32 mod_nsec))
-         if (dry_run) return 0;
-         RETURN_ERROR_IF_RO_OR_LO;

--# ifdef HAVE_STRUCT_UTIMBUF
-+#ifdef HAVE_STRUCT_UTIMBUF
-         tbuf.actime = time(NULL);
-         tbuf.modtime = modtime;
--        return utime(fname, &amp;tbuf);
--# else
-+#else
-         t[0] = time(NULL);
-         t[1] = modtime;
--        return utime(fname, t);
--# endif
-+#endif
-+        if (utime(fname, t) == 0)
-+                return 0;
-+
-+#ifdef SUPPORT_FORCE_CHANGE
-+        fileflags = make_mutable(fname, &amp;mode, fileflags, force_change);
-+        if (fileflags) {
-+                if (utime(fname, t) == 0)
-+                        return 0;
-+                undo_make_mutable(fname, fileflags);
-+        }
-+#else
-+        mode = fileflags; /* avoid compiler warning */
-+#endif
-+
-+        return -1;
- }

- #else
</del><ins>+ #ifdef HAVE_FTRUNCATE
</ins><span class="cx"> diff --git a/t_stub.c b/t_stub.c
</span><span class="cx"> --- a/t_stub.c
</span><span class="cx"> +++ b/t_stub.c
</span><del>-@@ -26,6 +26,7 @@ int module_id = -1;
</del><ins>+@@ -28,6 +28,7 @@ int module_id = -1;
+ int checksum_len = 0;
</ins><span class="cx">  int relative_paths = 0;
</span><del>- int human_readable = 0;
</del><span class="cx">  int module_dirlen = 0;
</span><span class="cx"> +int force_change = 0;
</span><ins>+ int preserve_acls = 0;
</ins><span class="cx">  int preserve_times = 0;
</span><span class="cx">  int preserve_xattrs = 0;
</span><del>- mode_t orig_umask = 002;
-@@ -90,3 +91,27 @@ struct filter_list_struct daemon_filter_list;
</del><ins>+@@ -97,3 +98,23 @@ filter_rule_list daemon_filter_list;
</ins><span class="cx">  {
</span><span class="cx">          return &quot;tester&quot;;
</span><span class="cx">  }
</span><span class="cx"> +
</span><span class="cx"> +#if defined SUPPORT_FILEFLAGS || defined SUPPORT_FORCE_CHANGE
</span><del>-+ uint32 make_mutable(UNUSED(const char *fname), UNUSED(mode_t *mode), UNUSED(uint32 fileflags), UNUSED(uint32 iflags))
</del><ins>++ int make_mutable(UNUSED(const char *fname), UNUSED(mode_t mode), UNUSED(uint32 fileflags), UNUSED(uint32 iflags))
</ins><span class="cx"> +{
</span><span class="cx"> +        return 0;
</span><span class="cx"> +}
</span><span class="cx"> +
</span><ins>++/* Undo a prior make_mutable() call that returned a 1. */
</ins><span class="cx"> + int undo_make_mutable(UNUSED(const char *fname), UNUSED(uint32 fileflags))
</span><span class="cx"> +{
</span><span class="cx"> +        return 0;
</span><span class="cx"> +}
</span><del>-+
-+ int make_parentdir_mutable(UNUSED(const char *fname), UNUSED(uint32 iflags), UNUSED(char *parent_dirbuf), UNUSED(int parent_dirbuf_size))
-+{
-+        return 0;
-+}
</del><span class="cx"> +#endif
</span><span class="cx"> +
</span><span class="cx"> +#ifdef SUPPORT_XATTRS
</span><span class="lines">@@ -1393,50 +1031,94 @@
</span><span class="cx"> diff --git a/util.c b/util.c
</span><span class="cx"> --- a/util.c
</span><span class="cx"> +++ b/util.c
</span><del>-@@ -125,7 +125,7 @@ NORETURN void overflow_exit(const char *str)
</del><ins>+@@ -33,6 +33,7 @@ extern int relative_paths;
+ extern int preserve_times;
+ extern int preserve_xattrs;
+ extern int preallocate_files;
++extern int force_change;
+ extern char *module_dir;
+ extern unsigned int module_dirlen;
+ extern char *partial_dir;
+@@ -115,9 +116,36 @@ void print_child_argv(const char *prefix, char **cmd)
+         rprintf(FCLIENT, &quot; (%d args)\n&quot;, cnt);
+ }
</ins><span class="cx">  
</span><ins>++#ifdef SUPPORT_FORCE_CHANGE
++static int try_a_force_change(const char *fname, time_t modtime, uint32 mod_nsec, mode_t mode, uint32 fileflags)
++{
++        if (fileflags == NO_FFLAGS) {
++                STRUCT_STAT st;
++                if (x_lstat(fname, &amp;st, NULL) == 0)
++                        fileflags = st.st_flags;
++        }
++
++        if (fileflags != NO_FFLAGS &amp;&amp; make_mutable(fname, mode, fileflags, force_change) &gt; 0) {
++                int ret, save_force_change = force_change;
++
++                force_change = 0; /* Make certain we can't come back here. */
++                ret = set_modtime(fname, modtime, mod_nsec, mode, fileflags);
++                force_change = save_force_change;
++
++                undo_make_mutable(fname, fileflags);
++
++                return ret;
++        }
++
++        errno = EPERM;
++
++        return -1;
++}
++#endif
++
</ins><span class="cx">  /* This returns 0 for success, 1 for a symlink if symlink time-setting
</span><span class="cx">   * is not possible, or -1 for any other error. */
</span><del>--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)
</del><ins>+-int set_modtime(const char *fname, time_t modtime, uint32 mod_nsec, mode_t mode)
++int set_modtime(const char *fname, time_t modtime, uint32 mod_nsec, mode_t mode, uint32 fileflags)
</ins><span class="cx">  {
</span><span class="cx">          static int switch_step = 0;
</span><span class="cx">  
</span><del>-@@ -138,7 +138,7 @@ int set_modtime(const char *fname, time_t modtime, mode_t mode)
-         switch (switch_step) {
- #ifdef HAVE_UTIMENSAT
</del><ins>+@@ -132,6 +160,11 @@ int set_modtime(const char *fname, time_t modtime, uint32 mod_nsec, mode_t mode)
</ins><span class="cx">  #include &quot;case_N.h&quot;
</span><del>--                if (do_utimensat(fname, modtime, 0) == 0)
-+                if (do_utimensat(fname, modtime, 0, mode, fileflags) == 0)
</del><ins>+                 if (do_utimensat(fname, modtime, mod_nsec) == 0)
</ins><span class="cx">                          break;
</span><ins>++#ifdef SUPPORT_FORCE_CHANGE
++                if (force_change &amp;&amp; errno == EPERM
++                 &amp;&amp; try_a_force_change(fname, modtime, mod_nsec, mode, fileflags) == 0)
++                        break;
++#endif
</ins><span class="cx">                  if (errno != ENOSYS)
</span><span class="cx">                          return -1;
</span><del>-@@ -148,7 +148,7 @@ int set_modtime(const char *fname, time_t modtime, mode_t mode)

- #ifdef HAVE_LUTIMES
</del><ins>+                 switch_step++;
+@@ -142,6 +175,11 @@ int set_modtime(const char *fname, time_t modtime, uint32 mod_nsec, mode_t mode)
</ins><span class="cx">  #include &quot;case_N.h&quot;
</span><del>--                if (do_lutimes(fname, modtime, 0) == 0)
-+                if (do_lutimes(fname, modtime, 0, mode, fileflags) == 0)
</del><ins>+                 if (do_lutimes(fname, modtime, mod_nsec) == 0)
</ins><span class="cx">                          break;
</span><ins>++#ifdef SUPPORT_FORCE_CHANGE
++                if (force_change &amp;&amp; errno == EPERM
++                 &amp;&amp; try_a_force_change(fname, modtime, mod_nsec, mode, fileflags) == 0)
++                        break;
++#endif
</ins><span class="cx">                  if (errno != ENOSYS)
</span><span class="cx">                          return -1;
</span><del>-@@ -167,10 +167,10 @@ int set_modtime(const char *fname, time_t modtime, mode_t mode)

- #include &quot;case_N.h&quot;
- #ifdef HAVE_UTIMES
--                if (do_utimes(fname, modtime, 0) == 0)
-+                if (do_utimes(fname, modtime, 0, mode, fileflags) == 0)
</del><ins>+                 switch_step++;
+@@ -165,6 +203,13 @@ int set_modtime(const char *fname, time_t modtime, uint32 mod_nsec, mode_t mode)
+                 if (do_utime(fname, modtime, mod_nsec) == 0)
</ins><span class="cx">                          break;
</span><del>- #else
--                if (do_utime(fname, modtime, 0) == 0)
-+                if (do_utime(fname, modtime, 0, mode, fileflags) == 0)
-                         break;
</del><span class="cx">  #endif
</span><ins>++#ifdef SUPPORT_FORCE_CHANGE
++                if (force_change &amp;&amp; errno == EPERM
++                 &amp;&amp; try_a_force_change(fname, modtime, mod_nsec, mode, fileflags) == 0)
++                        break;
++#else
++                fileflags = 0; /* avoid compiler warning */
++#endif
</ins><span class="cx">  
</span><ins>+                 return -1;
+         }
</ins><span class="cx"> diff --git a/xattrs.c b/xattrs.c
</span><span class="cx"> --- a/xattrs.c
</span><span class="cx"> +++ b/xattrs.c
</span><del>-@@ -1042,7 +1042,7 @@ int set_stat_xattr(const char *fname, struct file_struct *file, mode_t new_mode)
</del><ins>+@@ -1045,7 +1045,7 @@ int set_stat_xattr(const char *fname, struct file_struct *file, mode_t new_mode)
</ins><span class="cx">          mode = (fst.st_mode &amp; _S_IFMT) | (fmode &amp; ACCESSPERMS)
</span><span class="cx">               | (S_ISDIR(fst.st_mode) ? 0700 : 0600);
</span><span class="cx">          if (fst.st_mode != mode)
</span><span class="lines">@@ -1445,10 +1127,10 @@
</span><span class="cx">          if (!IS_DEVICE(fst.st_mode))
</span><span class="cx">                  fst.st_rdev = 0; /* just in case */
</span><span class="cx">  
</span><del>-diff -up a/config.h.in b/config.h.in
</del><ins>+diff -Nurp a/config.h.in b/config.h.in
</ins><span class="cx"> --- a/config.h.in
</span><span class="cx"> +++ b/config.h.in
</span><del>-@@ -70,6 +70,9 @@
</del><ins>+@@ -76,6 +76,9 @@
</ins><span class="cx">  /* Define to 1 if vsprintf has a C99-compatible return value */
</span><span class="cx">  #undef HAVE_C99_VSNPRINTF
</span><span class="cx">  
</span><span class="lines">@@ -1458,10 +1140,10 @@
</span><span class="cx">  /* Define to 1 if you have the `chmod' function. */
</span><span class="cx">  #undef HAVE_CHMOD
</span><span class="cx">  
</span><del>-diff -up a/configure.sh b/configure.sh
</del><ins>+diff -Nurp a/configure.sh b/configure.sh
</ins><span class="cx"> --- a/configure.sh
</span><span class="cx"> +++ b/configure.sh
</span><del>-@@ -7444,6 +7444,7 @@ fi
</del><ins>+@@ -7652,6 +7652,7 @@ fi
</ins><span class="cx">  
</span><span class="cx">  for ac_func in waitpid wait4 getcwd strdup chown chmod lchmod mknod mkfifo \
</span><span class="cx">      fchmod fstat ftruncate strchr readlink link utime utimes lutimes strftime \
</span><span class="lines">@@ -1469,22 +1151,21 @@
</span><span class="cx">      memmove lchown vsnprintf snprintf vasprintf asprintf setsid strpbrk \
</span><span class="cx">      strlcat strlcpy strtol mallinfo getgroups setgroups geteuid getegid \
</span><span class="cx">      setlocale setmode open64 lseek64 mkstemp64 mtrace va_copy __va_copy \
</span><del>-diff -up a/proto.h b/proto.h
</del><ins>+diff -Nurp a/proto.h b/proto.h
</ins><span class="cx"> --- a/proto.h
</span><span class="cx"> +++ b/proto.h
</span><del>-@@ -274,6 +274,9 @@ int read_ndx_and_attrs(int f_in, int *if
</del><ins>+@@ -286,6 +286,8 @@ int read_ndx_and_attrs(int f_in, int f_o
</ins><span class="cx">  void free_sums(struct sum_struct *s);
</span><span class="cx">  mode_t dest_mode(mode_t flist_mode, mode_t stat_mode, int dflt_perms,
</span><span class="cx">                   int exists);
</span><del>-+uint32 make_mutable(const char *fname, mode_t *mode_ptr, uint32 fileflags, uint32 iflags);
</del><ins>++int make_mutable(const char *fname, mode_t mode, uint32 fileflags, uint32 iflags);
</ins><span class="cx"> +int undo_make_mutable(const char *fname, uint32 fileflags);
</span><del>-+int make_parentdir_mutable(const char *fname, uint32 iflags, char *parent_dirbuf, int parent_dirbuf_size);
</del><span class="cx">  int set_file_attrs(const char *fname, struct file_struct *file, stat_x *sxp,
</span><span class="cx">                     const char *fnamecmp, int flags);
</span><del>- RETSIGTYPE sig_int(UNUSED(int val));
-@@ -297,11 +300,12 @@ void set_socket_options(int fd, char *op
- int do_unlink(const char *fname);
- int do_symlink(const char *fname1, const char *fname2);
</del><ins>+ RETSIGTYPE sig_int(int sig_num);
+@@ -310,11 +312,12 @@ int do_unlink(const char *fname);
+ int do_symlink(const char *lnk, const char *fname);
+ ssize_t do_readlink(const char *path, char *buf, size_t bufsiz);
</ins><span class="cx">  int do_link(const char *fname1, const char *fname2);
</span><span class="cx"> -int do_lchown(const char *path, uid_t owner, gid_t group);
</span><span class="cx"> +int do_lchown(const char *path, uid_t owner, gid_t group, mode_t mode, uint32 fileflags);
</span><span class="lines">@@ -1497,34 +1178,19 @@
</span><span class="cx">  int do_rename(const char *fname1, const char *fname2);
</span><span class="cx">  int do_ftruncate(int fd, OFF_T size);
</span><span class="cx">  void trim_trailing_slashes(char *name);
</span><del>-@@ -311,10 +315,10 @@ 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);
--int do_utimensat(const char *fname, time_t modtime, uint32 mod_nsec);
--int do_lutimes(const char *fname, time_t modtime, uint32 mod_nsec);
--int do_utimes(const char *fname, time_t modtime, uint32 mod_nsec);
--int do_utime(const char *fname, time_t modtime, UNUSED(uint32 mod_nsec));
-+int do_utimensat(const char *fname, time_t modtime, uint32 mod_nsec, mode_t mode, uint32 fileflags);
-+int do_lutimes(const char *fname, time_t modtime, uint32 mod_nsec, mode_t mode, uint32 fileflags);
-+int do_utimes(const char *fname, time_t modtime, uint32 mod_nsec, mode_t mode, uint32 fileflags);
-+int do_utime(const char *fname, time_t modtime, UNUSED(uint32 mod_nsec), mode_t mode, uint32 fileflags);
- void set_compression(const char *fname);
- void send_token(int f, int32 token, struct map_struct *buf, OFF_T offset,
-                 int32 n, int32 toklen);
-@@ -334,7 +338,7 @@ int fd_pair(int fd[2]);
</del><ins>+@@ -353,7 +356,7 @@ void set_nonblocking(int fd);
+ void set_blocking(int fd);
+ int fd_pair(int fd[2]);
</ins><span class="cx">  void print_child_argv(const char *prefix, char **cmd);
</span><del>- 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);
</del><ins>+-int set_modtime(const char *fname, time_t modtime, uint32 mod_nsec, mode_t mode);
++int set_modtime(const char *fname, time_t modtime, uint32 mod_nsec, mode_t mode, uint32 fileflags);
+ int make_path(char *fname, int flags);
</ins><span class="cx">  int full_write(int desc, const char *ptr, size_t len);
</span><del>-diff -up a/rsync.1 b/rsync.1
</del><ins>+ int copy_file(const char *source, const char *dest, int ofd, mode_t mode);
+diff -Nurp a/rsync.1 b/rsync.1
</ins><span class="cx"> --- a/rsync.1
</span><span class="cx"> +++ b/rsync.1
</span><del>-@@ -431,6 +431,7 @@ to the detailed description below for a
</del><ins>+@@ -438,6 +438,7 @@ to the detailed description below for a
</ins><span class="cx">   \-K, \-\-keep\-dirlinks         treat symlinked dir on receiver as dir
</span><span class="cx">   \-H, \-\-hard\-links            preserve hard links
</span><span class="cx">   \-p, \-\-perms                 preserve permissions
</span><span class="lines">@@ -1532,9 +1198,9 @@
</span><span class="cx">   \-E, \-\-executability         preserve executability
</span><span class="cx">       \-\-chmod=CHMOD           affect file and/or directory permissions
</span><span class="cx">   \-A, \-\-acls                  preserve ACLs (implies \-p)
</span><del>-@@ -462,7 +463,10 @@ to the detailed description below for a
-      \-\-delete\-after          receiver deletes after transfer, not during
-      \-\-delete\-excluded       also delete excluded files from dest dirs
</del><ins>+@@ -473,7 +474,10 @@ to the detailed description below for a
+      \-\-ignore\-missing\-args   ignore missing source args without error
+      \-\-delete\-missing\-args   delete missing source args from destination
</ins><span class="cx">       \-\-ignore\-errors         delete even if there are I/O errors
</span><span class="cx"> -     \-\-force                 force deletion of dirs even if not empty
</span><span class="cx"> +     \-\-force\-delete          force deletion of dirs even if not empty
</span><span class="lines">@@ -1544,7 +1210,7 @@
</span><span class="cx">       \-\-max\-delete=NUM        don'\&amp;t delete more than NUM files
</span><span class="cx">       \-\-max\-size=SIZE         don'\&amp;t transfer any file larger than SIZE
</span><span class="cx">       \-\-min\-size=SIZE         don'\&amp;t transfer any file smaller than SIZE
</span><del>-@@ -658,7 +662,8 @@ specified, in which case \fB\-r\fP is no
</del><ins>+@@ -743,7 +747,8 @@ specified, in which case \fB\-r\fP is no
</ins><span class="cx">  .IP 
</span><span class="cx">  Note that \fB\-a\fP \fBdoes not preserve hardlinks\fP, because
</span><span class="cx">  finding multiply\-linked files is expensive.  You must separately
</span><span class="lines">@@ -1554,7 +1220,7 @@
</span><span class="cx">  .IP 
</span><span class="cx">  .IP &quot;\-\-no\-OPTION&quot;
</span><span class="cx">  You may turn off one or more implied options by prefixing
</span><del>-@@ -975,7 +980,7 @@ they would be using \fB\-\-copy\-links\f
</del><ins>+@@ -1080,7 +1085,7 @@ they would be using \fB\-\-copy\-links\f
</ins><span class="cx">  Without this option, if the sending side has replaced a directory with a
</span><span class="cx">  symlink to a directory, the receiving side will delete anything that is in
</span><span class="cx">  the way of the new symlink, including a directory hierarchy (as long as
</span><span class="lines">@@ -1563,7 +1229,7 @@
</span><span class="cx">  .IP 
</span><span class="cx">  See also \fB\-\-keep\-dirlinks\fP for an analogous option for the receiving
</span><span class="cx">  side.
</span><del>-@@ -1162,6 +1167,33 @@ Note that this option does not copy rsyn
</del><ins>+@@ -1267,6 +1272,33 @@ Note that this option does not copy rsyn
</ins><span class="cx">  used by \fB\-\-fake\-super\fP) unless you repeat the option (e.g. \-XX).  This
</span><span class="cx">  \(dq\&amp;copy all xattrs\(dq\&amp; mode cannot be used with \fB\-\-fake\-super\fP.
</span><span class="cx">  .IP 
</span><span class="lines">@@ -1592,12 +1258,12 @@
</span><span class="cx"> +This option causes rsync to disable system\-immutable
</span><span class="cx"> +flags on files and directories that are being updated or deleted on the
</span><span class="cx"> +receiving side.  It does not try to affect user flags.  This option overrides
</span><del>-+\fB\-\-force\-change\fP and \fB\-\-force\-schange\fP.
</del><ins>++\fB\-\-force\-change\fP and \fB\-\-force\-uchange\fP.
</ins><span class="cx"> +.IP 
</span><span class="cx">  .IP &quot;\fB\-\-chmod\fP&quot;
</span><span class="cx">  This option tells rsync to apply one or more
</span><span class="cx">  comma\-separated \(dq\&amp;chmod\(dq\&amp; modes to the permission of the files in the
</span><del>-@@ -1472,13 +1504,14 @@ See \fB\-\-delete\fP (which is implied)
</del><ins>+@@ -1633,13 +1665,14 @@ display as a \(dq\&amp;*missing\(dq\&amp; entry
</ins><span class="cx">  Tells \fB\-\-delete\fP to go ahead and delete files
</span><span class="cx">  even when there are I/O errors.
</span><span class="cx">  .IP 
</span><span class="lines">@@ -1615,7 +1281,7 @@
</span><span class="cx">  \fB\-\-recursive\fP option was also enabled.
</span><span class="cx">  .IP 
</span><span class="cx">  .IP &quot;\fB\-\-max\-delete=NUM\fP&quot;
</span><del>-@@ -2034,7 +2067,7 @@ with older versions of rsync, but that a
</del><ins>+@@ -2357,7 +2390,7 @@ with older versions of rsync, but that a
</ins><span class="cx">  verbose messages).
</span><span class="cx">  .IP 
</span><span class="cx">  The \(dq\&amp;%i\(dq\&amp; escape has a cryptic output that is 11 letters long.  The general
</span><span class="lines">@@ -1624,7 +1290,7 @@
</span><span class="cx">  type of update being done, \fBX\fP is replaced by the file\-type, and the
</span><span class="cx">  other letters represent attributes that may be output if they are being
</span><span class="cx">  modified.
</span><del>-@@ -2104,7 +2137,7 @@ sender\(cq\&amp;s value (requires \fB\-\-own
</del><ins>+@@ -2427,7 +2460,7 @@ sender\(cq\&amp;s value (requires \fB\-\-own
</ins><span class="cx">  A \fBg\fP means the group is different and is being updated to the
</span><span class="cx">  sender\(cq\&amp;s value (requires \fB\-\-group\fP and the authority to set the group).
</span><span class="cx">  .IP o 
</span></span></pre></div>
<a id="trunkdportsnetrsyncfilespatchhfscompressionoptionsdiff"></a>
<div class="modfile"><h4>Modified: trunk/dports/net/rsync/files/patch-hfs-compression-options.diff (121461 => 121462)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/dports/net/rsync/files/patch-hfs-compression-options.diff        2014-06-26 00:50:01 UTC (rev 121461)
+++ trunk/dports/net/rsync/files/patch-hfs-compression-options.diff        2014-06-26 01:16:27 UTC (rev 121462)
</span><span class="lines">@@ -1,24 +1,7 @@
</span><del>-This patch adds support for HFS+ compression status to be
-shown during options display.
-
-To use this patch, run these commands for a successful build:
-
-    patch -p1 &lt;patches/fileflags.diff
-    patch -p1 &lt;patches/crtimes.diff
-    patch -p1 &lt;patches/hfs-compression.diff
-    patch -p1 &lt;patches/hfs-compression-options.diff
-    ./prepare-source
-    ./configure
-    make
-
-TODO:
- - Should rsync try to treat the compressed data as file data and use the
-   rsync algorithm on the data transfer?
-
</del><span class="cx"> diff --git a/options.c b/options.c
</span><span class="cx"> --- a/options.c
</span><span class="cx"> +++ b/options.c
</span><del>-@@ -228,6 +228,7 @@
</del><ins>+@@ -579,6 +579,7 @@
</ins><span class="cx">          char const *iconv = &quot;no &quot;;
</span><span class="cx">          char const *ipv6 = &quot;no &quot;;
</span><span class="cx">          char const *fileflags = &quot;no &quot;;
</span><span class="lines">@@ -26,7 +9,7 @@
</span><span class="cx">          STRUCT_STAT *dumstat;
</span><span class="cx">  
</span><span class="cx">  #if SUBPROTOCOL_VERSION != 0
</span><del>-@@ -264,6 +265,9 @@
</del><ins>+@@ -618,6 +619,9 @@
</ins><span class="cx">  #ifdef SUPPORT_FILEFLAGS
</span><span class="cx">          fileflags = &quot;&quot;;
</span><span class="cx">  #endif
</span><span class="lines">@@ -36,15 +19,15 @@
</span><span class="cx">  
</span><span class="cx">          rprintf(f, &quot;%s  version %s  protocol version %d%s\n&quot;,
</span><span class="cx">                  RSYNC_NAME, RSYNC_VERSION, PROTOCOL_VERSION, subprotocol);
</span><del>-@@ -277,8 +281,10 @@
</del><ins>+@@ -631,8 +635,10 @@
</ins><span class="cx">                  (int)(sizeof (int64) * 8));
</span><span class="cx">          rprintf(f, &quot;    %ssocketpairs, %shardlinks, %ssymlinks, %sIPv6, batchfiles, %sinplace,\n&quot;,
</span><span class="cx">                  got_socketpair, hardlinks, links, ipv6, have_inplace);
</span><del>--        rprintf(f, &quot;    %sappend, %sACLs, %sxattrs, %siconv, %ssymtimes, %sfile-flags\n&quot;,
-+        rprintf(f, &quot;    %sappend, %sACLs, %sxattrs, %siconv, %ssymtimes, %sfile-flags,\n&quot;,
-                 have_inplace, acls, xattrs, iconv, symtimes, fileflags);
-+        rprintf(f, &quot;    %sHFS-compression\n&quot;,
-+                hfscomp);
</del><ins>+-        rprintf(f, &quot;    %sappend, %sACLs, %sxattrs, %siconv, %ssymtimes, %sprealloc, %sfile-flags\n&quot;,
++        rprintf(f, &quot;    %sappend, %sACLs, %sxattrs, %siconv, %ssymtimes, %sprealloc, %sfile-flags,\n&quot;,
+                 have_inplace, acls, xattrs, iconv, symtimes, prealloc, fileflags);
++         rprintf(f, &quot;    %sHFS-compression\n&quot;,
++                 hfscomp);
</ins><span class="cx">  
</span><span class="cx">  #ifdef MAINTAINER_MODE
</span><span class="cx">          rprintf(f, &quot;Panic Action: \&quot;%s\&quot;\n&quot;, get_panic_action());
</span></span></pre></div>
<a id="trunkdportsnetrsyncfilespatchhfscompressiondiff"></a>
<div class="modfile"><h4>Modified: trunk/dports/net/rsync/files/patch-hfs-compression.diff (121461 => 121462)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/dports/net/rsync/files/patch-hfs-compression.diff        2014-06-26 00:50:01 UTC (rev 121461)
+++ trunk/dports/net/rsync/files/patch-hfs-compression.diff        2014-06-26 01:16:27 UTC (rev 121462)
</span><span class="lines">@@ -18,30 +18,32 @@
</span><span class="cx">  - Should rsync try to treat the compressed data as file data and use the
</span><span class="cx">    rsync algorithm on the data transfer?
</span><span class="cx"> 
</span><del>-based-on: patch/b3.0.x/crtimes
</del><ins>+based-on: patch/master/crtimes
</ins><span class="cx"> diff --git a/flist.c b/flist.c
</span><span class="cx"> --- a/flist.c
</span><span class="cx"> +++ b/flist.c
</span><del>-@@ -1496,6 +1496,7 @@ static struct file_struct *send_file_name(int f, struct file_list *flist,
- #ifdef SUPPORT_FILEFLAGS
-                         sx.st.st_flags = preserve_fileflags ? F_FFLAGS(file) : 0;
- #endif
</del><ins>+@@ -1583,6 +1583,9 @@ static struct file_struct *send_file_name(int f, struct file_list *flist,
+ #ifdef SUPPORT_XATTRS
+                 if (preserve_xattrs) {
+                         sx.st.st_mode = file-&gt;mode;
++                        if (preserve_fileflags)
++                                sx.st.st_flags = F_FFLAGS(file);
</ins><span class="cx"> +                        sx.st.st_mtime = file-&gt;modtime; /* get_xattr needs mtime for decmpfs xattrs */
</span><del>-                         sx.xattr = NULL;
</del><span class="cx">                          if (get_xattr(fname, &amp;sx) &lt; 0) {
</span><span class="cx">                                  io_error |= IOERR_GENERAL;
</span><ins>+                                 return NULL;
</ins><span class="cx"> diff --git a/generator.c b/generator.c
</span><span class="cx"> --- a/generator.c
</span><span class="cx"> +++ b/generator.c
</span><del>-@@ -39,6 +39,7 @@ extern int keep_dirlinks;
- extern int force_change;
</del><ins>+@@ -37,6 +37,7 @@ extern int implied_dirs;
+ extern int keep_dirlinks;
</ins><span class="cx">  extern int preserve_acls;
</span><span class="cx">  extern int preserve_xattrs;
</span><span class="cx"> +extern int preserve_hfs_compression;
</span><span class="cx">  extern int preserve_links;
</span><span class="cx">  extern int preserve_devices;
</span><span class="cx">  extern int preserve_specials;
</span><del>-@@ -1888,6 +1889,14 @@ static void recv_generator(char *fname, struct file_struct *file, int ndx,
</del><ins>+@@ -1762,6 +1763,14 @@ static void recv_generator(char *fname, struct file_struct *file, int ndx,
</ins><span class="cx">                                          fname, fnamecmpbuf);
</span><span class="cx">                          }
</span><span class="cx">                          sx.st.st_size = F_LENGTH(fuzzy_file);
</span><span class="lines">@@ -55,8 +57,8 @@
</span><span class="cx"> +#endif
</span><span class="cx">                          statret = 0;
</span><span class="cx">                          fnamecmp = fnamecmpbuf;
</span><del>-                         fnamecmp_type = FNAMECMP_FUZZY;
-@@ -2072,6 +2081,18 @@ static void recv_generator(char *fname, struct file_struct *file, int ndx,
</del><ins>+                 }
+@@ -1929,6 +1938,18 @@ static void recv_generator(char *fname, struct file_struct *file, int ndx,
</ins><span class="cx">          if (read_batch)
</span><span class="cx">                  goto cleanup;
</span><span class="cx">  
</span><span class="lines">@@ -78,55 +80,49 @@
</span><span class="cx"> diff --git a/lib/sysxattrs.c b/lib/sysxattrs.c
</span><span class="cx"> --- a/lib/sysxattrs.c
</span><span class="cx"> +++ b/lib/sysxattrs.c
</span><del>-@@ -22,6 +22,17 @@
</del><ins>+@@ -22,10 +22,17 @@
</ins><span class="cx">  #include &quot;rsync.h&quot;
</span><span class="cx">  #include &quot;sysxattrs.h&quot;
</span><span class="cx">  
</span><span class="cx"> +extern int preserve_hfs_compression;
</span><span class="cx"> +
</span><del>-+#ifdef HAVE_OSX_XATTRS
</del><ins>+ #ifdef SUPPORT_XATTRS

+ #ifdef HAVE_OSX_XATTRS
</ins><span class="cx"> +#ifndef XATTR_SHOWCOMPRESSION
</span><span class="cx"> +#define XATTR_SHOWCOMPRESSION 0x0020
</span><span class="cx"> +#endif
</span><del>-+#define GETXATTR_FETCH_LIMIT (64*1024*1024)
</del><ins>+ #define GETXATTR_FETCH_LIMIT (64*1024*1024)
</ins><span class="cx"> +
</span><span class="cx"> +int xattr_options = XATTR_NOFOLLOW;
</span><del>-+#endif
-+
- #ifdef SUPPORT_XATTRS
</del><ins>+ #endif
</ins><span class="cx">  
</span><span class="cx">  #if defined HAVE_LINUX_XATTRS
</span><del>-@@ -55,7 +66,27 @@ ssize_t sys_llistxattr(const char *path, char *list, size_t size)
</del><ins>+@@ -59,7 +66,12 @@ ssize_t sys_llistxattr(const char *path, char *list, size_t size)
</ins><span class="cx">  
</span><span class="cx">  ssize_t sys_lgetxattr(const char *path, const char *name, void *value, size_t size)
</span><span class="cx">  {
</span><del>--        return getxattr(path, name, value, size, 0, XATTR_NOFOLLOW);
</del><ins>+-        ssize_t len = getxattr(path, name, value, size, 0, XATTR_NOFOLLOW);
</ins><span class="cx"> +        ssize_t len;
</span><span class="cx"> +
</span><span class="cx"> +        if (preserve_hfs_compression)
</span><span class="cx"> +                xattr_options |= XATTR_SHOWCOMPRESSION;
</span><span class="cx"> +
</span><span class="cx"> +        len = getxattr(path, name, value, size, 0, xattr_options);
</span><del>-+
-+        /* If we're retrieving data, handle resource forks &gt; 64MB specially */
-+        if (value != NULL &amp;&amp; strcmp(name, XATTR_RESOURCEFORK_NAME) == 0 &amp;&amp; len == GETXATTR_FETCH_LIMIT) {
-+                /* getxattr will only return 64MB of data at a time, need to call again with a new offset */
-+                u_int32_t offset = GETXATTR_FETCH_LIMIT;
-+                ssize_t data_retrieved = len;
-+                while (data_retrieved &lt; (ssize_t)size) {
</del><ins>+ 
+         /* If we're retrieving data, handle resource forks &gt; 64MB specially */
+         if (value != NULL &amp;&amp; len == GETXATTR_FETCH_LIMIT &amp;&amp; (size_t)len &lt; size) {
+@@ -67,7 +79,7 @@ ssize_t sys_lgetxattr(const char *path, const char *name, void *value, size_t si
+                 u_int32_t offset = len;
+                 size_t data_retrieved = len;
+                 while (data_retrieved &lt; size) {
+-                        len = getxattr(path, name, value + offset, size - data_retrieved, offset, XATTR_NOFOLLOW);
</ins><span class="cx"> +                        len = getxattr(path, name, value + offset, size - data_retrieved, offset, xattr_options);
</span><del>-+                        data_retrieved += len;
-+                        offset += (u_int32_t)len;
-+                }
-+                len = data_retrieved;
-+        }
-+
-+        return len;
- }
</del><ins>+                         if (len &lt;= 0)
+                                 break;
+                         data_retrieved += len;
+@@ -91,12 +103,16 @@ int sys_lsetxattr(const char *path, const char *name, const void *value, size_t
</ins><span class="cx">  
</span><del>- ssize_t sys_fgetxattr(int filedes, const char *name, void *value, size_t size)
-@@ -70,12 +101,16 @@ int sys_lsetxattr(const char *path, const char *name, const void *value, size_t

</del><span class="cx">  int sys_lremovexattr(const char *path, const char *name)
</span><span class="cx">  {
</span><span class="cx"> -        return removexattr(path, name, XATTR_NOFOLLOW);
</span><span class="lines">@@ -156,19 +152,25 @@
</span><span class="cx"> +#include &lt;sys/mount.h&gt; /* For statfs() */
</span><span class="cx"> +#endif
</span><span class="cx">  
</span><del>- extern int verbose;
</del><span class="cx">  extern int dry_run;
</span><del>-@@ -50,7 +54,9 @@ extern int copy_dirlinks;
</del><ins>+ extern int list_only;
+@@ -53,6 +57,7 @@ extern int copy_dirlinks;
</ins><span class="cx">  extern int copy_unsafe_links;
</span><span class="cx">  extern int keep_dirlinks;
</span><span class="cx">  extern int preserve_hard_links;
</span><span class="cx"> +extern int preserve_hfs_compression;
</span><span class="cx">  extern int protocol_version;
</span><del>-+extern int force_change;
</del><ins>+ extern int force_change;
</ins><span class="cx">  extern int file_total;
</span><del>- extern int recurse;
- extern int xfer_dirs;
-@@ -490,6 +496,43 @@ static pid_t do_cmd(char *cmd, char *machine, char *user, char **remote_argv, in
</del><ins>+@@ -107,6 +112,7 @@ int daemon_over_rsh = 0;
+ mode_t orig_umask = 0;
+ int batch_gen_fd = -1;
+ int sender_keeps_checksum = 0;
++int fs_supports_hfs_compression = 0;

+ /* There's probably never more than at most 2 outstanding child processes,
+  * but set it higher, just in case. */
+@@ -559,6 +565,43 @@ static pid_t do_cmd(char *cmd, char *machine, char *user, char **remote_argv, in
</ins><span class="cx">          return 0; /* not reached */
</span><span class="cx">  }
</span><span class="cx">  
</span><span class="lines">@@ -212,7 +214,7 @@
</span><span class="cx">  /* The receiving side operates in one of two modes:
</span><span class="cx">   *
</span><span class="cx">   * 1. it receives any number of files into a destination directory,
</span><del>-@@ -548,6 +591,9 @@ static char *get_local_name(struct file_list *flist, char *dest_path)
</del><ins>+@@ -617,6 +660,9 @@ static char *get_local_name(struct file_list *flist, char *dest_path)
</ins><span class="cx">                                  exit_cleanup(RERR_FILESELECT);
</span><span class="cx">                          }
</span><span class="cx">                          filesystem_dev = st.st_dev; /* ensures --force works right w/-x */
</span><span class="lines">@@ -222,7 +224,7 @@
</span><span class="cx">                          return NULL;
</span><span class="cx">                  }
</span><span class="cx">                  if (file_total &gt; 1) {
</span><del>-@@ -608,7 +654,9 @@ static char *get_local_name(struct file_list *flist, char *dest_path)
</del><ins>+@@ -677,7 +723,9 @@ static char *get_local_name(struct file_list *flist, char *dest_path)
</ins><span class="cx">                                  full_fname(dest_path));
</span><span class="cx">                          exit_cleanup(RERR_FILESELECT);
</span><span class="cx">                  }
</span><span class="lines">@@ -233,7 +235,7 @@
</span><span class="cx">                  return NULL;
</span><span class="cx">          }
</span><span class="cx">  
</span><del>-@@ -628,6 +676,9 @@ static char *get_local_name(struct file_list *flist, char *dest_path)
</del><ins>+@@ -697,6 +745,9 @@ static char *get_local_name(struct file_list *flist, char *dest_path)
</ins><span class="cx">                          full_fname(dest_path));
</span><span class="cx">                  exit_cleanup(RERR_FILESELECT);
</span><span class="cx">          }
</span><span class="lines">@@ -243,18 +245,10 @@
</span><span class="cx">          *cp = '/';
</span><span class="cx">  
</span><span class="cx">          return cp + 1;
</span><del>-@@ -981,7 +1032,6 @@ int child_main(int argc, char *argv[])
-         return 0;
- }

--
- void start_server(int f_in, int f_out, int argc, char *argv[])
- {
-         set_nonblocking(f_in);
</del><span class="cx"> diff --git a/options.c b/options.c
</span><span class="cx"> --- a/options.c
</span><span class="cx"> +++ b/options.c
</span><del>-@@ -52,6 +52,7 @@ int preserve_links = 0;
</del><ins>+@@ -54,6 +54,7 @@ int preserve_links = 0;
</ins><span class="cx">  int preserve_hard_links = 0;
</span><span class="cx">  int preserve_acls = 0;
</span><span class="cx">  int preserve_xattrs = 0;
</span><span class="lines">@@ -262,7 +256,7 @@
</span><span class="cx">  int preserve_perms = 0;
</span><span class="cx">  int preserve_fileflags = 0;
</span><span class="cx">  int preserve_executability = 0;
</span><del>-@@ -355,6 +356,10 @@ void usage(enum logcode F)
</del><ins>+@@ -713,6 +714,10 @@ void usage(enum logcode F)
</ins><span class="cx">  #ifdef SUPPORT_XATTRS
</span><span class="cx">    rprintf(F,&quot; -X, --xattrs                preserve extended attributes\n&quot;);
</span><span class="cx">  #endif
</span><span class="lines">@@ -273,7 +267,7 @@
</span><span class="cx">    rprintf(F,&quot; -o, --owner                 preserve owner (super-user only)\n&quot;);
</span><span class="cx">    rprintf(F,&quot; -g, --group                 preserve group\n&quot;);
</span><span class="cx">    rprintf(F,&quot;     --devices               preserve device files (super-user only)\n&quot;);
</span><del>-@@ -588,6 +593,12 @@ static struct poptOption long_options[] = {
</del><ins>+@@ -974,6 +979,12 @@ static struct poptOption long_options[] = {
</ins><span class="cx">    {&quot;force-uchange&quot;,    0,  POPT_ARG_VAL,    &amp;force_change, USR_IMMUTABLE, 0, 0 },
</span><span class="cx">    {&quot;force-schange&quot;,    0,  POPT_ARG_VAL,    &amp;force_change, SYS_IMMUTABLE, 0, 0 },
</span><span class="cx">  #endif
</span><span class="lines">@@ -286,7 +280,7 @@
</span><span class="cx">    {&quot;ignore-errors&quot;,    0,  POPT_ARG_VAL,    &amp;ignore_errors, 1, 0, 0 },
</span><span class="cx">    {&quot;no-ignore-errors&quot;, 0,  POPT_ARG_VAL,    &amp;ignore_errors, 0, 0, 0 },
</span><span class="cx">    {&quot;max-delete&quot;,       0,  POPT_ARG_INT,    &amp;max_delete, 0, 0, 0 },
</span><del>-@@ -1362,6 +1373,15 @@ int parse_arguments(int *argc_p, const char ***argv_p)
</del><ins>+@@ -1974,6 +1985,15 @@ int parse_arguments(int *argc_p, const char ***argv_p)
</ins><span class="cx">          }
</span><span class="cx">  #endif
</span><span class="cx">  
</span><span class="lines">@@ -299,10 +293,10 @@
</span><span class="cx"> +        }
</span><span class="cx"> +#endif
</span><span class="cx"> +
</span><del>-         if (write_batch &amp;&amp; read_batch) {
</del><ins>+         if (block_size &gt; MAX_BLOCK_SIZE) {
</ins><span class="cx">                  snprintf(err_buf, sizeof err_buf,
</span><del>-                         &quot;--write-batch and --read-batch can not be used together\n&quot;);
-@@ -1915,6 +1935,11 @@ void server_options(char **args, int *argc_p)
</del><ins>+                          &quot;--block-size=%lu is too large (max: %u)\n&quot;, block_size, MAX_BLOCK_SIZE);
+@@ -2573,6 +2593,11 @@ void server_options(char **args, int *argc_p)
</ins><span class="cx">          if (preserve_fileflags)
</span><span class="cx">                  args[ac++] = &quot;--fileflags&quot;;
</span><span class="cx">  
</span><span class="lines">@@ -317,7 +311,7 @@
</span><span class="cx"> diff --git a/rsync.c b/rsync.c
</span><span class="cx"> --- a/rsync.c
</span><span class="cx"> +++ b/rsync.c
</span><del>-@@ -498,8 +498,14 @@ int set_file_attrs(const char *fname, struct file_struct *file, stat_x *sxp,
</del><ins>+@@ -573,8 +573,14 @@ int set_file_attrs(const char *fname, struct file_struct *file, stat_x *sxp,
</ins><span class="cx">  #ifdef SUPPORT_XATTRS
</span><span class="cx">          if (am_root &lt; 0)
</span><span class="cx">                  set_stat_xattr(fname, file, new_mode);
</span><span class="lines">@@ -333,7 +327,7 @@
</span><span class="cx">  #endif
</span><span class="cx">  
</span><span class="cx">          if (!preserve_times
</span><del>-@@ -510,6 +516,9 @@ int set_file_attrs(const char *fname, struct file_struct *file, stat_x *sxp,
</del><ins>+@@ -585,6 +591,9 @@ int set_file_attrs(const char *fname, struct file_struct *file, stat_x *sxp,
</ins><span class="cx">          if (sxp-&gt;st.st_ino == 2 &amp;&amp; S_ISDIR(sxp-&gt;st.st_mode))
</span><span class="cx">                  flags |= ATTRS_SKIP_CRTIME;
</span><span class="cx">          if (!(flags &amp; ATTRS_SKIP_MTIME)
</span><span class="lines">@@ -341,14 +335,14 @@
</span><span class="cx"> +            &amp;&amp; !(sxp-&gt;st.st_flags &amp; UF_COMPRESSED) /* setting this alters mtime, so defer to after set_fileflags */
</span><span class="cx"> +#endif
</span><span class="cx">              &amp;&amp; cmp_time(sxp-&gt;st.st_mtime, file-&gt;modtime) != 0) {
</span><del>-                 int ret = set_modtime(fname, file-&gt;modtime, sxp-&gt;st.st_mode, ST_FLAGS(sxp-&gt;st));
</del><ins>+                 int ret = set_modtime(fname, file-&gt;modtime, F_MOD_NSEC(file), sxp-&gt;st.st_mode, ST_FLAGS(sxp-&gt;st));
</ins><span class="cx">                  if (ret &lt; 0) {
</span><del>-@@ -620,6 +629,16 @@ int set_file_attrs(const char *fname, struct file_struct *file, stat_x *sxp,
</del><ins>+@@ -643,6 +652,16 @@ int set_file_attrs(const char *fname, struct file_struct *file, stat_x *sxp,
</ins><span class="cx">                   &amp;&amp; !set_fileflags(fname, fileflags))
</span><span class="cx">                          goto cleanup;
</span><span class="cx">                  updated = 1;
</span><span class="cx"> +#ifdef SUPPORT_HFS_COMPRESSION
</span><del>-+                int ret = set_modtime(fname, file-&gt;modtime, new_mode, fileflags);
</del><ins>++                int ret = set_modtime(fname, file-&gt;modtime, F_MOD_NSEC(file), new_mode, fileflags);
</ins><span class="cx"> +                if (ret &lt; 0) {
</span><span class="cx"> +                        rsyserr(FERROR_XFER, errno, &quot;failed to set times on %s&quot;,
</span><span class="cx"> +                                full_fname(fname));
</span><span class="lines">@@ -363,7 +357,7 @@
</span><span class="cx"> diff --git a/rsync.h b/rsync.h
</span><span class="cx"> --- a/rsync.h
</span><span class="cx"> +++ b/rsync.h
</span><del>-@@ -509,6 +509,17 @@ typedef unsigned int size_t;
</del><ins>+@@ -549,6 +549,17 @@ typedef unsigned int size_t;
</ins><span class="cx">  #define ST_FLAGS(st) NO_FFLAGS
</span><span class="cx">  #endif
</span><span class="cx">  
</span><span class="lines">@@ -384,7 +378,7 @@
</span><span class="cx"> diff --git a/rsync.yo b/rsync.yo
</span><span class="cx"> --- a/rsync.yo
</span><span class="cx"> +++ b/rsync.yo
</span><del>-@@ -360,6 +360,8 @@ to the detailed description below for a complete description.  verb(
</del><ins>+@@ -367,6 +367,8 @@ to the detailed description below for a complete description.  verb(
</ins><span class="cx">       --chmod=CHMOD           affect file and/or directory permissions
</span><span class="cx">   -A, --acls                  preserve ACLs (implies -p)
</span><span class="cx">   -X, --xattrs                preserve extended attributes
</span><span class="lines">@@ -393,9 +387,9 @@
</span><span class="cx">   -o, --owner                 preserve owner (super-user only)
</span><span class="cx">   -g, --group                 preserve group
</span><span class="cx">       --devices               preserve device files (super-user only)
</span><del>-@@ -1038,6 +1040,42 @@ flags on files and directories that are being updated or deleted on the
</del><ins>+@@ -1135,6 +1137,42 @@ flags on files and directories that are being updated or deleted on the
</ins><span class="cx">  receiving side.  It does not try to affect user flags.  This option overrides
</span><del>- bf(--force-change) and bf(--force-schange).
</del><ins>+ bf(--force-change) and bf(--force-uchange).
</ins><span class="cx">  
</span><span class="cx"> +dit(bf(--hfs-compression)) This option causes rsync to preserve HFS+
</span><span class="cx"> +compression if the destination filesystem supports it.  If the destination
</span><span class="lines">@@ -439,18 +433,18 @@
</span><span class="cx"> diff --git a/t_stub.c b/t_stub.c
</span><span class="cx"> --- a/t_stub.c
</span><span class="cx"> +++ b/t_stub.c
</span><del>-@@ -29,6 +29,7 @@ int module_dirlen = 0;
- int force_change = 0;
</del><ins>+@@ -32,6 +32,7 @@ int force_change = 0;
+ int preserve_acls = 0;
</ins><span class="cx">  int preserve_times = 0;
</span><span class="cx">  int preserve_xattrs = 0;
</span><span class="cx"> +int preserve_hfs_compression = 0;
</span><del>- mode_t orig_umask = 002;
</del><span class="cx">  char *partial_dir;
</span><span class="cx">  char *module_dir;
</span><ins>+ filter_rule_list daemon_filter_list;
</ins><span class="cx"> diff --git a/xattrs.c b/xattrs.c
</span><span class="cx"> --- a/xattrs.c
</span><span class="cx"> +++ b/xattrs.c
</span><del>-@@ -32,6 +32,7 @@ extern int am_generator;
</del><ins>+@@ -33,6 +33,7 @@ extern int am_generator;
</ins><span class="cx">  extern int read_only;
</span><span class="cx">  extern int list_only;
</span><span class="cx">  extern int preserve_xattrs;
</span><span class="lines">@@ -458,7 +452,7 @@
</span><span class="cx">  extern int preserve_links;
</span><span class="cx">  extern int preserve_devices;
</span><span class="cx">  extern int preserve_specials;
</span><del>-@@ -40,6 +41,10 @@ extern int checksum_seed;
</del><ins>+@@ -41,6 +42,10 @@ extern int checksum_seed;
</ins><span class="cx">  #define RSYNC_XAL_INITIAL 5
</span><span class="cx">  #define RSYNC_XAL_LIST_INITIAL 100
</span><span class="cx">  
</span><span class="lines">@@ -469,7 +463,7 @@
</span><span class="cx">  #define MAX_FULL_DATUM 32
</span><span class="cx">  
</span><span class="cx">  #define HAS_PREFIX(str, prfx) (*(str) == *(prfx) \
</span><del>-@@ -72,6 +77,17 @@ extern int checksum_seed;
</del><ins>+@@ -73,6 +78,17 @@ extern int checksum_seed;
</ins><span class="cx">  #define XDEF_ACL_SUFFIX &quot;dacl&quot;
</span><span class="cx">  #define XDEF_ACL_ATTR RSYNC_PREFIX &quot;%&quot; XDEF_ACL_SUFFIX
</span><span class="cx">  
</span><span class="lines">@@ -487,7 +481,7 @@
</span><span class="cx">  typedef struct {
</span><span class="cx">          char *datum, *name;
</span><span class="cx">          size_t datum_len, name_len;
</span><del>-@@ -166,8 +182,7 @@ static ssize_t get_xattr_names(const char *fname)
</del><ins>+@@ -167,8 +183,7 @@ static ssize_t get_xattr_names(const char *fname)
</ins><span class="cx">  /* On entry, the *len_ptr parameter contains the size of the extra space we
</span><span class="cx">   * should allocate when we create a buffer for the data.  On exit, it contains
</span><span class="cx">   * the length of the datum. */
</span><span class="lines">@@ -497,7 +491,7 @@
</span><span class="cx">  {
</span><span class="cx">          size_t datum_len = sys_lgetxattr(fname, name, NULL, 0);
</span><span class="cx">          size_t extra_len = *len_ptr;
</span><del>-@@ -176,7 +191,7 @@ static char *get_xattr_data(const char *fname, const char *name, size_t *len_ptr
</del><ins>+@@ -177,7 +192,7 @@ static char *get_xattr_data(const char *fname, const char *name, size_t *len_ptr
</ins><span class="cx">          *len_ptr = datum_len;
</span><span class="cx">  
</span><span class="cx">          if (datum_len == (size_t)-1) {
</span><span class="lines">@@ -506,7 +500,7 @@
</span><span class="cx">                          return NULL;
</span><span class="cx">                  rsyserr(FERROR_XFER, errno,
</span><span class="cx">                          &quot;get_xattr_data: lgetxattr(\&quot;%s\&quot;,\&quot;%s\&quot;,0) failed&quot;,
</span><del>-@@ -184,6 +199,15 @@ static char *get_xattr_data(const char *fname, const char *name, size_t *len_ptr
</del><ins>+@@ -185,6 +200,15 @@ static char *get_xattr_data(const char *fname, const char *name, size_t *len_ptr
</ins><span class="cx">                  return NULL;
</span><span class="cx">          }
</span><span class="cx">  
</span><span class="lines">@@ -522,7 +516,7 @@
</span><span class="cx">          if (!datum_len &amp;&amp; !extra_len)
</span><span class="cx">                  extra_len = 1; /* request non-zero amount of memory */
</span><span class="cx">          if (datum_len + extra_len &lt; datum_len)
</span><del>-@@ -212,7 +236,29 @@ static char *get_xattr_data(const char *fname, const char *name, size_t *len_ptr
</del><ins>+@@ -213,7 +237,29 @@ static char *get_xattr_data(const char *fname, const char *name, size_t *len_ptr
</ins><span class="cx">          return ptr;
</span><span class="cx">  }
</span><span class="cx">  
</span><span class="lines">@@ -553,8 +547,8 @@
</span><span class="cx">  {
</span><span class="cx">          ssize_t list_len, name_len;
</span><span class="cx">          size_t datum_len, name_offset;
</span><del>-@@ -221,7 +267,8 @@ static int rsync_xal_get(const char *fname, item_list *xalp)
-         int user_only = am_sender ? 0 : am_root &lt;= 0;
</del><ins>+@@ -222,7 +268,8 @@ static int rsync_xal_get(const char *fname, item_list *xalp)
+         int user_only = am_sender ? 0 : !am_root;
</ins><span class="cx">  #endif
</span><span class="cx">          rsync_xa *rxa;
</span><span class="cx"> -        int count;
</span><span class="lines">@@ -563,7 +557,7 @@
</span><span class="cx">  
</span><span class="cx">          /* This puts the name list into the &quot;namebuf&quot; buffer. */
</span><span class="cx">          if ((list_len = get_xattr_names(fname)) &lt; 0)
</span><del>-@@ -251,20 +298,22 @@ static int rsync_xal_get(const char *fname, item_list *xalp)
</del><ins>+@@ -252,20 +299,22 @@ static int rsync_xal_get(const char *fname, item_list *xalp)
</ins><span class="cx">                  }
</span><span class="cx">  
</span><span class="cx">                  datum_len = name_len; /* Pass extra size to get_xattr_data() */
</span><span class="lines">@@ -592,16 +586,16 @@
</span><span class="cx">                  } else
</span><span class="cx">                          name_offset = datum_len;
</span><span class="cx">  
</span><del>-@@ -309,7 +358,7 @@ int get_xattr(const char *fname, stat_x *sxp)
-                         return 0;
-         }
</del><ins>+@@ -311,7 +360,7 @@ int get_xattr(const char *fname, stat_x *sxp)
+         } else if (IS_MISSING_FILE(sxp-&gt;st))
+                 return 0;
</ins><span class="cx">  
</span><span class="cx"> -        if (rsync_xal_get(fname, sxp-&gt;xattr) &lt; 0) {
</span><span class="cx"> +        if (rsync_xal_get(fname, sxp) &lt; 0) {
</span><span class="cx">                  free_xattr(sxp);
</span><span class="cx">                  return -1;
</span><span class="cx">          }
</span><del>-@@ -344,6 +393,8 @@ int copy_xattrs(const char *source, const char *dest)
</del><ins>+@@ -346,6 +395,8 @@ int copy_xattrs(const char *source, const char *dest)
</ins><span class="cx">                  datum_len = 0;
</span><span class="cx">                  if (!(ptr = get_xattr_data(source, name, &amp;datum_len, 0)))
</span><span class="cx">                          return -1;
</span><span class="lines">@@ -610,7 +604,7 @@
</span><span class="cx">                  if (sys_lsetxattr(dest, name, ptr, datum_len) &lt; 0) {
</span><span class="cx">                          int save_errno = errno ? errno : EINVAL;
</span><span class="cx">                          rsyserr(FERROR_XFER, errno,
</span><del>-@@ -360,6 +411,10 @@ int copy_xattrs(const char *source, const char *dest)
</del><ins>+@@ -362,6 +413,10 @@ int copy_xattrs(const char *source, const char *dest)
</ins><span class="cx">  
</span><span class="cx">  static int find_matching_xattr(item_list *xalp)
</span><span class="cx">  {
</span><span class="lines">@@ -621,7 +615,7 @@
</span><span class="cx">          size_t i, j;
</span><span class="cx">          item_list *lst = rsync_xal_l.items;
</span><span class="cx">  
</span><del>-@@ -393,6 +448,7 @@ static int find_matching_xattr(item_list *xalp)
</del><ins>+@@ -395,6 +450,7 @@ static int find_matching_xattr(item_list *xalp)
</ins><span class="cx">          }
</span><span class="cx">  
</span><span class="cx">          return -1;
</span><span class="lines">@@ -629,7 +623,7 @@
</span><span class="cx">  }
</span><span class="cx">  
</span><span class="cx">  /* Store *xalp on the end of rsync_xal_l */
</span><del>-@@ -572,11 +628,13 @@ void send_xattr_request(const char *fname, struct file_struct *file, int f_out)
</del><ins>+@@ -574,11 +630,13 @@ void send_xattr_request(const char *fname, struct file_struct *file, int f_out)
</ins><span class="cx">  
</span><span class="cx">                          /* Re-read the long datum. */
</span><span class="cx">                          if (!(ptr = get_xattr_data(fname, rxa-&gt;name, &amp;len, 0))) {
</span><span class="lines">@@ -642,9 +636,9 @@
</span><span class="cx">  
</span><span class="cx"> +                        assert(ptr != UNREAD_DATA);
</span><span class="cx">                          write_varint(f_out, len); /* length might have changed! */
</span><del>-                         write_buf(f_out, ptr, len);
</del><ins>+                         write_bigbuf(f_out, ptr, len);
</ins><span class="cx">                          free(ptr);
</span><del>-@@ -792,7 +850,7 @@ static int rsync_xal_set(const char *fname, item_list *xalp,
</del><ins>+@@ -795,7 +853,7 @@ static int rsync_xal_set(const char *fname, item_list *xalp,
</ins><span class="cx">          int user_only = am_root &lt;= 0;
</span><span class="cx">  #endif
</span><span class="cx">          size_t name_len;
</span><span class="lines">@@ -653,7 +647,7 @@
</span><span class="cx">  
</span><span class="cx">          /* This puts the current name list into the &quot;namebuf&quot; buffer. */
</span><span class="cx">          if ((list_len = get_xattr_names(fname)) &lt; 0)
</span><del>-@@ -804,7 +862,10 @@ static int rsync_xal_set(const char *fname, item_list *xalp,
</del><ins>+@@ -807,7 +865,10 @@ static int rsync_xal_set(const char *fname, item_list *xalp,
</ins><span class="cx">                  if (XATTR_ABBREV(rxas[i])) {
</span><span class="cx">                          /* See if the fnamecmp version is identical. */
</span><span class="cx">                          len = name_len = rxas[i].name_len;
</span><span class="lines">@@ -665,7 +659,7 @@
</span><span class="cx">                            still_abbrev:
</span><span class="cx">                                  if (am_generator)
</span><span class="cx">                                          continue;
</span><del>-@@ -813,14 +874,14 @@ static int rsync_xal_set(const char *fname, item_list *xalp,
</del><ins>+@@ -816,14 +877,14 @@ static int rsync_xal_set(const char *fname, item_list *xalp,
</ins><span class="cx">                                  ret = -1;
</span><span class="cx">                                  continue;
</span><span class="cx">                          }
</span><span class="lines">@@ -683,7 +677,7 @@
</span><span class="cx">                          if (memcmp(sum, rxas[i].datum + 1, MAX_DIGEST_LEN) != 0) {
</span><span class="cx">                                  free(ptr);
</span><span class="cx">                                  goto still_abbrev;
</span><del>-@@ -889,6 +950,10 @@ static int rsync_xal_set(const char *fname, item_list *xalp,
</del><ins>+@@ -892,6 +953,10 @@ static int rsync_xal_set(const char *fname, item_list *xalp,
</ins><span class="cx">                  }
</span><span class="cx">          }
</span><span class="cx">  
</span><span class="lines">@@ -694,7 +688,7 @@
</span><span class="cx">          return ret;
</span><span class="cx">  }
</span><span class="cx">  
</span><del>-@@ -935,7 +1000,7 @@ char *get_xattr_acl(const char *fname, int is_access_acl, size_t *len_p)
</del><ins>+@@ -938,7 +1003,7 @@ char *get_xattr_acl(const char *fname, int is_access_acl, size_t *len_p)
</ins><span class="cx">  {
</span><span class="cx">          const char *name = is_access_acl ? XACC_ACL_ATTR : XDEF_ACL_ATTR;
</span><span class="cx">          *len_p = 0; /* no extra data alloc needed from get_xattr_data() */
</span><span class="lines">@@ -703,7 +697,7 @@
</span><span class="cx">  }
</span><span class="cx">  
</span><span class="cx">  int set_xattr_acl(const char *fname, int is_access_acl, const char *buf, size_t buf_len)
</span><del>-@@ -1078,11 +1143,33 @@ int set_stat_xattr(const char *fname, struct file_struct *file, mode_t new_mode)
</del><ins>+@@ -1081,11 +1146,33 @@ int set_stat_xattr(const char *fname, struct file_struct *file, mode_t new_mode)
</ins><span class="cx">          return 0;
</span><span class="cx">  }
</span><span class="cx">  
</span><span class="lines">@@ -737,7 +731,7 @@
</span><span class="cx">          return ret;
</span><span class="cx">  }
</span><span class="cx">  
</span><del>-@@ -1091,6 +1178,9 @@ int x_lstat(const char *fname, STRUCT_STAT *fst, STRUCT_STAT *xst)
</del><ins>+@@ -1094,6 +1181,9 @@ int x_lstat(const char *fname, STRUCT_STAT *fst, STRUCT_STAT *xst)
</ins><span class="cx">          int ret = do_lstat(fname, fst);
</span><span class="cx">          if ((ret &lt; 0 || get_stat_xattr(fname, -1, fst, xst) &lt; 0) &amp;&amp; xst)
</span><span class="cx">                  xst-&gt;st_mode = 0;
</span><span class="lines">@@ -747,7 +741,7 @@
</span><span class="cx">          return ret;
</span><span class="cx">  }
</span><span class="cx">  
</span><del>-@@ -1099,6 +1189,9 @@ int x_fstat(int fd, STRUCT_STAT *fst, STRUCT_STAT *xst)
</del><ins>+@@ -1102,6 +1192,9 @@ int x_fstat(int fd, STRUCT_STAT *fst, STRUCT_STAT *xst)
</ins><span class="cx">          int ret = do_fstat(fd, fst);
</span><span class="cx">          if ((ret &lt; 0 || get_stat_xattr(NULL, fd, fst, xst) &lt; 0) &amp;&amp; xst)
</span><span class="cx">                  xst-&gt;st_mode = 0;
</span><span class="lines">@@ -757,10 +751,10 @@
</span><span class="cx">          return ret;
</span><span class="cx">  }
</span><span class="cx">  
</span><del>-diff -up a/rsync.1 b/rsync.1
</del><ins>+diff -Nurp a/rsync.1 b/rsync.1
</ins><span class="cx"> --- a/rsync.1
</span><span class="cx"> +++ b/rsync.1
</span><del>-@@ -436,6 +436,8 @@ to the detailed description below for a
</del><ins>+@@ -443,6 +443,8 @@ to the detailed description below for a
</ins><span class="cx">       \-\-chmod=CHMOD           affect file and/or directory permissions
</span><span class="cx">   \-A, \-\-acls                  preserve ACLs (implies \-p)
</span><span class="cx">   \-X, \-\-xattrs                preserve extended attributes
</span><span class="lines">@@ -769,9 +763,9 @@
</span><span class="cx">   \-o, \-\-owner                 preserve owner (super\-user only)
</span><span class="cx">   \-g, \-\-group                 preserve group
</span><span class="cx">       \-\-devices               preserve device files (super\-user only)
</span><del>-@@ -1195,6 +1197,44 @@ flags on files and directories that are
</del><ins>+@@ -1300,6 +1302,44 @@ flags on files and directories that are
</ins><span class="cx">  receiving side.  It does not try to affect user flags.  This option overrides
</span><del>- \fB\-\-force\-change\fP and \fB\-\-force\-schange\fP.
</del><ins>+ \fB\-\-force\-change\fP and \fB\-\-force\-uchange\fP.
</ins><span class="cx">  .IP 
</span><span class="cx"> +.IP &quot;\fB\-\-hfs\-compression\fP&quot;
</span><span class="cx"> +This option causes rsync to preserve HFS+
</span></span></pre>
</div>
</div>

</body>
</html>