1
1
mirror of https://github.com/systemd/systemd-stable.git synced 2024-12-24 21:34:08 +03:00

journal: Add new _INITRD field

The _INITRD field is a boolean field (0 or 1) that specifies whether
a message was processed by systemd-journald in the initrd or not.
This commit is contained in:
Daan De Meyer 2022-05-17 14:57:54 +02:00 committed by Luca Boccassi
parent 5e98346220
commit cae8edd93c
3 changed files with 14 additions and 1 deletions

View File

@ -398,6 +398,14 @@
for details about journal namespaces.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><varname>_SYSTEM_CONTEXT=</varname></term>
<listitem><para>A string field that specifies the context in which the message was logged. If
<literal>initrd</literal>, the log message was processed while systemd-journald
was running inside the initrd. If <literal>main</literal>, the log message was generated after
journald switched root to the root filesystem.</para></listitem>
</varlistentry>
</variablelist>
</refsect1>

View File

@ -1035,6 +1035,11 @@ static void dispatch_message_real(
if (!isempty(s->namespace_field))
iovec[n++] = IOVEC_MAKE_STRING(s->namespace_field);
if (in_initrd())
iovec[n++] = IOVEC_MAKE_STRING("_SYSTEM_CONTEXT=initrd");
else
iovec[n++] = IOVEC_MAKE_STRING("_SYSTEM_CONTEXT=main");
assert(n <= m);
if (s->split_mode == SPLIT_UID && c && uid_is_valid(c->uid))

View File

@ -179,7 +179,7 @@ struct Server {
#define SERVER_MACHINE_ID(s) ((s)->machine_id_field + STRLEN("_MACHINE_ID="))
/* Extra fields for any log messages */
#define N_IOVEC_META_FIELDS 23
#define N_IOVEC_META_FIELDS 24
/* Extra fields for log messages that contain OBJECT_PID= (i.e. log about another process) */
#define N_IOVEC_OBJECT_FIELDS 18