mirror of
https://github.com/systemd/systemd.git
synced 2024-12-22 17:35:35 +03:00
parent
cb4069d95e
commit
b2392ff31c
@ -357,6 +357,14 @@
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><varname>ReadKMsg=</varname></term>
|
||||
|
||||
<listitem><para>Takes a boolean value. If enabled (the
|
||||
default), journal reads <filename>/dev/kmsg</filename>
|
||||
messages generated by the kernel.</para></listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><varname>TTYPath=</varname></term>
|
||||
|
||||
|
@ -18,6 +18,7 @@ struct ConfigPerfItem;
|
||||
Journal.Storage, config_parse_storage, 0, offsetof(Server, storage)
|
||||
Journal.Compress, config_parse_bool, 0, offsetof(Server, compress)
|
||||
Journal.Seal, config_parse_bool, 0, offsetof(Server, seal)
|
||||
Journal.ReadKMsg, config_parse_bool, 0, offsetof(Server, read_kmsg)
|
||||
Journal.SyncIntervalSec, config_parse_sec, 0, offsetof(Server, sync_interval_usec)
|
||||
# The following is a legacy name for compatibility
|
||||
Journal.RateLimitInterval, config_parse_sec, 0, offsetof(Server, rate_limit_interval)
|
||||
|
@ -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) {
|
||||
|
||||
|
@ -1915,6 +1915,7 @@ int server_init(Server *s) {
|
||||
s->syslog_fd = s->native_fd = s->stdout_fd = s->dev_kmsg_fd = s->audit_fd = s->hostname_fd = s->notify_fd = -1;
|
||||
s->compress = true;
|
||||
s->seal = true;
|
||||
s->read_kmsg = true;
|
||||
|
||||
s->watchdog_usec = USEC_INFINITY;
|
||||
|
||||
@ -2051,7 +2052,7 @@ int server_init(Server *s) {
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
/* /dev/ksmg */
|
||||
/* /dev/kmsg */
|
||||
r = server_open_dev_kmsg(s);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
@ -112,6 +112,7 @@ struct Server {
|
||||
|
||||
bool compress;
|
||||
bool seal;
|
||||
bool read_kmsg;
|
||||
|
||||
bool forward_to_kmsg;
|
||||
bool forward_to_syslog;
|
||||
|
Loading…
Reference in New Issue
Block a user