1 Depends-On-Patch: acls.diff
3 After applying this patch, run these commands for a successful build:
6 ./configure --enable-acl-support --enable-xattr-support
11 - This patch needs to be rewritten to more efficiently handle large xattrs.
13 - We need to affect the itemized output to know when xattrs are being updated.
15 - We need to affect the --link-dest option to avoid hard-linking two files
16 that differ in their xattrs (when --xattrs was specified).
20 @@ -27,13 +27,13 @@ VERSION=@VERSION@
22 HEADERS=byteorder.h config.h errcode.h proto.h rsync.h smb_acls.h lib/pool_alloc.h
23 LIBOBJ=lib/wildmatch.o lib/compat.o lib/snprintf.o lib/mdfour.o \
24 - lib/permstring.o lib/pool_alloc.o lib/sysacls.o @LIBOBJS@
25 + lib/permstring.o lib/pool_alloc.o lib/sysacls.o lib/sysxattr.o @LIBOBJS@
26 ZLIBOBJ=zlib/deflate.o zlib/inffast.o zlib/inflate.o zlib/inftrees.o \
27 zlib/trees.o zlib/zutil.o zlib/adler32.o zlib/compress.o zlib/crc32.o
28 OBJS1=rsync.o generator.o receiver.o cleanup.o sender.o exclude.o util.o \
29 main.o checksum.o match.o syscall.o log.o backup.o
30 OBJS2=options.o flist.o io.o compat.o hlink.o token.o uidlist.o socket.o \
31 - fileio.o batch.o clientname.o chmod.o acls.o
32 + fileio.o batch.o clientname.o chmod.o acls.o xattr.o
33 OBJS3=progress.o pipe.o
34 DAEMON_OBJ = params.o loadparm.o clientserver.o access.o connection.o authenticate.o
35 popt_OBJS=popt/findme.o popt/popt.o popt/poptconfig.o \
38 @@ -29,6 +29,7 @@ extern int am_root;
40 extern int orig_umask;
41 extern int preserve_acls;
42 +extern int preserve_xattrs;
43 extern unsigned int file_struct_len;
45 /* === ACL structures === */
46 @@ -743,6 +744,10 @@ void receive_acl(struct file_struct *fil
47 type = SMB_ACL_TYPE_ACCESS;
48 racl_list = &access_acl_list;
49 ndx_ptr = (char*)file + file_struct_len;
50 +#ifdef SUPPORT_XATTRS
51 + if (preserve_xattrs)
55 char tag = read_byte(f);
57 @@ -801,6 +806,10 @@ void cache_acl(struct file_struct *file,
59 racl_list = &access_acl_list;
60 ndx_ptr = (char*)file + file_struct_len;
61 +#ifdef SUPPORT_XATTRS
62 + if (preserve_xattrs)
68 @@ -916,6 +925,10 @@ int set_acl(const char *fname, const str
70 type = SMB_ACL_TYPE_ACCESS;
71 ndx_ptr = (char*)file + file_struct_len;
72 +#ifdef SUPPORT_XATTRS
73 + if (preserve_xattrs)
81 @@ -30,6 +30,7 @@ extern char *backup_dir;
84 extern int preserve_acls;
85 +extern int preserve_xattrs;
86 extern int preserve_devices;
87 extern int preserve_specials;
88 extern int preserve_links;
89 @@ -136,6 +137,9 @@ static int make_bak_dir(char *fullpath)
91 sx.acc_acl = sx.def_acl = NULL;
93 +#ifdef SUPPORT_XATTRS
96 if (!(file = make_file(rel, NULL, NULL, 0, NO_FILTERS)))
99 @@ -144,6 +148,12 @@ static int make_bak_dir(char *fullpath)
100 cache_acl(file, &sx);
103 +#ifdef SUPPORT_XATTRS
104 + if (preserve_xattrs) {
105 + get_xattr(rel, &sx);
106 + cache_xattr(file, &sx);
109 set_file_attrs(fullpath, file, NULL, 0);
112 @@ -195,6 +205,9 @@ static int keep_backup(char *fname)
114 sx.acc_acl = sx.def_acl = NULL;
116 +#ifdef SUPPORT_XATTRS
120 if (!(file = make_file(fname, NULL, NULL, 0, NO_FILTERS)))
121 return 1; /* the file could have disappeared */
122 @@ -208,6 +221,12 @@ static int keep_backup(char *fname)
123 cache_acl(file, &sx);
126 +#ifdef SUPPORT_XATTRS
127 + if (preserve_xattrs) {
128 + get_xattr(fname, &sx);
129 + cache_xattr(file, &sx);
133 /* Check to see if this is a device file, or link */
134 if ((am_root && preserve_devices && IS_DEVICE(file->mode))
137 @@ -823,6 +823,30 @@ samba_cv_HAVE_ACL_GET_PERM_NP=yes,samba_
141 +AC_CHECK_HEADERS(attr/xattr.h)
142 +AC_MSG_CHECKING(whether to support extended attributes)
143 +AC_ARG_ENABLE(xattr-support,
144 +AC_HELP_STRING([--enable-xattr-support], [Include extended attribute support (default=no)]),
145 +[ case "$enableval" in
149 + AC_MSG_RESULT(Using Linux xattrs)
150 + AC_DEFINE(HAVE_LINUX_XATTRS, 1, [True if you have Linux xattrs])
153 + AC_MSG_RESULT(Xattrs requested but not linux. Good luck)
159 + AC_DEFINE(HAVE_NA_XATTRS, 1, [True if you don't have extended attributes])
162 + AC_DEFINE(HAVE_NO_XATTRL, 1, [True if you don't have extended attributes])
165 AC_CONFIG_FILES([Makefile lib/dummy zlib/dummy popt/dummy shconfig])
170 @@ -41,6 +41,7 @@ extern int one_file_system;
171 extern int copy_dirlinks;
172 extern int keep_dirlinks;
173 extern int preserve_acls;
174 +extern int preserve_xattrs;
175 extern int preserve_links;
176 extern int preserve_hard_links;
177 extern int preserve_devices;
178 @@ -494,7 +495,7 @@ static struct file_struct *receive_file_
179 char thisname[MAXPATHLEN];
180 unsigned int l1 = 0, l2 = 0;
181 int alloc_len, basename_len, dirname_len, linkname_len, sum_len;
183 +#if defined SUPPORT_ACLS || defined SUPPORT_XATTRS
187 @@ -606,10 +607,16 @@ static struct file_struct *receive_file_
188 xtra_len = (S_ISDIR(mode) ? 2 : 1) * 4;
191 +#elif defined SUPPORT_XATTRS
194 +#ifdef SUPPORT_XATTRS
195 + if (preserve_xattrs)
199 alloc_len = file_struct_len + dirname_len + basename_len
201 +#if defined SUPPORT_ACLS || defined SUPPORT_XATTRS
204 + linkname_len + sum_len;
205 @@ -618,7 +625,7 @@ static struct file_struct *receive_file_
206 file = (struct file_struct *)bp;
207 memset(bp, 0, file_struct_len);
208 bp += file_struct_len;
210 +#if defined SUPPORT_ACLS || defined SUPPORT_XATTRS
214 @@ -717,6 +724,10 @@ static struct file_struct *receive_file_
216 receive_acl(file, f);
218 +#ifdef SUPPORT_XATTRS
219 + if (preserve_xattrs)
220 + receive_xattr(file, f );
225 @@ -987,6 +998,13 @@ static struct file_struct *send_file_nam
229 +#ifdef SUPPORT_XATTRS
230 + if (preserve_xattrs) {
232 + if (get_xattr(fname, &sx) < 0)
237 maybe_emit_filelist_progress(flist->count + flist_count_offset);
239 @@ -999,11 +1017,19 @@ static struct file_struct *send_file_nam
243 +#ifdef SUPPORT_XATTRS
244 + if (preserve_xattrs)
245 + send_xattr(&sx, f);
252 +#ifdef SUPPORT_XATTRS
253 + if (preserve_xattrs)
259 --- old/lib/sysxattr.c
260 +++ new/lib/sysxattr.c
263 + * Extended attribute support for rsync.
265 + * Copyright (C) 2004 Red Hat, Inc.
266 + * Written by Jay Fenlason.
268 + * This program is free software; you can redistribute it and/or modify
269 + * it under the terms of the GNU General Public License as published by
270 + * the Free Software Foundation; either version 2 of the License, or
271 + * (at your option) any later version.
273 + * This program is distributed in the hope that it will be useful,
274 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
275 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
276 + * GNU General Public License for more details.
278 + * You should have received a copy of the GNU General Public License along
279 + * with this program; if not, write to the Free Software Foundation, Inc.,
280 + * 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
284 +#include "sysxattr.h"
286 +#if defined HAVE_LINUX_XATTRS
288 +ssize_t sys_lgetxattr(const char *path, const char *name, void *value, size_t size)
290 + return lgetxattr(path, name, value, size);
293 +int sys_lsetxattr(const char *path, const char *name, const void *value, size_t size, int flags)
295 + return lsetxattr(path, name, value, size, flags);
298 +ssize_t sys_llistxattr(const char *path, char *list, size_t size)
300 + return llistxattr(path, list, size);
305 +#endif /* No xattrs */
306 --- old/lib/sysxattr.h
307 +++ new/lib/sysxattr.h
309 +#if defined SUPPORT_XATTRS && defined HAVE_ATTR_XATTR_H
310 +#include <attr/xattr.h>
313 +#if defined HAVE_LINUX_XATTRS
315 +ssize_t sys_lgetxattr(const char *path, const char *name, void *value, size_t size);
316 +int sys_lsetxattr(const char *path, const char *name, const void *value, size_t size, int flags);
317 +ssize_t sys_llistxattr(const char *path, char *list, size_t size);
321 +#endif /* No xattrs */
324 @@ -48,6 +48,7 @@ int copy_links = 0;
325 int preserve_links = 0;
326 int preserve_hard_links = 0;
327 int preserve_acls = 0;
328 +int preserve_xattrs = 0;
329 int preserve_perms = 0;
330 int preserve_executability = 0;
331 int preserve_devices = 0;
332 @@ -200,6 +201,7 @@ static void print_rsync_version(enum log
333 char const *have_inplace = "no ";
334 char const *hardlinks = "no ";
335 char const *acls = "no ";
336 + char const *xattrs = "no ";
337 char const *links = "no ";
338 char const *ipv6 = "no ";
339 STRUCT_STAT *dumstat;
340 @@ -219,7 +221,9 @@ static void print_rsync_version(enum log
345 +#ifdef SUPPORT_XATTRS
351 @@ -233,9 +237,9 @@ static void print_rsync_version(enum log
352 rprintf(f, "Copyright (C) 1996-2006 by Andrew Tridgell, Wayne Davison, and others.\n");
353 rprintf(f, "<http://rsync.samba.org/>\n");
354 rprintf(f, "Capabilities: %d-bit files, %ssocketpairs, "
355 - "%shard links, %sACLs, %ssymlinks, batchfiles,\n",
356 + "%shard links, %sACLs, %sxattrs, %ssymlinks, batchfiles,\n",
357 (int) (sizeof (OFF_T) * 8),
358 - got_socketpair, hardlinks, acls, links);
359 + got_socketpair, hardlinks, acls, xattrs, links);
361 /* Note that this field may not have type ino_t. It depends
362 * on the complicated interaction between largefile feature
363 @@ -308,6 +312,9 @@ void usage(enum logcode F)
365 rprintf(F," -A, --acls preserve ACLs (implies --perms)\n");
367 +#ifdef SUPPORT_XATTRS
368 + rprintf(F," -X, --xattrs preserve extended attributes (implies --perms)\n");
370 rprintf(F," --chmod=CHMOD change destination permissions\n");
371 rprintf(F," -o, --owner preserve owner (super-user only)\n");
372 rprintf(F," -g, --group preserve group\n");
373 @@ -427,6 +434,9 @@ static struct poptOption long_options[]
374 {"acls", 'A', POPT_ARG_NONE, 0, 'A', 0, 0 },
375 {"no-acls", 0, POPT_ARG_VAL, &preserve_acls, 0, 0, 0 },
376 {"no-A", 0, POPT_ARG_VAL, &preserve_acls, 0, 0, 0 },
377 + {"xattrs", 'X', POPT_ARG_NONE, 0, 'X', 0, 0 },
378 + {"no-xattrs", 0, POPT_ARG_VAL, &preserve_xattrs, 0, 0, 0 },
379 + {"no-X", 0, POPT_ARG_VAL, &preserve_xattrs, 0, 0, 0 },
380 {"times", 't', POPT_ARG_VAL, &preserve_times, 1, 0, 0 },
381 {"no-times", 0, POPT_ARG_VAL, &preserve_times, 0, 0, 0 },
382 {"no-t", 0, POPT_ARG_VAL, &preserve_times, 0, 0, 0 },
383 @@ -1109,6 +1119,17 @@ int parse_arguments(int *argc, const cha
388 +#ifdef SUPPORT_XATTRS
389 + preserve_xattrs = 1;
390 + preserve_perms = 1;
393 + snprintf(err_buf,sizeof(err_buf),
394 + "extended attributes are not supported on this %s\n",
395 + am_server ? "server" : "client");
397 +#endif /* SUPPORT_XATTRS */
400 /* A large opt value means that set_refuse_options()
401 @@ -1560,6 +1581,10 @@ void server_options(char **args,int *arg
405 +#ifdef SUPPORT_XATTRS
406 + if (preserve_xattrs)
414 @@ -34,6 +34,7 @@ extern int verbose;
416 extern int logfile_format_has_i;
417 extern int preserve_acls;
418 +extern int preserve_xattrs;
419 extern int preserve_perms;
420 extern int preserve_executability;
421 extern int preserve_times;
422 @@ -223,6 +224,10 @@ int set_file_attrs(char *fname, struct f
423 if (preserve_acls && set_acl(fname, file, sxp) == 0)
426 +#ifdef SUPPORT_XATTRS
427 + if (preserve_xattrs && set_xattr(fname, file, sxp) == 0)
432 if ((sxp->st.st_mode & CHMOD_BITS) != (file->mode & CHMOD_BITS)) {
435 @@ -495,6 +495,10 @@ struct idev {
436 #define ACLS_NEED_MASK 1
439 +#ifdef HAVE_LINUX_XATTRS
440 +#define SUPPORT_XATTRS 1
443 #define GID_NONE ((gid_t)-1)
445 #define HL_CHECK_MASTER 0
446 @@ -687,6 +691,9 @@ typedef struct {
447 struct rsync_acl *acc_acl; /* access ACL */
448 struct rsync_acl *def_acl; /* default ACL */
450 +#ifdef SUPPORT_XATTRS
455 #define ACL_READY(sx) ((sx).acc_acl != NULL)
458 @@ -322,6 +322,7 @@ to the detailed description below for a
459 -p, --perms preserve permissions
460 -E, --executability preserve executability
461 -A, --acls preserve ACLs (implies -p) [non-standard]
462 + -X, --xattrs preserve extended attrs (implies -p) [n.s.]
463 --chmod=CHMOD change destination permissions
464 -o, --owner preserve owner (super-user only)
465 -g, --group preserve group
466 @@ -809,6 +810,11 @@ version makes it incompatible with sendi
467 rsync unless you double the bf(--acls) option (e.g. bf(-AA)). This
468 doubling is not needed when pulling files from an older rsync.
470 +dit(bf(-X, --xattrs)) This option causes rsync to update the remote
471 +extended attributes to be the same as the local ones. This will work
472 +only if the remote machine's rsync supports this option also. This is
473 +a non-standard option.
475 dit(bf(--chmod)) This option tells rsync to apply one or more
476 comma-separated "chmod" strings to the permission of the files in the
477 transfer. The resulting value is treated as though it was the permissions
482 + * Extended Attribute support for rsync.
483 + * Written by Jay Fenlason, vaguely based on the ACLs patch.
485 + * Copyright (C) 2004 Red Hat, Inc.
486 + * Copyright (C) 2006 Wayne Davison
488 + * This program is free software; you can redistribute it and/or modify
489 + * it under the terms of the GNU General Public License as published by
490 + * the Free Software Foundation; either version 2 of the License, or
491 + * (at your option) any later version.
493 + * This program is distributed in the hope that it will be useful,
494 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
495 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
496 + * GNU General Public License for more details.
498 + * You should have received a copy of the GNU General Public License along
499 + * with this program; if not, write to the Free Software Foundation, Inc.,
500 + * 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
504 +#include "lib/sysxattr.h"
506 +#ifdef SUPPORT_XATTRS
509 +extern unsigned int file_struct_len;
511 +#define RSYNC_XAL_INITIAL 5
512 +#define RSYNC_XAL_LIST_INITIAL 100
521 +static size_t namebuf_len = 0;
522 +static char *namebuf = NULL;
524 +static size_t datumbuf_len = 0;
525 +static char *datumbuf = NULL;
527 +static item_list empty_xattr = EMPTY_ITEM_LIST;
528 +static item_list rsync_xal_l = EMPTY_ITEM_LIST;
530 +/* ------------------------------------------------------------------------- */
532 +static void rsync_xal_free(item_list *xalp)
535 + rsync_xa *rxas = xalp->items;
537 + for (i = 0; i < xalp->count; i++) {
538 + free(rxas[i].name);
539 + /* free(rxas[i].value); */
544 +void free_xattr(statx *sxp)
546 + rsync_xal_free(sxp->xattr);
551 +static int rsync_xal_compare_names(const void *x1, const void *x2)
553 + const rsync_xa *xa1 = x1;
554 + const rsync_xa *xa2 = x2;
555 + return strcmp(xa1->name, xa2->name);
558 +static int rsync_xal_get(const char *fname, item_list *xalp)
561 + ssize_t datum_size;
569 + namebuf = new_array(char, namebuf_len);
570 + datumbuf_len = 100;
571 + datumbuf = new_array(char, datumbuf_len);
572 + if (!namebuf || !datumbuf)
573 + out_of_memory("rsync_xal_get");
576 + name_size = sys_llistxattr(fname, namebuf, namebuf_len);
577 + if (name_size > (ssize_t)namebuf_len) {
581 + if (name_size < 0) {
582 + if (errno == ENOTSUP)
584 + if (errno == ERANGE) {
585 + name_size = sys_llistxattr(fname, NULL, 0);
586 + if (name_size < 0) {
587 + rsyserr(FERROR, errno, "%s: rsync_xal_get: llistxattr",
591 + namebuf = realloc_array(namebuf, char, name_size + 1);
593 + out_of_memory("rsync_xal_get");
594 + namebuf_len = name_size;
595 + name_size = sys_llistxattr(fname, namebuf, namebuf_len);
596 + if (name_size < 0) {
597 + rsyserr(FERROR, errno,
598 + "%s: rsync_xal_get: re-llistxattr failed",
603 + rsyserr(FERROR, errno,
604 + "%s: rsync_xal_get: llistxattr failed:",
609 + if (name_size == 0)
611 + for (left = name_size, name = namebuf; left > 0 ; left -= len, name += len) {
612 + rsync_xa *rxas = EXPAND_ITEM_LIST(xalp, rsync_xa, RSYNC_XAL_INITIAL);
614 + len = strlen(name) + 1;
615 + datum_size = sys_lgetxattr(fname, name, datumbuf, datumbuf_len);
616 + if (datum_size > (ssize_t)datumbuf_len) {
620 + if (datum_size < 0) {
621 + if (errno == ENOTSUP)
623 + if (errno == ERANGE) {
624 + datum_size = sys_lgetxattr(fname, name, NULL, 0);
625 + if (datum_size < 0) {
626 + rsyserr(FERROR, errno,
627 + "%s: rsync_xal_get: lgetxattr %s failed",
631 + datumbuf = realloc_array(datumbuf, char, datum_size + 1);
633 + out_of_memory("rsync_xal_get");
634 + datumbuf_len = datum_size;
635 + datum_size = sys_lgetxattr(fname, name, datumbuf, datumbuf_len);
636 + if (datum_size < 0) {
637 + rsyserr(FERROR, errno,
638 + "%s: rsync_xal_get: re-lgetxattr of %s failed",
643 + rsyserr(FERROR, errno,
644 + "%s: rsync_xal_get: lgetxattr %s failed",
649 + ptr = new_array(char, len + datum_size);
651 + out_of_memory("rsync_xal_get");
652 + memcpy(ptr, name, len);
654 + memcpy(ptr + len, datumbuf, datum_size);
655 + rxas->name_len = len;
657 + rxas->datum_len = datum_size;
658 + rxas->datum = ptr + len;
660 + if (xalp->count > 1)
661 + qsort(xalp->items, xalp->count, sizeof (rsync_xa), rsync_xal_compare_names);
665 +/* Read the xattr(s) for this filename. */
666 +int get_xattr(const char *fname, statx *sxp)
668 + sxp->xattr = new(item_list);
669 + *sxp->xattr = empty_xattr;
670 + if (rsync_xal_get(fname, sxp->xattr) < 0) {
677 +static int find_matching_xattr(item_list *xalp)
680 + item_list *lst = rsync_xal_l.items;
682 + for (i = 0; i < rsync_xal_l.count; i++) {
683 + rsync_xa *rxas1 = lst[i].items;
684 + rsync_xa *rxas2 = xalp->items;
686 + /* Wrong number of elements? */
687 + if (lst[i].count != xalp->count)
689 + /* any elements different? */
690 + for (j = 0; j < xalp->count; j++) {
691 + if (rxas1[j].name_len != rxas2[j].name_len
692 + || rxas1[j].datum_len != rxas2[j].datum_len
693 + || strcmp(rxas1[j].name, rxas2[j].name)
694 + || memcmp(rxas1[j].datum, rxas2[j].datum, rxas2[j].datum_len))
697 + /* no differences found. This is The One! */
698 + if (j == xalp->count)
705 +/* Store *xalp on the end of rsync_xal_l */
706 +static void rsync_xal_store(item_list *xalp)
708 + item_list *new_lst = EXPAND_ITEM_LIST(&rsync_xal_l, item_list, RSYNC_XAL_LIST_INITIAL);
709 + EXPAND_ITEM_LIST(new_lst, item_list, xalp->count);
710 + memcpy(new_lst->items, xalp->items, xalp->count * sizeof (item_list));
711 + new_lst->count = xalp->count;
715 +/* Send the make_xattr()-generated xattr list for this flist entry. */
716 +void send_xattr(statx *sxp, int f)
718 + int ndx = find_matching_xattr(sxp->xattr);
720 + write_byte(f, 'x');
722 + rsync_xal_free(sxp->xattr);
725 + int count = sxp->xattr->count;
726 + write_byte(f, 'X');
727 + write_int(f, count);
728 + for (rxa = sxp->xattr->items; count--; rxa++) {
729 + write_int(f, rxa->name_len);
730 + write_int(f, rxa->datum_len);
731 + write_buf(f, rxa->name, rxa->name_len);
732 + write_buf(f, rxa->datum, rxa->datum_len);
734 + rsync_xal_store(sxp->xattr);
739 +/* ------------------------------------------------------------------------- */
741 +/* receive and build the rsync_xattr_lists */
742 +void receive_xattr(struct file_struct *file, int f)
744 + static item_list temp_xattr = EMPTY_ITEM_LIST;
745 + int tag = read_byte(f);
746 + char *ndx_ptr = (char*)file + file_struct_len;
750 + int i, count = read_int(f);
751 + for (i = 0; i < count; i++) {
754 + size_t name_len = read_int(f);
755 + size_t datum_len = read_int(f);
756 + if (name_len + datum_len < name_len)
757 + out_of_memory("receive_xattr"); /* overflow */
758 + rxa = EXPAND_ITEM_LIST(&temp_xattr, rsync_xa, count);
759 + ptr = new_array(char, name_len + datum_len);
761 + out_of_memory("receive_xattr");
762 + read_buf(f, ptr, name_len);
763 + read_buf(f, ptr + name_len, datum_len);
764 + rxa->name_len = name_len;
765 + rxa->datum_len = datum_len;
767 + rxa->datum = ptr + name_len;
769 + ndx = rsync_xal_l.count;
770 + rsync_xal_store(&temp_xattr);
771 + } else if (tag == 'x') {
773 + if (ndx < 0 || (size_t)ndx >= rsync_xal_l.count) {
774 + rprintf(FERROR, "%s: receive_xattr: xa index %d out of range\n",
775 + f_name(file, NULL), ndx);
776 + exit_cleanup(RERR_STREAMIO);
780 + "%s: receive_xattr: unknown extended attribute type tag: %c\n",
781 + f_name(file, NULL), tag);
782 + exit_cleanup(RERR_STREAMIO);
783 + ndx = 0; /* silence a compiler warning... */
786 + SIVAL(ndx_ptr, 0, ndx);
789 +/* Turn the xattr data in statx into cached xattr data, setting the index
790 + * values in the file struct. */
791 +void cache_xattr(struct file_struct *file, statx *sxp)
793 + char *ndx_ptr = (char*)file + file_struct_len;
799 + ndx = find_matching_xattr(sxp->xattr);
801 + rsync_xal_store(sxp->xattr);
804 + SIVAL(ndx_ptr, 0, ndx);
807 +static int rsync_xal_set(const char *fname, item_list *xalp)
809 + rsync_xa *rxas = xalp->items;
813 + for (i = 0; i < xalp->count; i++) {
814 + int status = sys_lsetxattr(fname, rxas[i].name, rxas[i].datum, rxas[i].datum_len, 0);
816 + rsyserr(FERROR, errno, "%s: rsync_xal_set: lsetxattr %s failed",
817 + fname, rxas[i].name);
824 +/* Set extended attributes on indicated filename. */
825 +int set_xattr(const char *fname, const struct file_struct *file, UNUSED(statx *sxp))
828 + char *ndx_ptr = (char*)file + file_struct_len;
829 + item_list *lst = rsync_xal_l.items;
832 + return 1; /* FIXME: --dry-run needs to compute this value */
834 + ndx = IVAL(ndx_ptr, 0);
835 + return rsync_xal_set(fname, lst + ndx); /* TODO: This needs to return 1 if no xattrs changed! */
838 +#endif /* SUPPORT_XATTRS */