MCPcopy Create free account
hub / github.com/RsyncProject/rsync / send_xattr

Function send_xattr

xattrs.c:495–542  ·  view source on GitHub ↗

Send the make_xattr()-generated xattr list for this flist entry. */

Source from the content-addressed store, hash-verified

493
494/* Send the make_xattr()-generated xattr list for this flist entry. */
495int send_xattr(int f, stat_x *sxp)
496{
497 int ndx = find_matching_xattr(sxp->xattr);
498
499 /* Send 0 (-1 + 1) to indicate that literal xattr data follows. */
500 write_varint(f, ndx + 1);
501
502 if (ndx < 0) {
503 rsync_xa *rxa;
504 int count = sxp->xattr->count;
505 write_varint(f, count);
506 for (rxa = sxp->xattr->items; count--; rxa++) {
507 size_t name_len = rxa->name_len;
508 const char *name = rxa->name;
509 /* Strip the rsync prefix from disguised namespaces. */
510 if (name_len > RPRE_LEN
511#ifdef HAVE_LINUX_XATTRS
512 && am_root < 0
513#endif
514 && name[RPRE_LEN] != '%' && HAS_PREFIX(name, RSYNC_PREFIX)) {
515 name += RPRE_LEN;
516 name_len -= RPRE_LEN;
517 }
518#ifndef HAVE_LINUX_XATTRS
519 else {
520 /* Put everything else in the user namespace. */
521 name_len += UPRE_LEN;
522 }
523#endif
524 write_varint(f, name_len);
525 write_varint(f, rxa->datum_len);
526#ifndef HAVE_LINUX_XATTRS
527 if (name_len > rxa->name_len) {
528 write_buf(f, USER_PREFIX, UPRE_LEN);
529 name_len -= UPRE_LEN;
530 }
531#endif
532 write_buf(f, name, name_len);
533 if (rxa->datum_len > MAX_FULL_DATUM)
534 write_buf(f, rxa->datum + 1, xattr_sum_len);
535 else
536 write_bigbuf(f, rxa->datum, rxa->datum_len);
537 }
538 ndx = rsync_xal_store(sxp->xattr); /* adds item to rsync_xal_l */
539 }
540
541 return ndx;
542}
543
544/* Return a flag indicating if we need to change a file's xattrs. If
545 * "find_all" is specified, also mark any abbreviated xattrs that we

Callers 1

send_file_nameFunction · 0.85

Calls 5

find_matching_xattrFunction · 0.85
write_varintFunction · 0.85
write_bufFunction · 0.85
write_bigbufFunction · 0.85
rsync_xal_storeFunction · 0.85

Tested by

no test coverage detected