From a2735a4549e89f8c1158f17d06eb26fe0ec277d4 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Fri, 22 Nov 2019 15:21:06 +0100 Subject: [PATCH] journald: don't bother with seqnum file if we don't read form /dev/kmsg anyway --- src/journal/journald-kmsg.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/journal/journald-kmsg.c b/src/journal/journald-kmsg.c index 0f4d7704b26..f1e9dee38e7 100644 --- a/src/journal/journald-kmsg.c +++ b/src/journal/journald-kmsg.c @@ -416,15 +416,17 @@ fail: } int server_open_kernel_seqnum(Server *s) { - _cleanup_close_ int fd; + _cleanup_close_ int fd = -1; uint64_t *p; int r; assert(s); - /* We store the seqnum we last read in an mmaped file. That - * way we can just use it like a variable, but it is - * persistent and automatically flushed at reboot. */ + /* We store the seqnum we last read in an mmaped file. That way we can just use it like a variable, + * but it is persistent and automatically flushed at reboot. */ + + if (!s->read_kmsg) + return 0; fd = open("/run/systemd/journal/kernel-seqnum", O_RDWR|O_CREAT|O_CLOEXEC|O_NOCTTY|O_NOFOLLOW, 0644); if (fd < 0) { -- 2.47.3