NetBSD-Bugs archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: bin/54729: dmesg(8) trims leading whitespaces of kernel messages
The following reply was made to PR bin/54729; it has been noted by GNATS.
From: Izumi Tsutsui <tsutsui%ceres.dti.ne.jp@localhost>
To: gnats-bugs%netbsd.org@localhost
Cc: tsutsui%ceres.dti.ne.jp@localhost
Subject: Re: bin/54729: dmesg(8) trims leading whitespaces of kernel messages
Date: Tue, 31 Dec 2019 07:44:10 +0900
> It is probably possible to fix it to preserve the spaces (after
> the first one) after the timestamp
The following diff restores format as pre-timestamp versions.
Index: dmesg.c
===================================================================
RCS file: /cvsroot/src/sbin/dmesg/dmesg.c,v
retrieving revision 1.43
diff -u -p -d -r1.43 dmesg.c
--- dmesg.c 4 Jun 2019 11:59:05 -0000 1.43
+++ dmesg.c 30 Dec 2019 22:32:56 -0000
@@ -157,7 +157,7 @@ main(int argc, char *argv[])
long nsec, fsec;
int scale;
int deltas, quiet, humantime;
- bool frac;
+ bool frac, postts;
static const int bmib[] = { CTL_KERN, KERN_BOOTTIME };
size = sizeof(boottime);
@@ -262,6 +262,7 @@ main(int argc, char *argv[])
*/
#ifndef SMALL
frac = false;
+ postts = false;
scale = 0;
#endif
for (tstamp = 0, newl = 1, log = i = 0, p = bufdata + cur.msg_bufx;
@@ -310,6 +311,7 @@ main(int argc, char *argv[])
ADDC(ch);
ADDC('\0');
tstamp = 0;
+ postts = true;
sec = fsec = 0;
switch (sscanf(tbuf, "[%jd.%ld]", &sec, &fsec)){
case EOF:
@@ -375,8 +377,10 @@ main(int argc, char *argv[])
continue;
#endif
case ' ':
- if (!tstamp)
+ if (!tstamp && postts) {
+ postts = false;
continue;
+ }
/*FALLTHROUGH*/
default:
#ifndef SMALL
---
BTW, is it intentional that timestamp format is different between
kernel (and /kern/msgbuf) and dmesg?
https://nxr.netbsd.org/xref/src/sys/kern/subr_prf.c?r=1.181#506
> 506 n = snprintf(buf, sizeof(buf), "[% 4jd.%.*ld] ",
>> [ 1.0000000] NetBSD 9.0_RC1 (HPT5325) #0: Sun Dec 1 23:17:48 JST 2019
https://nxr.netbsd.org/xref/src/sbin/dmesg/dmesg.c?r=1.43#358
> 358 printf(" %5jd%s", sec, radix);
>> [ 1.000000] NetBSD 9.0_RC1 (HPT5325) #0: Sun Dec 1 23:17:48 JST 2019
---
Izumi Tsutsui
Home |
Main Index |
Thread Index |
Old Index