MCPcopy Index your code
hub / github.com/RsyncProject/rsync / send_xattr_request

Function send_xattr_request

xattrs.c:623–675  ·  view source on GitHub ↗

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. */

Source from the content-addressed store, hash-verified

621 * The generator may also call with f_out < 0 to just change all the
622 * XSTATE_ABBREV states into XSTATE_DONE. */
623void send_xattr_request(const char *fname, struct file_struct *file, int f_out)
624{
625 const rsync_xa_list *glst = rsync_xal_l.items;
626 const item_list *lst;
627 int cnt, prior_req = 0;
628 rsync_xa *rxa;
629
630 glst += F_XATTR(file);
631 lst = &glst->xa_items;
632
633 for (rxa = lst->items, cnt = lst->count; cnt--; rxa++) {
634 if (rxa->datum_len <= MAX_FULL_DATUM)
635 continue;
636 switch (rxa->datum[0]) {
637 case XSTATE_ABBREV:
638 /* Items left abbreviated matched the sender's checksum, so
639 * the receiver will cache the local data for future use. */
640 if (am_generator)
641 rxa->datum[0] = XSTATE_DONE;
642 continue;
643 case XSTATE_TODO:
644 assert(f_out >= 0);
645 break;
646 default:
647 continue;
648 }
649
650 /* Flag that we handled this abbreviated item. */
651 rxa->datum[0] = XSTATE_DONE;
652
653 write_varint(f_out, rxa->num - prior_req);
654 prior_req = rxa->num;
655
656 if (fname) {
657 size_t len = 0;
658 char *ptr;
659
660 /* Re-read the long datum. */
661 if (!(ptr = get_xattr_data(fname, rxa->name, &len, 0))) {
662 rprintf(FERROR_XFER, "failed to re-read xattr %s for %s\n", rxa->name, fname);
663 write_varint(f_out, 0);
664 continue;
665 }
666
667 write_varint(f_out, len); /* length might have changed! */
668 write_bigbuf(f_out, ptr, len);
669 free(ptr);
670 }
671 }
672
673 if (f_out >= 0)
674 write_byte(f_out, 0); /* end the list */
675}
676
677/* When called by the sender, read the request from the generator and mark
678 * any needed xattrs with a flag that lets us know they need to be sent to

Callers 2

write_ndx_and_attrsFunction · 0.85
itemizeFunction · 0.85

Calls 5

write_varintFunction · 0.85
get_xattr_dataFunction · 0.85
write_bigbufFunction · 0.85
write_byteFunction · 0.85
rprintfFunction · 0.70

Tested by

no test coverage detected