From 703bec8b700a5fede74fac497009f4b43cfd3ced Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Thu, 23 Jul 2026 22:13:31 -0500 Subject: [PATCH] Warn if we can't open /dev/kmsg. (alias dmesg="dmesg -S " to avoid.) --- toys/lsb/dmesg.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/toys/lsb/dmesg.c b/toys/lsb/dmesg.c index 29539af9..cd580191 100644 --- a/toys/lsb/dmesg.c +++ b/toys/lsb/dmesg.c @@ -136,8 +136,8 @@ void dmesg_main(void) int fd; // Each read returns one message. By default, we block when there are no - // more messages (--follow); O_NONBLOCK is needed for for usual behavior. - fd = open("/dev/kmsg", O_RDONLY|O_NONBLOCK*!(FLAG(w) || FLAG(W))); + // more messages (--follow); O_NONBLOCK is needed for usual behavior. + fd = xopen("/dev/kmsg", WARN_ONLY|O_RDONLY|O_NONBLOCK*!(FLAG(w)||FLAG(W))); if (fd == -1) goto klogctl_mode; // SYSLOG_ACTION_CLEAR(5) doesn't actually remove anything from /dev/kmsg, -- 2.39.5