]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
journal: Add new _INITRD field
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Tue, 17 May 2022 12:57:54 +0000 (14:57 +0200)
committerLuca Boccassi <luca.boccassi@gmail.com>
Tue, 23 Aug 2022 18:35:04 +0000 (19:35 +0100)
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.

man/systemd.journal-fields.xml
src/journal/journald-server.c
src/journal/journald-server.h

index d50e89f0bb9ba0c5754b6be994cdb8215d7cfa08..320b7829923b5711ec3ec4400a4984199df63a2f 100644 (file)
         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>
 
index 15b6844d5d4f53cc440b1316fe09ac6be8c67d89..0061abadff5ef0b2498b6f72cf19081157e0cc77 100644 (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))
index 01244e1ce10fefc6d799b9a9ac45f2f2a6fcfc43..ee8f37419088c2e7e9c99e29ba078ec28b4923d5 100644 (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