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

Function find_matching_xattr

xattrs.c:397–450  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

395}
396
397static int find_matching_xattr(const item_list *xalp)
398{
399 const struct ht_int64_node *node;
400 const rsync_xa_list_ref *ref;
401 int64 key;
402
403 if (rsync_xal_h == NULL)
404 return -1;
405
406 key = xattr_lookup_hash(xalp);
407
408 node = hashtable_find(rsync_xal_h, key, NULL);
409 if (node == NULL)
410 return -1;
411
412 if (node->data == NULL)
413 return -1;
414
415 for (ref = node->data; ref != NULL; ref = ref->next) {
416 const rsync_xa_list *ptr = rsync_xal_l.items;
417 const rsync_xa *rxas1;
418 const rsync_xa *rxas2 = xalp->items;
419 size_t j;
420
421 ptr += ref->ndx;
422 rxas1 = ptr->xa_items.items;
423
424 /* Wrong number of elements? */
425 if (ptr->xa_items.count != xalp->count)
426 continue;
427 /* any elements different? */
428 for (j = 0; j < xalp->count; j++) {
429 if (rxas1[j].name_len != rxas2[j].name_len
430 || rxas1[j].datum_len != rxas2[j].datum_len
431 || strcmp(rxas1[j].name, rxas2[j].name))
432 break;
433 if (rxas1[j].datum_len > MAX_FULL_DATUM) {
434 if (memcmp(rxas1[j].datum + 1,
435 rxas2[j].datum + 1,
436 xattr_sum_len) != 0)
437 break;
438 } else {
439 if (memcmp(rxas1[j].datum, rxas2[j].datum,
440 rxas2[j].datum_len))
441 break;
442 }
443 }
444 /* no differences found. This is The One! */
445 if (j == xalp->count)
446 return ref->ndx;
447 }
448
449 return -1;
450}
451
452/* Store *xalp on the end of rsync_xal_l */
453static int rsync_xal_store(item_list *xalp)

Callers 2

send_xattrFunction · 0.85
cache_tmp_xattrFunction · 0.85

Calls 2

xattr_lookup_hashFunction · 0.85
hashtable_findFunction · 0.85

Tested by

no test coverage detected