X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Fjournal%2Fjournald-kmsg.c;h=2f536320f8d90d41a8eff6740a55da8051ed83a7;hb=b1e2b33c5258f1cefcee55116ac5d049478c804d;hp=aebca5dbed1de58a0ddea63d12d02e3b39b1fffe;hpb=5809560d858f45351856d6fe786a8117306dd0f2;p=elogind.git diff --git a/src/journal/journald-kmsg.c b/src/journal/journald-kmsg.c index aebca5dbe..2f536320f 100644 --- a/src/journal/journald-kmsg.c +++ b/src/journal/journald-kmsg.c @@ -23,11 +23,12 @@ #include #include #include +#include #include #include -#include "journald.h" +#include "journald-server.h" #include "journald-kmsg.h" #include "journald-syslog.h" @@ -108,7 +109,7 @@ static void dev_kmsg_record(Server *s, char *p, size_t l) { char *message = NULL, *syslog_priority = NULL, *syslog_pid = NULL, *syslog_facility = NULL, *syslog_identifier = NULL, *source_time = NULL; int priority, r; unsigned n = 0, z = 0, j; - usec_t usec; + unsigned long long usec; char *identifier = NULL, *pid = NULL, *e, *f, *k; uint64_t serial; size_t pl; @@ -170,7 +171,7 @@ static void dev_kmsg_record(Server *s, char *p, size_t l) { e = f; *e = 0; - r = parse_usec(p, &usec); + r = safe_atollu(p, &usec); if (r < 0) return; @@ -249,10 +250,12 @@ static void dev_kmsg_record(Server *s, char *p, size_t l) { break; g = udev_list_entry_get_name(ll); - b = strappend("_UDEV_DEVLINK=", g); if (g) { - IOVEC_SET_STRING(iovec[n++], b); - z++; + b = strappend("_UDEV_DEVLINK=", g); + if (b) { + IOVEC_SET_STRING(iovec[n++], b); + z++; + } } j++; @@ -262,8 +265,7 @@ static void dev_kmsg_record(Server *s, char *p, size_t l) { } } - if (asprintf(&source_time, "_SOURCE_MONOTONIC_TIMESTAMP=%llu", - (unsigned long long) usec) >= 0) + if (asprintf(&source_time, "_SOURCE_MONOTONIC_TIMESTAMP=%llu", usec) >= 0) IOVEC_SET_STRING(iovec[n++], source_time); IOVEC_SET_STRING(iovec[n++], "_TRANSPORT=kernel"); @@ -274,7 +276,7 @@ static void dev_kmsg_record(Server *s, char *p, size_t l) { if ((priority & LOG_FACMASK) == LOG_KERN) IOVEC_SET_STRING(iovec[n++], "SYSLOG_IDENTIFIER=kernel"); else { - syslog_parse_identifier((const char**) &p, &identifier, &pid); + pl -= syslog_parse_identifier((const char**) &p, &identifier, &pid); /* Avoid any messages we generated ourselves via * log_info() and friends. */ @@ -358,7 +360,7 @@ int server_flush_dev_kmsg(Server *s) { if (!s->dev_kmsg_readable) return 0; - log_info("Flushing /dev/kmsg..."); + log_debug("Flushing /dev/kmsg..."); for (;;) { r = server_read_dev_kmsg(s); @@ -410,7 +412,7 @@ int server_open_kernel_seqnum(Server *s) { /* We store the seqnum we last read in an mmaped file. That * way we can just use it like a variable, but it is - * persistant and automatically flushed at reboot. */ + * persistent and automatically flushed at reboot. */ fd = open("/run/systemd/journal/kernel-seqnum", O_RDWR|O_CREAT|O_CLOEXEC|O_NOCTTY|O_NOFOLLOW, 0644); if (fd < 0) {