From d00c9dac744c3f6e01bd1431d7af6487afbd9729 Mon Sep 17 00:00:00 2001 From: Joachim Wiberg Date: Sun, 21 Feb 2021 12:51:29 +0100 Subject: [PATCH] Minor, refactor in preparation for checking kmesg seqno Signed-off-by: Joachim Wiberg --- src/syslogd.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/src/syslogd.c b/src/syslogd.c index a212191..6ea06a4 100644 --- a/src/syslogd.c +++ b/src/syslogd.c @@ -59,6 +59,7 @@ static char sccsid[] __attribute__((unused)) = #include #include #include +#include #include #include #include @@ -1098,6 +1099,7 @@ void printsys(char *msg) { struct buf_msg buffer; char line[MAXLINE + 1]; + uint64_t seqno = 0; char *lp, *p, *q; int c; @@ -1120,19 +1122,26 @@ void printsys(char *msg) /* Linux /dev/kmsg: "pri,seq#,msec,flag[,..];msg" */ time_t now = boot_time; + /* pri */ buffer.pri = 0; while (isdigit(*p)) buffer.pri = 10 * buffer.pri + (*p++ - '0'); - ++p; - /* skip sequence number for now */ - while (isdigit(*++p)) - ; - ++p; + + p++; /* skip ',' */ + + /* seq# */ + while (isdigit(*p)) + seqno = 10 * seqno + (*p++ - '0'); + + p++; /* skip ',' */ + + /* timestamp */ while (isdigit(*p)) buffer.timestamp.usec = 10 * buffer.timestamp.usec + (*p++ - '0'); now += buffer.timestamp.usec / 1000000; buffer.timestamp.usec = buffer.timestamp.usec % 1000000; localtime_r(&now, &buffer.timestamp.tm); + /* skip flags for now */ q = strchr(p, ';'); if (q)