1 Common subdirectories: rsync-2.6.4pre2-prexattr/autom4te.cache and rsync-2.6.4pre2/autom4te.cache
2 diff -u -N rsync-2.6.4pre2-prexattr/backup.c rsync-2.6.4pre2/backup.c
3 --- rsync-2.6.4pre2-prexattr/backup.c 2005-03-02 20:15:48.000000000 -0500
4 +++ rsync-2.6.4pre2/backup.c 2005-03-02 20:20:46.000000000 -0500
6 do_lchown(fullpath, st.st_uid, st.st_gid);
7 do_chmod(fullpath, st.st_mode);
8 (void)DUP_ACL(end, fullpath, st.st_mode);
9 + (void)DUP_XATTR(end, fullpath );
16 PUSH_KEEP_BACKUP_ACL(file, fname, buf);
17 + PUSH_KEEP_BACKUP_XATTR( file, fname, buf );
19 /* Check to see if this is a device file, or link */
20 if (IS_DEVICE(file->mode)) {
23 set_perms(buf, file, NULL, 0);
24 CLEANUP_KEEP_BACKUP_ACL();
25 + CLEANUP_KEEP_BACKUP_XATTR();
29 diff -u -N rsync-2.6.4pre2-prexattr/configure.in rsync-2.6.4pre2/configure.in
30 --- rsync-2.6.4pre2-prexattr/configure.in 2005-03-02 20:15:48.000000000 -0500
31 +++ rsync-2.6.4pre2/configure.in 2005-03-02 20:20:46.000000000 -0500
36 +AC_CHECK_HEADERS(attr/xattr.h)
37 ++AC_MSG_CHECKING(whether to support extended attributes)
38 +AC_ARG_WITH(xattr-support,
39 +[ --with-xattr-support Include extended attribute support (default=no)],
44 + AC_MSG_RESULT(Using Linux xattrs)
45 + AC_DEFINE(HAVE_LINUX_XATTRS, 1, [True if you have Linux xattrs])
48 + AC_MSG_RESULT(Xattrs requested but not linux. Good luck)
54 + AC_DEFINE(HAVE_NA_XATTRS, 1, [True if you don't have extended attributes])
57 + AC_DEFINE(HAVE_NO_XATTRL, 1, [True if you don't have extended attributes])
60 AC_CONFIG_FILES([Makefile lib/dummy zlib/dummy popt/dummy shconfig])
63 diff -u -N rsync-2.6.4pre2-prexattr/options.c rsync-2.6.4pre2/options.c
64 --- rsync-2.6.4pre2-prexattr/options.c 2005-03-02 20:15:48.000000000 -0500
65 +++ rsync-2.6.4pre2/options.c 2005-03-02 20:31:22.000000000 -0500
67 int preserve_links = 0;
68 int preserve_hard_links = 0;
69 int preserve_acls = 0;
70 +int preserve_xattrs = 0;
71 int preserve_perms = 0;
72 int preserve_devices = 0;
75 char const *have_inplace = "no ";
76 char const *hardlinks = "no ";
77 char const *acls = "no ";
78 + char const *xattrs = "no ";
79 char const *links = "no ";
80 char const *ipv6 = "no ";
94 "Copyright (C) 1996-2005 by Andrew Tridgell and others\n");
95 rprintf(f, "<http://rsync.samba.org/>\n");
96 rprintf(f, "Capabilities: %d-bit files, %ssocketpairs, "
97 - "%shard links, %sACLs, %ssymlinks, batchfiles, \n",
98 + "%shard links, %sACLs, %sxattrs, %ssymlinks, batchfiles, \n",
99 (int) (sizeof (OFF_T) * 8),
100 - got_socketpair, hardlinks, acls, links);
101 + got_socketpair, hardlinks, acls, xattrs, links);
103 /* Note that this field may not have type ino_t. It depends
104 * on the complicated interaction between largefile feature
106 rprintf(F," -K, --keep-dirlinks treat symlinked dir on receiver as dir\n");
107 rprintf(F," -p, --perms preserve permissions\n");
108 rprintf(F," -A, --acls preserve ACLs (implies --perms)\n");
109 + rprintf(F," -X, --xattrs preserve extended attributes (implies --perms)\n");
110 rprintf(F," -o, --owner preserve owner (root only)\n");
111 rprintf(F," -g, --group preserve group\n");
112 rprintf(F," -D, --devices preserve devices (root only)\n");
114 {"copy-unsafe-links",0, POPT_ARG_NONE, ©_unsafe_links, 0, 0, 0 },
115 {"perms", 'p', POPT_ARG_NONE, &preserve_perms, 0, 0, 0 },
116 {"acls", 'A', POPT_ARG_NONE, 0, 'A', 0, 0 },
117 + {"xattrs", 'X', POPT_ARG_NONE, 0, 'X', 0, 0 },
118 {"owner", 'o', POPT_ARG_NONE, &preserve_uid, 0, 0, 0 },
119 {"group", 'g', POPT_ARG_NONE, &preserve_gid, 0, 0, 0 },
120 {"devices", 'D', POPT_ARG_NONE, &preserve_devices, 0, 0, 0 },
122 #endif /* SUPPORT_ACLS */
127 + preserve_xattrs = 1;
128 + preserve_perms = 1;
130 + snprintf(err_buf,sizeof(err_buf),
131 + "extended attributes are not supported on this %s\n",
132 + am_server ? "server" : "client");
134 +#endif /* SUPPORT_XATTRS */
138 /* A large opt value means that set_refuse_options()
139 @@ -1289,6 +1306,8 @@
143 + if ( preserve_xattrs )
148 Common subdirectories: rsync-2.6.4pre2-prexattr/packaging and rsync-2.6.4pre2/packaging
149 Common subdirectories: rsync-2.6.4pre2-prexattr/patches and rsync-2.6.4pre2/patches
150 Common subdirectories: rsync-2.6.4pre2-prexattr/popt and rsync-2.6.4pre2/popt
151 diff -u -N rsync-2.6.4pre2-prexattr/rsync.c rsync-2.6.4pre2/rsync.c
152 --- rsync-2.6.4pre2-prexattr/rsync.c 2005-03-02 20:15:48.000000000 -0500
153 +++ rsync-2.6.4pre2/rsync.c 2005-03-02 20:31:22.000000000 -0500
155 if (SET_ACL(fname, file) == 0)
158 + /* If this is a directory, SET_XATTR() will be called on the cleanup
159 + * receive_generator() pass--if we called it here, we might clobber
160 + * writability on the directory (SELinux security contexts are stored
161 + * in xattrs). everything else is OK to do now. */
162 + if (!S_ISDIR(st->st_mode)) {
163 + if (SET_XATTR(fname, file) == 0)
167 if (verbose > 1 && flags & PERMS_REPORT) {
168 enum logcode code = daemon_log_format_has_i || dry_run
169 diff -u -N rsync-2.6.4pre2-prexattr/rsync.h rsync-2.6.4pre2/rsync.h
170 --- rsync-2.6.4pre2-prexattr/rsync.h 2005-03-02 20:15:48.000000000 -0500
171 +++ rsync-2.6.4pre2/rsync.h 2005-03-02 20:32:39.000000000 -0500
173 #endif /* SUPPORT_ACLS */
174 #include "smb_acls.h"
176 +#define SUPPORT_XATTRS HAVE_LINUX_XATTRS
179 +#ifdef HAVE_ATTR_XATTR_H
180 +#include <attr/xattr.h>
182 +#define MAKE_XATTR(file, fname) make_xattr(file, fname)
183 +#define SEND_XATTR(file, f) send_xattr(file, f)
184 +#define RECEIVE_XATTR(file, f) receive_xattr(file, f)
185 +#define SORT_FILE_XATTR_INDEX_LISTS() sort_file_xattr_index_lists()
186 +#define SET_XATTR(fname, file) set_xattr(fname, file)
187 +#define NEXT_XATTR_UID() next_xattr_uid()
188 +#define XATTR_UID_MAP(uid) xattr_uid_map(uid)
189 +#define PUSH_KEEP_BACKUP_XATTR(file, orig, dest) \
190 + push_keep_backup_xattr(file, orig, dest)
191 +#define CLEANUP_KEEP_BACKUP_XATTR() cleanup_keep_backup_xattr()
192 +#define DUP_XATTR(orig, dest) dup_xattr(orig, dest)
193 +#else /* SUPPORT_XATTRS */
194 +#define MAKE_XATTR(file, fname) 1 /* checked return value */
195 +#define SEND_XATTR(file, f)
196 +#define RECEIVE_XATTR(file, f)
197 +#define SORT_FILE_XATTR_INDEX_LISTS()
198 +#define SET_XATTR(fname, file) 0 /* checked return value */
199 +#define NEXT_XATTR_UID()
200 +#define XATTR_UID_MAP(uid)
201 +#define PUSH_KEEP_BACKUP_XATTR(file, orig, dest)
202 +#define CLEANUP_KEEP_BACKUP_XATTR()
203 +#define DUP_XATTR(src, orig) 0 /* checked return value */
204 +#endif /* SUPPORT_XATTRS */
208 /* We have replacement versions of these if they're missing. */
209 diff -u -N rsync-2.6.4pre2-prexattr/rsync.yo rsync-2.6.4pre2/rsync.yo
210 --- rsync-2.6.4pre2-prexattr/rsync.yo 2005-03-02 20:15:48.000000000 -0500
211 +++ rsync-2.6.4pre2/rsync.yo 2005-03-02 20:33:53.000000000 -0500
213 -K, --keep-dirlinks treat symlinked dir on receiver as dir
214 -p, --perms preserve permissions
215 -A, --acls preserve ACLs (implies -p) [local option]
216 + -X, --xattrs preserve extended attributes (implies -p) [local option]
217 -o, --owner preserve owner (root only)
218 -g, --group preserve group
219 -D, --devices preserve devices (root only)
221 remote machine's rsync supports this option also. This is a non-standard
224 +dit(bf(-X, --xattrs)) This option causes rsync to update the remote
225 +extended attributes to be the same as the local ones. This will work
226 +only if the remote machine's rsync supports this option also. This is
227 +a non-standard option.
229 dit(bf(-o, --owner)) This option causes rsync to set the owner of the
230 destination file to be the same as the source file. On most systems,
231 only the super-user can set file ownership. By default, the preservation
232 Common subdirectories: rsync-2.6.4pre2-prexattr/support and rsync-2.6.4pre2/support
233 diff -u -N rsync-2.6.4pre2-prexattr/lib/sysxattr.c rsync-2.6.4pre2/sysxattr.c
234 --- rsync-2.6.4pre2-prexattr/lib/sysxattr.c 1969-12-31 19:00:00.000000000 -0500
235 +++ rsync-2.6.4pre2/lib/sysxattr.c 2005-03-02 20:34:10.000000000 -0500
237 +/* Extended attribute support for rsync. */
238 +/* This file Copyright (C) 2004 Red Hat, Inc. */
239 +/* Written by Jay Fenlason */
241 +/* This program is free software; you can redistribute it and/or modify
242 + it under the terms of the GNU General Public License as published by
243 + the Free Software Foundation; either version 2 of the License, or
244 + (at your option) any later version.
246 + This program is distributed in the hope that it will be useful,
247 + but WITHOUT ANY WARRANTY; without even the implied warranty of
248 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
249 + GNU General Public License for more details.
251 + You should have received a copy of the GNU General Public License
252 + along with this program; if not, write to the Free Software
253 + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
258 +#if defined(HAVE_LINUX_XATTRS)
260 +ssize_t sys_lgetxattr ( const char *path, const char *name, void *value, size_t size )
262 + return lgetxattr ( path, name, value, size );
265 +int sys_lsetxattr ( const char *path, const char *name, const void *value, size_t size, int flags )
267 + return lsetxattr ( path, name, value, size, flags );
270 +ssize_t sys_llistxattr ( const char *path, char *list, size_t size )
272 + return llistxattr ( path, list, size );
277 +#endif /* No xattrs */
278 Common subdirectories: rsync-2.6.4pre2-prexattr/testhelp and rsync-2.6.4pre2/testhelp
279 Common subdirectories: rsync-2.6.4pre2-prexattr/testsuite and rsync-2.6.4pre2/testsuite
280 diff -u -N rsync-2.6.4pre2-prexattr/xattr.c rsync-2.6.4pre2/xattr.c
281 --- rsync-2.6.4pre2-prexattr/xattr.c 1969-12-31 19:00:00.000000000 -0500
282 +++ rsync-2.6.4pre2/xattr.c 2005-03-02 20:34:47.000000000 -0500
284 +/* Extended Attribute support for rsync */
285 +/* Copyright (C) 2004 Red Hat, Inc */
286 +/* Written by Jay Fenlason, vaguely based on the ACLs patch */
288 +/* This program is free software; you can redistribute it and/or modify
289 + it under the terms of the GNU General Public License as published by
290 + the Free Software Foundation; either version 2 of the License, or
291 + (at your option) any later version.
293 + This program is distributed in the hope that it will be useful,
294 + but WITHOUT ANY WARRANTY; without even the implied warranty of
295 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
296 + GNU General Public License for more details.
298 + You should have received a copy of the GNU General Public License
299 + along with this program; if not, write to the Free Software
300 + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
307 +extern int preserve_xattrs;
310 +#define RSYNC_XAL_INITIAL 5
311 +#define RSYNC_XAL_LIST_INITIAL 100
333 +static size_t namebuf_len = 0;
334 +static char *namebuf = NULL;
336 +static size_t datumbuf_len = 0;
337 +static char *datumbuf = NULL;
339 +static rsync_xal curr_rsync_xal = { 0, 0, NULL };
340 +static rsync_xal_list rsync_xal_l = { 0, 0, NULL };
343 +/* ------------------------------------------------------------------------- */
345 +/* the below stuff is only used by the receiver */
347 +/* structure to hold index to rsync_xal_l member corresponding to
348 + * flist->files[i] */
351 + const struct file_struct *file;
358 + file_xal_index *filexalidxs;
359 +} file_xal_index_list;
361 +static file_xal_index_list fxil = {0, 0, NULL };
363 +/* stuff for redirecting calls to set_acl() from set_perms()
364 + * for keep_backup() */
365 +static const struct file_struct *backup_orig_file = NULL;
366 +static const char null_string[] = "";
367 +static const char *backup_orig_fname = null_string;
368 +static const char *backup_dest_fname = null_string;
369 +static rsync_xal backup_xal;
371 +/* ------------------------------------------------------------------------- */
373 +static void rsync_xal_free ( rsync_xal *x ) {
376 + for ( i = 0; i < x->count; i++ ) {
377 + free ( x->rxas[i].name );
378 + /* free ( x->rxas[i].value ); */
383 +static int rsync_xal_compare_names ( const void *x1, const void *x2 ) {
384 + const rsync_xa *xa1;
385 + const rsync_xa *xa2;
389 + return strcmp ( xa1->name, xa2->name );
392 +static BOOL rsync_xal_get ( const char *fname, rsync_xal *x ) {
394 + ssize_t datum_size;
402 + namebuf = malloc ( 100 );
403 + datumbuf_len = 100;
404 + datumbuf = malloc ( 100 );
405 + if ( ! namebuf || ! datumbuf ) {
406 + rprintf(FERROR, "%s: rsync_xal_get: allocate intial buffers failed: %s\n",
407 + fname, strerror(errno));
412 + name_size = sys_llistxattr ( fname, namebuf, namebuf_len );
413 + if ( name_size > namebuf_len ) {
417 + if ( name_size < 0 ) {
418 + if ( errno == ENOTSUP )
420 + if ( errno == ERANGE ) {
421 + name_size = sys_llistxattr ( fname, NULL, 0 );
422 + if ( name_size < 0 ) {
423 + rprintf ( FERROR, "%s: rsync_xal_get: llistxattr: %s\n",
424 + fname, strerror(errno) );
427 + namebuf = realloc ( namebuf, name_size + 1 );
429 + rprintf ( FERROR, "%s: rsync_xal_get: reallocate namebuf to %lu failed: %s\n",
430 + fname, (unsigned long)name_size, strerror(errno) );
433 + namebuf_len = name_size;
434 + name_size = sys_llistxattr ( fname, namebuf, namebuf_len );
435 + if ( name_size < 0 ) {
436 + rprintf ( FERROR, "%s: rsync_xal_get: re-llistxattr failed: %s\n",
437 + fname, strerror(errno) );
441 + rprintf(FERROR, "%s: rsync_xal_get: llistxattr failed: %s\n",
442 + fname, strerror(errno));
446 + rsync_xal_free ( x );
447 + if ( name_size == 0 )
449 + for ( left = name_size, name = namebuf; left > 0 ; left -= len, name += len ) {
450 + len = strlen ( name ) + 1;
452 + if ( x->count >= x->alloc ) {
455 + rsync_xa *new_rxas;
457 + new_alloc = ( x->alloc < RSYNC_XAL_INITIAL ) ? RSYNC_XAL_INITIAL : x->alloc * 2;
458 + new_size = new_alloc * sizeof(rsync_xa);
459 + new_rxas = x->alloc ? realloc ( x->rxas, new_size ) : malloc ( new_size );
460 + if ( new_rxas == NULL ) {
461 + rprintf(FERROR, "%s: rsync_xal_get: allocate %lufailed: %s\n",
462 + fname, (unsigned long)new_size, strerror(errno));
465 + x->alloc = new_alloc;
466 + x->rxas = new_rxas;
468 + datum_size = sys_lgetxattr ( fname, name, datumbuf, datumbuf_len );
469 + if ( datum_size > datumbuf_len ) {
473 + if ( datum_size < 0 ) {
474 + if ( errno == ENOTSUP )
476 + if ( errno == ERANGE ) {
477 + datum_size = sys_lgetxattr ( fname, name, NULL, 0 );
478 + if ( datum_size < 0 ) {
479 + rprintf ( FERROR, "%s: rsync_xal_get: lgetxattr %s failed: %s\n",
480 + fname, name, strerror(errno) );
483 + datumbuf = realloc ( datumbuf, datum_size + 1 );
484 + if ( ! datumbuf ) {
485 + rprintf(FERROR, "%s: rsync_xal_get: allocate %lu for datumbuf failed: %s\n",
486 + fname, (unsigned long)(datum_size + 1), strerror(errno));
489 + datumbuf_len = datum_size;
490 + datum_size = sys_lgetxattr ( fname, name, datumbuf, datumbuf_len );
491 + if ( datum_size < 0 ) {
492 + rprintf ( FERROR, "%s: rsync_xal_get: re-lgetxattr of %s failed: %s\n",
493 + name, fname, strerror(errno) );
497 + rprintf(FERROR, "%s: rsync_xal_get: lgetxattr %s failed: %s\n",
498 + fname, name, strerror(errno));
502 + ptr = malloc ( len + datum_size );
503 + strcpy ( ptr, name );
505 + memcpy ( ptr + len, datumbuf, datum_size );
506 + x->rxas[curr_rsync_xal.count].name_len = len;
507 + x->rxas[curr_rsync_xal.count].name = ptr;
508 + x->rxas[curr_rsync_xal.count].datum_len = datum_size;
509 + x->rxas[curr_rsync_xal.count].datum = ptr + len;
512 + if ( x->count > 1 ) {
513 + qsort ( x->rxas, x->count, sizeof(rsync_xa), rsync_xal_compare_names );
519 +/* generate the xattr(s) for this flist entry;
520 + * xattr(s) are either sent or cleaned-up by send_xattr() below */
522 +BOOL make_xattr(const struct file_struct *file, const char *fname)
524 + if (!preserve_xattrs)
527 + rsync_xal_get ( fname, &curr_rsync_xal );
531 +static ssize_t rsync_xal_find_matching ( void ) {
535 + for ( i = 0; i < rsync_xal_l.count; i++ ) {
536 + /* Wrong number of elements? */
537 + if ( rsync_xal_l.rxals[i].count != curr_rsync_xal.count )
539 + /* any elements different? */
540 + for ( j = 0; j < curr_rsync_xal.count; j++ ) {
542 + rsync_xal_l.rxals[i].rxas[j].name_len != curr_rsync_xal.rxas[j].name_len
543 + || rsync_xal_l.rxals[i].rxas[j].datum_len != curr_rsync_xal.rxas[j].datum_len
544 + || strcmp ( rsync_xal_l.rxals[i].rxas[j].name, curr_rsync_xal.rxas[j].name )
545 + || memcmp ( rsync_xal_l.rxals[i].rxas[j].datum, curr_rsync_xal.rxas[j].datum, curr_rsync_xal.rxas[j].datum_len ) )
548 + /* no differences found. This is The One! */
549 + if ( j == curr_rsync_xal.count )
552 + if ( i < rsync_xal_l.count )
554 + return (ssize_t)-1;
557 +/* Store curr_rsync_xal on the end of rsync_xal_l */
558 +static void rsync_xal_store ( void ) {
559 + if ( rsync_xal_l.count <= rsync_xal_l.alloc ) {
564 + new_alloc = ( rsync_xal_l.count < RSYNC_XAL_LIST_INITIAL ) ? RSYNC_XAL_LIST_INITIAL : rsync_xal_l.count * 2;
565 + new_size = new_alloc * sizeof(rsync_xal);
566 + new_xal = rsync_xal_l.count ? realloc ( rsync_xal_l.rxals, new_size ) : malloc ( new_size );
567 + if ( new_xal == NULL ) {
568 + rprintf ( FERROR, "rsync_xal_store: allocate %lu for new_xal failed\n", (unsigned long)new_size );
569 + exit_cleanup(RERR_STREAMIO );
571 + rsync_xal_l.alloc = new_alloc;
572 + rsync_xal_l.rxals = new_xal;
574 + rsync_xal_l.rxals[rsync_xal_l.count] = curr_rsync_xal;
575 + rsync_xal_l.count++;
576 + curr_rsync_xal.count = 0;
577 + curr_rsync_xal.alloc = 0;
580 +/* send the make_xattr()-generated xattr list for this flist entry,
581 + * or clean up after an flist entry that's not being sent (f == -1) */
583 +void send_xattr ( const struct file_struct *file, int f )
587 + if ( ! preserve_xattrs )
591 + rsync_xal_free ( &curr_rsync_xal );
594 + index = rsync_xal_find_matching ( );
595 + if ( index != -1) {
596 + write_byte(f, 'x' );
597 + write_int(f, index);
598 + rsync_xal_free ( &curr_rsync_xal );
603 + count = curr_rsync_xal.count;
604 + write_byte(f, 'X' );
605 + write_int(f, count);
606 + for (rxa = curr_rsync_xal.rxas; count--; rxa++) {
607 + write_int( f, rxa->name_len );
608 + write_int ( f, rxa->datum_len );
609 + write_buf ( f, rxa->name, rxa->name_len );
610 + write_buf ( f, rxa->datum, rxa->datum_len );
617 +/* ------------------------------------------------------------------------- */
618 +/* receive and build the rsync_xattr_lists */
620 +void receive_xattr(struct file_struct *file, int f)
625 + if ( ! preserve_xattrs )
627 + fname = f_name(file);
628 + tag = read_byte(f);
629 + if (tag != 'X' && tag != 'x') {
630 + rprintf(FERROR, "%s: receive_xattr: unknown extended attribute type tag: %c\n",
632 + exit_cleanup(RERR_STREAMIO);
635 + if ( fxil.alloc <= fxil.count) {
640 + if ( fxil.count < RSYNC_XAL_LIST_INITIAL )
641 + new_alloc = fxil.alloc + RSYNC_XAL_LIST_INITIAL;
643 + new_alloc = fxil.alloc * 2;
644 + new_size = new_alloc * sizeof(file_xal_index);
646 + new_ptr = realloc ( fxil.filexalidxs, new_size );
648 + new_ptr = malloc ( new_size );
650 + out_of_memory("receive_xattr");
651 + if (verbose >= 3) {
652 + rprintf(FINFO, "receive_xattr to %lu bytes, %s move\n",
653 + (unsigned long) new_size,
654 + fxil.filexalidxs == new_ptr ? "did not" : "did");
657 + fxil.filexalidxs = new_ptr;
658 + fxil.alloc = new_alloc;
661 + fxil.filexalidxs[fxil.count].file = file;
666 + fxil.filexalidxs[fxil.count].xalidx = rsync_xal_l.count;
668 + count = read_int ( f );
669 + curr_rsync_xal.count = count;
670 + curr_rsync_xal.alloc = count;
671 + curr_rsync_xal.rxas = malloc ( count * sizeof(rsync_xa) );
672 + if ( curr_rsync_xal.rxas == NULL ) {
673 + rprintf(FERROR, "%s: receive_xattr: allocate %lu xas failed\n",
674 + fname, (unsigned long)count );
675 + exit_cleanup(RERR_STREAMIO);
677 + for ( i = 0; i < count; i++ ) {
682 + name_len = read_int ( f );
683 + datum_len = read_int ( f );
684 + ptr = malloc ( name_len + datum_len );
685 + read_buf ( f, ptr, name_len );
686 + read_buf ( f, ptr + name_len, datum_len );
687 + curr_rsync_xal.rxas[i].name_len = name_len;
688 + curr_rsync_xal.rxas[i].datum_len = datum_len;
689 + curr_rsync_xal.rxas[i].name = ptr;
690 + curr_rsync_xal.rxas[i].datum = ptr + name_len;
696 + index = read_int(f);
697 + if ( index >= rsync_xal_l.count) {
698 + rprintf(FERROR, "%s: receive_xattr: xa index %lu out of range\n",
699 +fname, (unsigned long)index );
700 + exit_cleanup(RERR_STREAMIO);
702 + fxil.filexalidxs[fxil.count].xalidx = index;
707 +static BOOL rsync_xal_set ( const char *fname, rsync_xal *x ) {
713 + for ( i = 0; i < x->count; i++ ) {
714 + status = sys_lsetxattr ( fname, x->rxas[i].name, x->rxas[i].datum, x->rxas[i].datum_len, 0 );
715 + if ( status < 0 ) {
716 + rprintf(FERROR, "%s: rsync_xal_set: lsetxattr %s failed: %s\n",
717 + fname, x->rxas[i].name, strerror(errno));
724 +/* for duplicating xattrs on backups when using backup_dir */
726 +int dup_xattr ( const char *orig, const char *bak )
731 + if (!preserve_xattrs)
734 + ret = rsync_xal_get ( orig, &backup_xal );
736 + ret = rsync_xal_set ( bak, &backup_xal );
737 + rsync_xal_free ( &backup_xal );
741 +void push_keep_backup_xattr ( const struct file_struct *file, const char *orig, const char *dest )
743 + if ( ! preserve_xattrs )
746 + backup_orig_file = file;
747 + backup_orig_fname = orig;
748 + backup_dest_fname = dest;
749 + rsync_xal_get ( orig, &backup_xal );
752 +static int set_keep_backup_xal ( void ) {
753 + if ( ! preserve_xattrs )
755 + return rsync_xal_set ( backup_dest_fname, &backup_xal );
758 +void cleanup_keep_backup_xattr ( void )
760 + if ( ! preserve_xattrs)
763 + backup_orig_file = NULL;
764 + backup_orig_fname = null_string;
765 + backup_dest_fname = null_string;
766 + rsync_xal_free ( &backup_xal );
769 +static int file_xal_index_compare ( const void *x1, const void *x2 ) {
770 + const file_xal_index *xa1;
771 + const file_xal_index *xa2;
775 + return ( xa1->file == xa2->file) ? 0 :
776 + ( ( xa1->file < xa2->file ) ? -1: 1 );
778 +void sort_file_xattr_index_lists ( void )
780 + if ( ! preserve_xattrs )
782 + qsort ( fxil.filexalidxs, fxil.count, sizeof(file_xal_index),
783 + file_xal_index_compare );
787 +static int find_file_xal_index( const struct file_struct *file) {
788 + int low = 0, high = fxil.count;
789 + const struct file_struct *file_mid;
792 + rprintf(FERROR, "find_file_xal_index: no entries\n");
793 + exit_cleanup(RERR_STREAMIO);
797 + int mid = (high + low) / 2;
798 + file_mid = fxil.filexalidxs[mid].file;
799 + if (file_mid == file)
800 + return fxil.filexalidxs[mid].xalidx;
801 + if (file_mid > file)
805 + } while (low < high);
807 + file_mid = fxil.filexalidxs[low].file;
808 + if (file_mid == file)
809 + return fxil.filexalidxs[low].xalidx;
812 + "find_file_xal_index: can't find entry for file in list\n");
813 + exit_cleanup(RERR_STREAMIO);
818 +/* set extended attributes on rsync-ed or keep_backup-ed file */
820 +int set_xattr ( const char *fname, const struct file_struct *file )
827 + if ( dry_run || ! preserve_xattrs )
829 + if (file == backup_orig_file) {
830 + if (!strcmp(fname, backup_dest_fname))
831 + return set_keep_backup_xal();
833 + xalidx = find_file_xal_index( file );
834 + x = &(rsync_xal_l.rxals[xalidx]);
835 + updated = rsync_xal_set ( fname, x );
839 +#endif /* SUPPORT_XATTRS */
840 Common subdirectories: rsync-2.6.4pre2-prexattr/zlib and rsync-2.6.4pre2/zlib
841 --- rsync-2.6.4/generator.c.xattr 2005-03-31 09:49:39.000000000 -0500
842 +++ rsync-2.6.4/generator.c 2005-03-31 09:59:22.000000000 -0500
845 SET_ACL(fname, file);
849 + SET_XATTR( fname, file );
851 if (delete_during && f_out != -1 && !phase && dry_run < 2
852 && (file->flags & FLAG_DEL_HERE))
853 delete_in_dir(the_file_list, fname, file);
854 --- rsync-2.6.5/flist.c.xattr 2005-06-02 14:26:25.000000000 -0400
855 +++ rsync-2.6.5/flist.c 2005-06-02 14:33:02.000000000 -0400
858 if (!MAKE_ACL(file, fname))
860 + if ( ! MAKE_XATTR(file, fname ) )
863 maybe_emit_filelist_progress(flist->count + flist_count_offset);
866 flist->files[flist->count++] = file;
867 send_file_entry(file, f, base_flags);
869 + SEND_XATTR ( file, f );
871 /* Cleanup unsent ACL(s). */
873 + SEND_XATTR( file, -1 );
877 @@ -1325,6 +1329,7 @@
878 file = receive_file_entry(flist, flags, f);
880 RECEIVE_ACL(file, f);
881 + RECEIVE_XATTR(file, f );
883 if (S_ISREG(file->mode))
884 stats.total_size += file->length;
885 @@ -1349,6 +1354,7 @@
886 clean_flist(flist, relative_paths, 1);
888 SORT_FILE_ACL_INDEX_LISTS();
889 + SORT_FILE_XATTR_INDEX_LISTS();
892 /* Now send the uid/gid list. This was introduced in
893 --- rsync-2.6.6/Makefile.in.xattr 2005-07-28 16:16:07.000000000 -0400
894 +++ rsync-2.6.6/Makefile.in 2005-07-28 16:18:13.000000000 -0400
897 HEADERS=byteorder.h config.h errcode.h proto.h rsync.h smb_acls.h lib/pool_alloc.h
898 LIBOBJ=lib/wildmatch.o lib/compat.o lib/snprintf.o lib/mdfour.o \
899 - lib/permstring.o lib/pool_alloc.o lib/sysacls.o @LIBOBJS@
900 + lib/permstring.o lib/pool_alloc.o lib/sysacls.o lib/sysxattr.o @LIBOBJS@
901 ZLIBOBJ=zlib/deflate.o zlib/inffast.o zlib/inflate.o zlib/inftrees.o \
902 zlib/trees.o zlib/zutil.o zlib/adler32.o zlib/compress.o zlib/crc32.o
903 OBJS1=rsync.o generator.o receiver.o cleanup.o sender.o exclude.o util.o \
904 main.o checksum.o match.o syscall.o log.o backup.o
905 OBJS2=options.o flist.o io.o compat.o hlink.o token.o uidlist.o socket.o \
906 - fileio.o batch.o clientname.o acls.o
907 + fileio.o batch.o clientname.o acls.o xattr.o
908 OBJS3=progress.o pipe.o
909 DAEMON_OBJ = params.o loadparm.o clientserver.o access.o connection.o authenticate.o
910 popt_OBJS=popt/findme.o popt/popt.o popt/poptconfig.o \