static int fix_permissions( int fd, const char *filename, const char *target, const char *context[_CONTEXT_MAX], uid_t uid) { int r; assert(fd >= 0); assert(target); assert(context); /* Ignore errors on these */ (void) fchmod(fd, 0640); (void) fix_acl(fd, uid); (void) fix_xattr(fd, context); if (fsync(fd) < 0) return log_error_errno(errno, "Failed to sync coredump %s: %m", coredump_tmpfile_name(filename)); (void) fsync_directory_of_file(fd); r = link_tmpfile(fd, filename, target); if (r < 0) return log_error_errno(r, "Failed to move coredump %s into place: %m", target); return 0; }
int id128_write_fd(int fd, Id128Format f, sd_id128_t id, bool do_sync) { char buffer[36 + 2]; size_t sz; int r; assert(fd >= 0); assert(f < _ID128_FORMAT_MAX); if (f != ID128_UUID) { sd_id128_to_string(id, buffer); buffer[32] = '\n'; sz = 33; } else { id128_to_uuid_string(id, buffer); buffer[36] = '\n'; sz = 37; } r = loop_write(fd, buffer, sz, false); if (r < 0) return r; if (do_sync) { if (fsync(fd) < 0) return -errno; r = fsync_directory_of_file(fd); if (r < 0) return r; } return 0; }