<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">--- flist.c.orig	2006-01-09 12:35:38.000000000 -0600
+++ flist.c	2006-01-09 12:35:51.000000000 -0600
@@ -27,6 +27,10 @@
 
 #include "rsync.h"
 
+#ifdef HAVE_COPYFILE_H
+#include &lt;copyfile.h&gt;
+#endif
+
 extern int verbose;
 extern int dry_run;
 extern int list_only;
@@ -65,6 +69,10 @@
 extern struct filter_list_struct filter_list;
 extern struct filter_list_struct server_filter_list;
 
+#ifdef EA_SUPPORT
+extern int extended_attributes;
+#endif
+
 int io_error;
 dev_t filesystem_dev; /* used to implement -x */
 
@@ -982,6 +990,54 @@
 	if (file-&gt;basename[0]) {
 		flist-&gt;files[flist-&gt;count++] = file;
 		send_file_entry(file, f, base_flags);
+#ifdef EA_SUPPORT
+		/* If the file doesn't begin with "._", and has
+		 * either acls or extended attributes, serialize
+		 * the data out and add a fake file to the file
+		 * list  with the "._" prepended to the basename.
+		 * of the original source.
+		 */
+		if (extended_attributes) {
+#ifdef HAVE_COPYFILE
+		    if(strncmp(file-&gt;basename, "._", 2)
+			&amp;&amp; copyfile(fname, NULL, 0,
+			    COPYFILE_CHECK | COPYFILE_METADATA)) {
+			char *bp;
+			struct file_struct *file2 = NULL;
+			int alloc_len;
+			
+			if (verbose &gt; 4)
+			    rprintf(FINFO, "added synthetic file for: %s\n", fname);
+
+			alloc_len = file_struct_len
+			    + strlen(file-&gt;basename) + 1 + 2 // + strlen("._")
+			    + MD4_SUM_LENGTH;
+
+			bp = pool_alloc(flist-&gt;file_pool, alloc_len, "receive_metadata_entry");
+
+			file2 = (struct file_struct *)bp;
+			memcpy(bp, file, file_struct_len);
+			bp += file_struct_len;
+
+			file2-&gt;basename = bp;
+			memcpy(bp + 2, file-&gt;basename, strlen(file-&gt;basename) + 1);
+			file2-&gt;basename[0] = '.';
+			file2-&gt;basename[1] = '_';
+			file2-&gt;length = 1;
+			file2-&gt;mode = S_IFREG | S_IRUSR;
+
+			flist_expand(flist);
+			flist-&gt;files[flist-&gt;count++] = file2;
+
+			if (f != -1)
+			    write_byte(f, 1);
+			send_file_entry(file2, f, base_flags);
+		    }
+#endif
+			if (f != -1)
+			    write_byte(f, 0);
+		}
+#endif
 	}
 	return file;
 }
@@ -1318,6 +1374,14 @@
 			flags |= read_byte(f) &lt;&lt; 8;
 		file = receive_file_entry(flist, flags, f);
 
+#ifdef EA_SUPPORT
+		if (extended_attributes &amp;&amp; read_byte(f))
+		    if (verbose &gt; 4)
+			rprintf(FINFO, "receiving synthetic file entry for: %s/%s\n",
+				flist-&gt;files[flist-&gt;count]-&gt;dirname ? flist-&gt;files[flist-&gt;count]-&gt;dirname : ".",
+				flist-&gt;files[flist-&gt;count]-&gt;basename);
+#endif
+
 		if (S_ISREG(file-&gt;mode))
 			stats.total_size += file-&gt;length;
 
</pre></body></html>