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

Function xattr_diff

xattrs.c:547–616  ·  view source on GitHub ↗

Return a flag indicating if we need to change a file's xattrs. If * "find_all" is specified, also mark any abbreviated xattrs that we * need so that send_xattr_request() can tell the sender about them. */

Source from the content-addressed store, hash-verified

545 * "find_all" is specified, also mark any abbreviated xattrs that we
546 * need so that send_xattr_request() can tell the sender about them. */
547int xattr_diff(struct file_struct *file, stat_x *sxp, int find_all)
548{
549 const rsync_xa_list *glst = rsync_xal_l.items;
550 const item_list *lst;
551 rsync_xa *snd_rxa, *rec_rxa;
552 int snd_cnt, rec_cnt;
553 int cmp, same, xattrs_equal = 1;
554
555 if (sxp && XATTR_READY(*sxp)) {
556 rec_rxa = sxp->xattr->items;
557 rec_cnt = sxp->xattr->count;
558 } else {
559 rec_rxa = NULL;
560 rec_cnt = 0;
561 }
562
563 if (F_XATTR(file) >= 0) {
564 glst += F_XATTR(file);
565 lst = &glst->xa_items;
566 } else
567 lst = &empty_xattr;
568
569 snd_rxa = lst->items;
570 snd_cnt = lst->count;
571
572 /* If the count of the sender's xattrs is different from our
573 * (receiver's) xattrs, the lists are not the same. */
574 if (snd_cnt != rec_cnt) {
575 if (!find_all)
576 return 1;
577 xattrs_equal = 0;
578 }
579
580 while (snd_cnt) {
581 cmp = rec_cnt ? strcmp(snd_rxa->name, rec_rxa->name) : -1;
582 if (cmp > 0)
583 same = 0;
584 else if (snd_rxa->datum_len > MAX_FULL_DATUM) {
585 same = cmp == 0 && snd_rxa->datum_len == rec_rxa->datum_len
586 && memcmp(snd_rxa->datum + 1, rec_rxa->datum + 1,
587 xattr_sum_len) == 0;
588 /* Flag unrequested items that we need. */
589 if (!same && find_all && snd_rxa->datum[0] == XSTATE_ABBREV)
590 snd_rxa->datum[0] = XSTATE_TODO;
591 } else {
592 same = cmp == 0 && snd_rxa->datum_len == rec_rxa->datum_len
593 && memcmp(snd_rxa->datum, rec_rxa->datum,
594 snd_rxa->datum_len) == 0;
595 }
596 if (!same) {
597 if (!find_all)
598 return 1;
599 xattrs_equal = 0;
600 }
601
602 if (cmp <= 0) {
603 snd_rxa++;
604 snd_cnt--;

Callers 2

xattrs_differFunction · 0.85
itemizeFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected