return -1;
for (name = namebuf; list_len > 0; name += name_len) {
- rsync_xa *rxas;
+ rsync_xa *rxa;
name_len = strlen(name) + 1;
list_len -= name_len;
#endif
/* No rsync.%FOO attributes are copied w/o 2 -X options. */
- if (preserve_xattrs < 2 && name_len > RPRE_LEN
- && name[RPRE_LEN] == '%' && HAS_PREFIX(name, RSYNC_PREFIX))
- continue;
+ if (name_len > RPRE_LEN && name[RPRE_LEN] == '%'
+ && HAS_PREFIX(name, RSYNC_PREFIX)) {
+ if ((am_sender && preserve_xattrs < 2)
+ || (am_root < 0 && strcmp(name, XSTAT_ATTR) == 0))
+ continue;
+ }
datum_len = name_len; /* Pass extra size to get_xattr_data() */
if (!(ptr = get_xattr_data(fname, name, &datum_len, 0)))
name_offset = datum_len;
#ifdef HAVE_LINUX_XATTRS
- if (am_root < 0 && name_len > RPRE_LEN
+ if (am_root < 0 && name_len > RPRE_LEN && name[RPRE_LEN] != '%'
&& HAS_PREFIX(name, RSYNC_PREFIX)) {
name += RPRE_LEN;
name_len -= RPRE_LEN;
}
#endif
- rxas = EXPAND_ITEM_LIST(xalp, rsync_xa, RSYNC_XAL_INITIAL);
- rxas->name = ptr + name_offset;
- memcpy(rxas->name, name, name_len);
- rxas->datum = ptr;
- rxas->name_len = name_len;
- rxas->datum_len = datum_len;
+ rxa = EXPAND_ITEM_LIST(xalp, rsync_xa, RSYNC_XAL_INITIAL);
+ rxa->name = ptr + name_offset;
+ memcpy(rxa->name, name, name_len);
+ rxa->datum = ptr;
+ rxa->name_len = name_len;
+ rxa->datum_len = datum_len;
}
if (xalp->count > 1)
qsort(xalp->items, xalp->count, sizeof (rsync_xa), rsync_xal_compare_names);
char *ptr;
/* Re-read the long datum. */
- if (!(ptr = get_xattr_data(fname, rxa->name, &len, 0)))
+ if (!(ptr = get_xattr_data(fname, rxa->name, &len, 0))) {
+ rprintf(FERROR_XFER, "failed to re-read xattr %s for %s\n", rxa->name, fname);
+ write_varint(f_out, 0);
continue;
+ }
write_varint(f_out, len); /* length might have changed! */
write_buf(f_out, ptr, len);
* any needed xattrs with a flag that lets us know they need to be sent to
* the receiver. When called by the receiver, reads the sent data and
* stores it in place of its checksum. */
-void recv_xattr_request(struct file_struct *file, int f_in)
+int recv_xattr_request(struct file_struct *file, int f_in)
{
item_list *lst = rsync_xal_l.items;
char *old_datum, *name;
rsync_xa *rxa;
- int rel_pos, cnt;
+ int rel_pos, cnt, got_xattr_data = 0;
if (F_XATTR(file) < 0) {
rprintf(FERROR, "recv_xattr_request: internal data error!\n");
rxa->name = name;
free(old_datum);
read_buf(f_in, rxa->datum, rxa->datum_len);
+ got_xattr_data = 1;
}
+
+ return got_xattr_data;
}
/* ------------------------------------------------------------------------- */
: !HAS_PREFIX(name, USER_PREFIX))
continue;
#endif
+ if (am_root < 0 && name_len > RPRE_LEN
+ && name[RPRE_LEN] == '%' && strcmp(name, XSTAT_ATTR) == 0)
+ continue;
for (i = 0; i < xalp->count; i++) {
if (strcmp(name, rxas[i].name) == 0)
return 0;
}
-int set_stat_xattr(const char *fname, struct file_struct *file)
+int set_stat_xattr(const char *fname, struct file_struct *file, mode_t new_mode)
{
STRUCT_STAT fst, xst;
dev_t rdev;
}
fst.st_mode &= (_S_IFMT | CHMOD_BITS);
- fmode = file->mode & (_S_IFMT | CHMOD_BITS);
+ fmode = new_mode & (_S_IFMT | CHMOD_BITS);
if (IS_DEVICE(fmode) || IS_SPECIAL(fmode)) {
uint32 *devp = F_RDEV_P(file);