int priority,
const char *identifier,
const char *message,
- struct ucred *ucred) {
+ const struct ucred *ucred) {
struct iovec iovec[5];
char header_priority[6], header_pid[16];
IOVEC_SET_STRING(iovec[n++], "\n");
if (writev(s->dev_kmsg_fd, iovec, n) < 0)
- log_debug("Failed to write to /dev/kmsg for logging: %m");
+ log_debug_errno(errno, "Failed to write to /dev/kmsg for logging: %m");
free(ident_buf);
}
return t == getpid();
}
-static void dev_kmsg_record(Server *s, char *p, size_t l) {
+static void dev_kmsg_record(Server *s, const char *p, size_t l) {
struct iovec iovec[N_IOVEC_META_FIELDS + 7 + N_IOVEC_KERNEL_FIELDS + 2 + N_IOVEC_UDEV_FIELDS];
char *message = NULL, *syslog_priority = NULL, *syslog_pid = NULL, *syslog_facility = NULL, *syslog_identifier = NULL, *source_time = NULL;
int priority, r;
/* Did we lose any? */
if (serial > *s->kernel_seqnum)
server_driver_message(s, SD_MESSAGE_JOURNAL_MISSED, "Missed %"PRIu64" kernel messages",
- serial - *s->kernel_seqnum - 1);
+ serial - *s->kernel_seqnum);
/* Make sure we never read this one again. Note that
* we always store the next message serial we expect
if (errno == EAGAIN || errno == EINTR || errno == EPIPE)
return 0;
- log_error("Failed to read from kernel: %m");
+ log_error_errno(errno, "Failed to read from kernel: %m");
return -errno;
}
goto fail;
}
- log_error("Failed to add /dev/kmsg fd to event loop: %s", strerror(-r));
+ log_error_errno(r, "Failed to add /dev/kmsg fd to event loop: %m");
goto fail;
}
r = sd_event_source_set_priority(s->dev_kmsg_event_source, SD_EVENT_PRIORITY_IMPORTANT+10);
if (r < 0) {
- log_error("Failed to adjust priority of kmsg event source: %s", strerror(-r));
+ log_error_errno(r, "Failed to adjust priority of kmsg event source: %m");
goto fail;
}
fd = open("/run/systemd/journal/kernel-seqnum", O_RDWR|O_CREAT|O_CLOEXEC|O_NOCTTY|O_NOFOLLOW, 0644);
if (fd < 0) {
- log_error("Failed to open /run/systemd/journal/kernel-seqnum, ignoring: %m");
+ log_error_errno(errno, "Failed to open /run/systemd/journal/kernel-seqnum, ignoring: %m");
return 0;
}
if (posix_fallocate(fd, 0, sizeof(uint64_t)) < 0) {
- log_error("Failed to allocate sequential number file, ignoring: %m");
+ log_error_errno(errno, "Failed to allocate sequential number file, ignoring: %m");
return 0;
}
p = mmap(NULL, sizeof(uint64_t), PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0);
if (p == MAP_FAILED) {
- log_error("Failed to map sequential number file, ignoring: %m");
+ log_error_errno(errno, "Failed to map sequential number file, ignoring: %m");
return 0;
}