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

Function rsync_xal_set

xattrs.c:944–1054  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

942}
943
944static int rsync_xal_set(const char *fname, item_list *xalp,
945 const char *fnamecmp, stat_x *sxp)
946{
947 rsync_xa *rxas = xalp->items;
948 ssize_t list_len;
949 size_t i, len;
950 char *name, *ptr, sum[MAX_XATTR_DIGEST_LEN];
951#ifdef HAVE_LINUX_XATTRS
952 int user_only = am_root <= 0;
953#endif
954 size_t name_len;
955 int ret = 0;
956
957 /* This puts the current name list into the "namebuf" buffer. */
958 if ((list_len = get_xattr_names(fname)) < 0)
959 return -1;
960
961 for (i = 0; i < xalp->count; i++) {
962 name = rxas[i].name;
963
964 if (XATTR_ABBREV(rxas[i])) {
965 /* See if the fnamecmp version is identical. */
966 len = name_len = rxas[i].name_len;
967 if ((ptr = get_xattr_data(fnamecmp, name, &len, 1)) == NULL) {
968 still_abbrev:
969 if (am_generator)
970 continue;
971 rprintf(FERROR, "Missing abbreviated xattr value, %s, for %s\n",
972 rxas[i].name, full_fname(fname));
973 ret = -1;
974 continue;
975 }
976 if (len != rxas[i].datum_len) {
977 free(ptr);
978 goto still_abbrev;
979 }
980
981 sum_init(xattr_sum_nni, checksum_seed);
982 sum_update(ptr, len);
983 sum_end(sum);
984 if (memcmp(sum, rxas[i].datum + 1, xattr_sum_len) != 0) {
985 free(ptr);
986 goto still_abbrev;
987 }
988
989 if (fname == fnamecmp)
990 ; /* Value is already set when identical */
991 else if (sys_lsetxattr(fname, name, ptr, len) < 0) {
992 rsyserr(FERROR_XFER, errno,
993 "rsync_xal_set: lsetxattr(%s,\"%s\") failed",
994 full_fname(fname), name);
995 ret = -1;
996 } else /* make sure caller sets mtime */
997 sxp->st.st_mtime = (time_t)-1;
998
999 if (am_generator) { /* generator items stay abbreviated */
1000 free(ptr);
1001 continue;

Callers 1

set_xattrFunction · 0.85

Calls 11

get_xattr_namesFunction · 0.85
get_xattr_dataFunction · 0.85
full_fnameFunction · 0.85
sum_initFunction · 0.85
sum_updateFunction · 0.85
sum_endFunction · 0.85
sys_lsetxattrFunction · 0.85
name_is_excludedFunction · 0.85
sys_lremovexattrFunction · 0.85
rprintfFunction · 0.70
rsyserrFunction · 0.70

Tested by

no test coverage detected