summaryrefslogtreecommitdiffstats
path: root/src/journal/journald-kmsg.c
diff options
context:
space:
mode:
authorSusant Sahani <ssahani@users.noreply.github.com>2017-07-15 13:57:52 +0200
committerLennart Poettering <lennart@poettering.net>2017-07-15 13:57:52 +0200
commitb2392ff31c3b98578f0011323a04619c8a2c19b4 (patch)
tree211ac953048a7cf30f4b1f1608602b300ba06463 /src/journal/journald-kmsg.c
parentadd version argument to help function (#6377) (diff)
downloadsystemd-b2392ff31c3b98578f0011323a04619c8a2c19b4.tar.xz
systemd-b2392ff31c3b98578f0011323a04619c8a2c19b4.zip
journald: make reading /dev/kmsg optional (#6362)
Closes #6022
Diffstat (limited to 'src/journal/journald-kmsg.c')
-rw-r--r--src/journal/journald-kmsg.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/journal/journald-kmsg.c b/src/journal/journald-kmsg.c
index 8afaec0ced..70ea562062 100644
--- a/src/journal/journald-kmsg.c
+++ b/src/journal/journald-kmsg.c
@@ -397,17 +397,26 @@ 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);
- s->dev_kmsg_fd = open("/dev/kmsg", O_RDWR|O_CLOEXEC|O_NONBLOCK|O_NOCTTY);
+ if (s->read_kmsg)
+ mode = O_RDWR|O_CLOEXEC|O_NONBLOCK|O_NOCTTY;
+ else
+ mode = O_WRONLY|O_CLOEXEC|O_NONBLOCK|O_NOCTTY;
+
+ s->dev_kmsg_fd = open("/dev/kmsg", mode);
if (s->dev_kmsg_fd < 0) {
log_full(errno == ENOENT ? LOG_DEBUG : LOG_WARNING,
"Failed to open /dev/kmsg, ignoring: %m");
return 0;
}
+ if (!s->read_kmsg)
+ return 0;
+
r = sd_event_add_io(s->event, &s->dev_kmsg_event_source, s->dev_kmsg_fd, EPOLLIN, dispatch_dev_kmsg, s);
if (r < 0) {