if (r < 0)
return log_error_errno(r, "Failed to copy bytes from %s in mage '%s' to '%s': %m", arg_source, arg_image, arg_target);
- (void) copy_xattr(source_fd, target_fd, 0);
+ (void) copy_xattr(source_fd, NULL, target_fd, NULL, 0);
(void) copy_access(source_fd, target_fd);
(void) copy_times(source_fd, target_fd, 0);
if (r < 0)
return log_error_errno(r, "Failed to copy bytes from '%s' to '%s' in image '%s': %m", arg_source, arg_target, arg_image);
- (void) copy_xattr(source_fd, target_fd, 0);
+ (void) copy_xattr(source_fd, NULL, target_fd, NULL, 0);
(void) copy_access(source_fd, target_fd);
(void) copy_times(source_fd, target_fd, 0);
finish:
if (r >= 0) {
(void) copy_times(e->input_fd, e->output_fd, COPY_CRTIME);
- (void) copy_xattr(e->input_fd, e->output_fd, 0);
+ (void) copy_xattr(e->input_fd, NULL, e->output_fd, NULL, 0);
}
if (e->on_finished)
if (S_ISREG(i->input_stat.st_mode)) {
(void) copy_times(i->input_fd, i->output_fd, COPY_CRTIME);
- (void) copy_xattr(i->input_fd, i->output_fd, 0);
+ (void) copy_xattr(i->input_fd, NULL, i->output_fd, NULL, 0);
}
}
return log_error_errno(r, "Failed to make writable copy of image: %m");
(void) copy_times(i->raw_job->disk_fd, dfd, COPY_CRTIME);
- (void) copy_xattr(i->raw_job->disk_fd, dfd, 0);
+ (void) copy_xattr(i->raw_job->disk_fd, NULL, dfd, NULL, 0);
dfd = safe_close(dfd);
r = copy_access(fileno(fr), fileno(fw));
if (r < 0)
return r;
- r = copy_xattr(fileno(fr), fileno(fw), COPY_ALL_XATTRS);
+ r = copy_xattr(fileno(fr), NULL, fileno(fw), NULL, COPY_ALL_XATTRS);
if (r < 0)
log_debug_errno(r, "Failed to copy all xattrs from old to new /etc/locale.gen file, ignoring: %m");
}
if (r < 0)
return log_error_errno(r, "Failed to copy '%s' to '%s%s': %m", *source, strempty(arg_root), *target);
- (void) copy_xattr(sfd, tfd, COPY_ALL_XATTRS);
+ (void) copy_xattr(sfd, NULL, tfd, NULL, COPY_ALL_XATTRS);
(void) copy_access(sfd, tfd);
(void) copy_times(sfd, tfd, 0);
}
r = -errno;
(void) futimens(fdt, (struct timespec[]) { st->st_atim, st->st_mtim });
- (void) copy_xattr(fdf, fdt, copy_flags);
+ (void) copy_xattr(fdf, NULL, fdt, NULL, copy_flags);
if (copy_flags & COPY_FSYNC) {
if (fsync(fdt) < 0) {
if (fchmod(fdt, st->st_mode & 07777) < 0)
r = -errno;
- (void) copy_xattr(dirfd(d), fdt, copy_flags);
+ (void) copy_xattr(dirfd(d), NULL, fdt, NULL, copy_flags);
(void) futimens(fdt, (struct timespec[]) { st->st_atim, st->st_mtim });
}
* mode/ownership of that device node...) */
if (S_ISREG(st.st_mode)) {
(void) copy_times(fdf, fdt, copy_flags);
- (void) copy_xattr(fdf, fdt, copy_flags);
+ (void) copy_xattr(fdf, NULL, fdt, NULL, copy_flags);
}
if (copy_flags & COPY_FSYNC_FULL) {
goto fail;
(void) copy_times(fdf, fdt, copy_flags);
- (void) copy_xattr(fdf, fdt, copy_flags);
+ (void) copy_xattr(fdf, NULL, fdt, NULL, copy_flags);
if (chattr_mask != 0)
(void) chattr_fd(fdt, chattr_flags, chattr_mask & ~CHATTR_EARLY_FL, NULL);
return fchmod_and_chown_with_fallback(fdt, patht, st.st_mode & 07777, st.st_uid, st.st_gid);
}
-int copy_xattr(int fdf, int fdt, CopyFlags copy_flags) {
+int copy_xattr(int df, const char *from, int dt, const char *to, CopyFlags copy_flags) {
_cleanup_free_ char *names = NULL;
int ret = 0, r;
- r = flistxattr_malloc(fdf, &names);
+ r = listxattr_at_malloc(df, from, 0, &names);
if (r < 0)
return r;
if (!FLAGS_SET(copy_flags, COPY_ALL_XATTRS) && !startswith(p, "user."))
continue;
- r = fgetxattr_malloc(fdf, p, &value);
+ r = getxattr_at_malloc(df, from, p, 0, &value);
if (r == -ENODATA)
continue; /* gone by now */
if (r < 0)
return r;
- if (fsetxattr(fdt, p, value, r, 0) < 0)
+ if (xsetxattr(dt, to, p, value, r, 0) < 0)
ret = -errno;
}
static inline int copy_rights(int fdf, int fdt) {
return copy_rights_with_fallback(fdf, fdt, NULL); /* no fallback */
}
-int copy_xattr(int fdf, int fdt, CopyFlags copy_flags);
+int copy_xattr(int df, const char *from, int dt, const char *to, CopyFlags copy_flags);