| 334 | } |
| 335 | |
| 336 | int copy_xattrs(const char *source, const char *dest) |
| 337 | { |
| 338 | ssize_t list_len, name_len; |
| 339 | size_t datum_len; |
| 340 | char *name, *ptr; |
| 341 | #ifdef HAVE_LINUX_XATTRS |
| 342 | int user_only = am_sender ? 0 : am_root <= 0; |
| 343 | #endif |
| 344 | |
| 345 | /* This puts the name list into the "namebuf" buffer. */ |
| 346 | if ((list_len = get_xattr_names(source)) < 0) |
| 347 | return -1; |
| 348 | |
| 349 | for (name = namebuf; list_len > 0; name += name_len) { |
| 350 | name_len = strlen(name) + 1; |
| 351 | list_len -= name_len; |
| 352 | |
| 353 | if (saw_xattr_filter) { |
| 354 | if (name_is_excluded(name, NAME_IS_XATTR, ALL_FILTERS)) |
| 355 | continue; |
| 356 | } |
| 357 | #ifdef HAVE_LINUX_XATTRS |
| 358 | /* Choose between ignoring the system namespace or (non-root) ignoring any non-user namespace. */ |
| 359 | else if (user_only ? !HAS_PREFIX(name, USER_PREFIX) : HAS_PREFIX(name, SYSTEM_PREFIX)) |
| 360 | continue; |
| 361 | #endif |
| 362 | |
| 363 | datum_len = 0; |
| 364 | if (!(ptr = get_xattr_data(source, name, &datum_len, 0))) |
| 365 | return -1; |
| 366 | if (sys_lsetxattr(dest, name, ptr, datum_len) < 0) { |
| 367 | int save_errno = errno ? errno : EINVAL; |
| 368 | rsyserr(FERROR_XFER, errno, |
| 369 | "copy_xattrs: lsetxattr(%s,\"%s\") failed", |
| 370 | full_fname(dest), name); |
| 371 | errno = save_errno; |
| 372 | return -1; |
| 373 | } |
| 374 | free(ptr); |
| 375 | } |
| 376 | |
| 377 | return 0; |
| 378 | } |
| 379 | |
| 380 | static int64 xattr_lookup_hash(const item_list *xalp) |
| 381 | { |
nothing calls this directly
no test coverage detected