#define XATTR_ABBREV(x) ((size_t)((x).name - (x).datum) < (x).datum_len)
-#define XSTATE_ABBREV 0
-#define XSTATE_DONE 1
-#define XSTATE_TODO 2
+#define XSTATE_ABBREV 1
+#define XSTATE_DONE 2
+#define XSTATE_TODO 3
#define USER_PREFIX "user."
#define UPRE_LEN ((int)sizeof USER_PREFIX - 1)
static ssize_t get_xattr_names(const char *fname)
{
ssize_t list_len;
- double arg;
+ int64 arg;
if (!namebuf) {
namebuf_len = 1024;
} else if (errno == ENOTSUP)
return 0;
else if (errno != ERANGE) {
- arg = (double)namebuf_len;
+ arg = namebuf_len;
got_error:
rsyserr(FERROR_XFER, errno,
- "get_xattr_names: llistxattr(\"%s\",%.0f) failed",
- fname, arg);
+ "get_xattr_names: llistxattr(\"%s\",%s) failed",
+ fname, big_num(arg, 0));
return -1;
}
list_len = sys_llistxattr(fname, NULL, 0);
size_t datum_len;
char *name, *ptr;
#ifdef HAVE_LINUX_XATTRS
- int user_only = am_sender ? 0 : !am_root;
+ int user_only = am_sender ? 0 : am_root <= 0;
#endif
/* This puts the name list into the "namebuf" buffer. */
return !xattrs_equal;
}
-/* When called by the generator with a NULL fname, this tells the sender
- * which abbreviated xattr values we need. When called by the sender
- * (with a non-NULL fname), we send all the extra xattr data it needs. */
+/* When called by the generator (with a NULL fname), this tells the sender
+ * all the abbreviated xattr values we need. When called by the sender
+ * (with a non-NULL fname), we send all the extra xattr data it needs.
+ * The generator may also call with f_out < 0 to just change all the
+ * XSTATE_ABBREV states into XSTATE_DONE. */
void send_xattr_request(const char *fname, struct file_struct *file, int f_out)
{
item_list *lst = rsync_xal_l.items;
rxa->datum[0] = XSTATE_DONE;
continue;
case XSTATE_TODO:
+ assert(f_out >= 0);
break;
default:
continue;
}
}
- write_byte(f_out, 0); /* end the list */
+ if (f_out >= 0)
+ write_byte(f_out, 0); /* end the list */
}
/* When called by the sender, read the request from the generator and mark
who_am_i(), num, f_name(file, NULL));
exit_cleanup(RERR_STREAMIO);
}
- if (rxa->datum_len <= MAX_FULL_DATUM || rxa->datum[0] != XSTATE_ABBREV) {
- rprintf(FERROR, "[%s] internal abbrev error!\n", who_am_i());
+ if (!XATTR_ABBREV(*rxa) || rxa->datum[0] != XSTATE_ABBREV) {
+ rprintf(FERROR, "[%s] internal abbrev error on %s (%s, len=%ld)!\n",
+ who_am_i(), f_name(file, NULL), rxa->name, (long)rxa->datum_len);
exit_cleanup(RERR_STREAMIO);
}
ssize_t list_len;
size_t i, len;
char *name, *ptr, sum[MAX_DIGEST_LEN];
+#ifdef HAVE_LINUX_XATTRS
+ int user_only = am_root <= 0;
+#endif
size_t name_len;
int ret = 0;
#ifdef HAVE_LINUX_XATTRS
/* We always ignore the system namespace, and non-root
* ignores everything but the user namespace. */
- if (am_root ? HAS_PREFIX(name, SYSTEM_PREFIX)
- : !HAS_PREFIX(name, USER_PREFIX))
+ if (user_only ? !HAS_PREFIX(name, USER_PREFIX)
+ : HAS_PREFIX(name, SYSTEM_PREFIX))
continue;
#endif
if (am_root < 0 && name_len > RPRE_LEN