]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
journald: mention the access mode we tried to open /dev/kmsg in
authorLennart Poettering <lennart@poettering.net>
Fri, 6 Sep 2024 12:19:59 +0000 (14:19 +0200)
committerLennart Poettering <lennart@poettering.net>
Fri, 6 Sep 2024 14:07:27 +0000 (16:07 +0200)
Let's make clearer what we are going to use /dev/kmsg for: read/write or just
writing. This hopefully should avoid confusion, such as the one #33975
is result of.

(Also while we are at it, add one extra debug message).

Fixes: #33975
src/journal/journald-kmsg.c

index 95135decaa49766458293c2e98764b918ed00228..8e327b8d237050ceccf41a999dba6ebe43839dcc 100644 (file)
@@ -386,20 +386,17 @@ static int dispatch_dev_kmsg(sd_event_source *es, int fd, uint32_t revents, void
 }
 
 int server_open_dev_kmsg(Server *s) {
-        mode_t mode;
         int r;
 
         assert(s);
 
-        if (s->read_kmsg)
-                mode = O_RDWR|O_CLOEXEC|O_NONBLOCK|O_NOCTTY;
-        else
-                mode = O_WRONLY|O_CLOEXEC|O_NONBLOCK|O_NOCTTY;
+        mode_t mode = O_CLOEXEC|O_NONBLOCK|O_NOCTTY|
+                (s->read_kmsg ? O_RDWR : O_WRONLY);
 
         s->dev_kmsg_fd = open("/dev/kmsg", mode);
         if (s->dev_kmsg_fd < 0) {
                 log_full_errno(errno == ENOENT ? LOG_DEBUG : LOG_WARNING,
-                               errno, "Failed to open /dev/kmsg, ignoring: %m");
+                               errno, "Failed to open /dev/kmsg for %s access, ignoring: %m", accmode_to_string(mode));
                 return 0;
         }
 
@@ -408,6 +405,7 @@ int server_open_dev_kmsg(Server *s) {
 
         r = sd_event_add_io(s->event, &s->dev_kmsg_event_source, s->dev_kmsg_fd, EPOLLIN, dispatch_dev_kmsg, s);
         if (r == -EPERM) { /* This will fail with EPERM on older kernels where /dev/kmsg is not readable. */
+                log_debug_errno(r, "Not reading from /dev/kmsg since that's not supported, apparently.");
                 r = 0;
                 goto finish;
         }