1
0
mirror of https://github.com/systemd/systemd synced 2025-11-12 21:34:44 +01:00

Compare commits

..

No commits in common. "640ebaa9526ddfdb73feac464707bbac49c83a46" and "848cfa74d275180c1c74213c4abc2ba04170e053" have entirely different histories.

14 changed files with 174 additions and 216 deletions

View File

@ -523,10 +523,10 @@ evdev:name:AlpsPS/2 ALPS GlidePoint:dmi:*svnLENOVO:*pvrLenovoYoga500-14IBD*
# Lenovo Thinkpad T490 # Lenovo Thinkpad T490
evdev:name:SynPS/2 Synaptics TouchPad:dmi:*:svnLENOVO:*pvrThinkPadT490:* evdev:name:SynPS/2 Synaptics TouchPad:dmi:*:svnLENOVO:*pvrThinkPadT490:*
EVDEV_ABS_00=::44 EVDEV_ABS_00=::57
EVDEV_ABS_01=::52 EVDEV_ABS_01=::33
EVDEV_ABS_35=::44 EVDEV_ABS_35=::57
EVDEV_ABS_36=::52 EVDEV_ABS_36=::33
# Lenovo Legion Y9000X2020 # Lenovo Legion Y9000X2020
evdev:name:MSFT0001:02 04F3:304B Touchpad:dmi:*svnLENOVO:*pvrLenovoLegionY9000X2020* evdev:name:MSFT0001:02 04F3:304B Touchpad:dmi:*svnLENOVO:*pvrLenovoLegionY9000X2020*

View File

@ -1013,11 +1013,6 @@ evdev:input:b0005v046DpB30B*
KEYBOARD_KEY_c103a=prog3 # Smartkey C → XF86Launch3 KEYBOARD_KEY_c103a=prog3 # Smartkey C → XF86Launch3
KEYBOARD_KEY_c103b=prog4 # Smartkey D → XF86Launch4 KEYBOARD_KEY_c103b=prog4 # Smartkey D → XF86Launch4
# Logitech K811
evdev:input:b0005v046DpB317*
KEYBOARD_KEY_70047=brightnessdown
KEYBOARD_KEY_70048=brightnessup
# iTouch # iTouch
evdev:input:b0003v046DpC308* evdev:input:b0003v046DpC308*
KEYBOARD_KEY_90001=shop # Shopping KEYBOARD_KEY_90001=shop # Shopping

View File

@ -374,10 +374,9 @@
<option>cat</option> <option>cat</option>
</term> </term>
<listitem> <listitem>
<para>generates a very terse output, only showing the actual message of each journal entry <para>generates a very terse output, only showing the
with no metadata, not even a timestamp. If combined with the actual message of each journal entry with no metadata,
<option>--output-fields=</option> option will output the listed fields for each log record, not even a timestamp.</para>
instead of the message.</para>
</listitem> </listitem>
</varlistentry> </varlistentry>
@ -399,11 +398,10 @@
<varlistentry> <varlistentry>
<term><option>--output-fields=</option></term> <term><option>--output-fields=</option></term>
<listitem><para>A comma separated list of the fields which should be included in the output. This has <listitem><para>A comma separated list of the fields which should be included in the output. This has an
an effect only for the output modes which would normally show all fields (<option>verbose</option>, effect only for the output modes which would normally show all fields (<option>verbose</option>,
<option>export</option>, <option>json</option>, <option>json-pretty</option>, <option>export</option>, <option>json</option>, <option>json-pretty</option>, <option>json-sse</option> and
<option>json-sse</option> and <option>json-seq</option>), as well as on <option>cat</option>. For the <option>json-seq</option>). The <literal>__CURSOR</literal>, <literal>__REALTIME_TIMESTAMP</literal>,
former, the <literal>__CURSOR</literal>, <literal>__REALTIME_TIMESTAMP</literal>,
<literal>__MONOTONIC_TIMESTAMP</literal>, and <literal>_BOOT_ID</literal> fields are always <literal>__MONOTONIC_TIMESTAMP</literal>, and <literal>_BOOT_ID</literal> fields are always
printed.</para></listitem> printed.</para></listitem>
</varlistentry> </varlistentry>

View File

@ -4,11 +4,6 @@
<!-- SPDX-License-Identifier: LGPL-2.1+ --> <!-- SPDX-License-Identifier: LGPL-2.1+ -->
<tbody> <tbody>
<row id='b'>
<entry><literal>%b</literal></entry>
<entry>Boot ID</entry>
<entry>The boot ID of the running system, formatted as string. See <citerefentry><refentrytitle>random</refentrytitle><manvolnum>4</manvolnum></citerefentry> for more information.</entry>
</row>
<row id='a'> <row id='a'>
<entry><literal>%a</literal></entry> <entry><literal>%a</literal></entry>
<entry>Architecture</entry> <entry>Architecture</entry>
@ -19,26 +14,11 @@
<entry>Operating system build ID</entry> <entry>Operating system build ID</entry>
<entry>The operating system build identifier of the running system, as read from the <varname>BUILD_ID=</varname> field of <filename>/etc/os-release</filename>. If not set, resolves to an empty string. See <citerefentry><refentrytitle>os-release</refentrytitle><manvolnum>5</manvolnum></citerefentry> for more information.</entry> <entry>The operating system build identifier of the running system, as read from the <varname>BUILD_ID=</varname> field of <filename>/etc/os-release</filename>. If not set, resolves to an empty string. See <citerefentry><refentrytitle>os-release</refentrytitle><manvolnum>5</manvolnum></citerefentry> for more information.</entry>
</row> </row>
<row id='H'>
<entry><literal>%H</literal></entry>
<entry>Host name</entry>
<entry>The hostname of the running system.</entry>
</row>
<row id='m'>
<entry><literal>%m</literal></entry>
<entry>Machine ID</entry>
<entry>The machine ID of the running system, formatted as string. See <citerefentry><refentrytitle>machine-id</refentrytitle><manvolnum>5</manvolnum></citerefentry> for more information.</entry>
</row>
<row id='o'> <row id='o'>
<entry><literal>%o</literal></entry> <entry><literal>%o</literal></entry>
<entry>Operating system ID</entry> <entry>Operating system ID</entry>
<entry>The operating system identifier of the running system, as read from the <varname>ID=</varname> field of <filename>/etc/os-release</filename>. See <citerefentry><refentrytitle>os-release</refentrytitle><manvolnum>5</manvolnum></citerefentry> for more information.</entry> <entry>The operating system identifier of the running system, as read from the <varname>ID=</varname> field of <filename>/etc/os-release</filename>. See <citerefentry><refentrytitle>os-release</refentrytitle><manvolnum>5</manvolnum></citerefentry> for more information.</entry>
</row> </row>
<row id='v'>
<entry><literal>%v</literal></entry>
<entry>Kernel release</entry>
<entry>Identical to <command>uname -r</command> output.</entry>
</row>
<row id='w'> <row id='w'>
<entry><literal>%w</literal></entry> <entry><literal>%w</literal></entry>
<entry>Operating system version ID</entry> <entry>Operating system version ID</entry>
@ -49,9 +29,4 @@
<entry>Operating system variant ID</entry> <entry>Operating system variant ID</entry>
<entry>The operating system variant identifier of the running system, as read from the <varname>VARIANT_ID=</varname> field of <filename>/etc/os-release</filename>. If not set, resolves to an empty string. See <citerefentry><refentrytitle>os-release</refentrytitle><manvolnum>5</manvolnum></citerefentry> for more information.</entry> <entry>The operating system variant identifier of the running system, as read from the <varname>VARIANT_ID=</varname> field of <filename>/etc/os-release</filename>. If not set, resolves to an empty string. See <citerefentry><refentrytitle>os-release</refentrytitle><manvolnum>5</manvolnum></citerefentry> for more information.</entry>
</row> </row>
<row id='percent'>
<entry><literal>%%</literal></entry>
<entry>Single percent sign</entry>
<entry>Use <literal>%%</literal> in place of <literal>%</literal> to specify a single percent sign.</entry>
</row>
</tbody> </tbody>

View File

@ -90,15 +90,30 @@
</thead> </thead>
<tbody> <tbody>
<xi:include href="standard-specifiers.xml" xpointer="a"/> <xi:include href="standard-specifiers.xml" xpointer="a"/>
<xi:include href="standard-specifiers.xml" xpointer="b"/> <row>
<entry><literal>%b</literal></entry>
<entry>Boot ID</entry>
<entry>The boot ID of the running system, formatted as string. See <citerefentry><refentrytitle>random</refentrytitle><manvolnum>4</manvolnum></citerefentry> for more information.</entry>
</row>
<xi:include href="standard-specifiers.xml" xpointer="B"/> <xi:include href="standard-specifiers.xml" xpointer="B"/>
<xi:include href="standard-specifiers.xml" xpointer="H"/> <row>
<xi:include href="standard-specifiers.xml" xpointer="m"/> <entry><literal>%H</literal></entry>
<entry>Host name</entry>
<entry>The hostname of the running system.</entry>
</row>
<row>
<entry><literal>%m</literal></entry>
<entry>Machine ID</entry>
<entry>The machine ID of the running system, formatted as string. See <citerefentry><refentrytitle>machine-id</refentrytitle><manvolnum>5</manvolnum></citerefentry> for more information.</entry>
</row>
<xi:include href="standard-specifiers.xml" xpointer="o"/> <xi:include href="standard-specifiers.xml" xpointer="o"/>
<xi:include href="standard-specifiers.xml" xpointer="v"/> <row>
<entry><literal>%v</literal></entry>
<entry>Kernel release</entry>
<entry>Identical to <command>uname -r</command> output.</entry>
</row>
<xi:include href="standard-specifiers.xml" xpointer="w"/> <xi:include href="standard-specifiers.xml" xpointer="w"/>
<xi:include href="standard-specifiers.xml" xpointer="W"/> <xi:include href="standard-specifiers.xml" xpointer="W"/>
<xi:include href="standard-specifiers.xml" xpointer="percent"/>
</tbody> </tbody>
</tgroup> </tgroup>
</table> </table>

View File

@ -1715,7 +1715,11 @@
<entry>Architecture</entry> <entry>Architecture</entry>
<entry>A short string identifying the architecture of the local system. A string such as <constant>x86</constant>, <constant>x86-64</constant> or <constant>arm64</constant>. See the architectures defined for <varname>ConditionArchitecture=</varname> above for a full list.</entry> <entry>A short string identifying the architecture of the local system. A string such as <constant>x86</constant>, <constant>x86-64</constant> or <constant>arm64</constant>. See the architectures defined for <varname>ConditionArchitecture=</varname> above for a full list.</entry>
</row> </row>
<xi:include href="standard-specifiers.xml" xpointer="b"/> <row>
<entry><literal>%b</literal></entry>
<entry>Boot ID</entry>
<entry>The boot ID of the running system, formatted as string. See <citerefentry><refentrytitle>random</refentrytitle><manvolnum>4</manvolnum></citerefentry> for more information.</entry>
</row>
<xi:include href="standard-specifiers.xml" xpointer="B"/> <xi:include href="standard-specifiers.xml" xpointer="B"/>
<row> <row>
<entry><literal>%C</literal></entry> <entry><literal>%C</literal></entry>
@ -1740,7 +1744,6 @@
Note that this setting is <emphasis>not</emphasis> influenced by the <varname>User=</varname> setting configurable in the [Service] section of the service unit.</entry> Note that this setting is <emphasis>not</emphasis> influenced by the <varname>User=</varname> setting configurable in the [Service] section of the service unit.</entry>
</row> </row>
<row> <row>
<!-- We do not use the common definition from standard-specifiers.xml here since we want a slightly more verbose explanation here, referring to the reload cycle. -->
<entry><literal>%H</literal></entry> <entry><literal>%H</literal></entry>
<entry>Host name</entry> <entry>Host name</entry>
<entry>The hostname of the running system at the point in time the unit configuration is loaded.</entry> <entry>The hostname of the running system at the point in time the unit configuration is loaded.</entry>
@ -1770,7 +1773,11 @@ Note that this setting is <emphasis>not</emphasis> influenced by the <varname>Us
<entry>Log directory root</entry> <entry>Log directory root</entry>
<entry>This is either <filename>/var/log</filename> (for the system manager) or the path <literal>$XDG_CONFIG_HOME</literal> resolves to with <filename index="false">/log</filename> appended (for user managers).</entry> <entry>This is either <filename>/var/log</filename> (for the system manager) or the path <literal>$XDG_CONFIG_HOME</literal> resolves to with <filename index="false">/log</filename> appended (for user managers).</entry>
</row> </row>
<xi:include href="standard-specifiers.xml" xpointer="m"/> <row>
<entry><literal>%m</literal></entry>
<entry>Machine ID</entry>
<entry>The machine ID of the running system, formatted as string. See <citerefentry><refentrytitle>machine-id</refentrytitle><manvolnum>5</manvolnum></citerefentry> for more information.</entry>
</row>
<xi:include href="standard-specifiers.xml" xpointer="o"/> <xi:include href="standard-specifiers.xml" xpointer="o"/>
<row> <row>
<entry><literal>%n</literal></entry> <entry><literal>%n</literal></entry>
@ -1836,7 +1843,11 @@ Note that this setting is <emphasis>not</emphasis> influenced by the <varname>Us
Note that this setting is <emphasis>not</emphasis> influenced by the <varname>User=</varname> setting configurable in the [Service] section of the service unit.</entry> Note that this setting is <emphasis>not</emphasis> influenced by the <varname>User=</varname> setting configurable in the [Service] section of the service unit.</entry>
</row> </row>
<xi:include href="standard-specifiers.xml" xpointer="v"/> <row>
<entry><literal>%v</literal></entry>
<entry>Kernel release</entry>
<entry>Identical to <command>uname -r</command> output</entry>
</row>
<row> <row>
<entry><literal>%V</literal></entry> <entry><literal>%V</literal></entry>
<entry>Directory for larger and persistent temporary files</entry> <entry>Directory for larger and persistent temporary files</entry>
@ -1844,7 +1855,11 @@ Note that this setting is <emphasis>not</emphasis> influenced by the <varname>Us
</row> </row>
<xi:include href="standard-specifiers.xml" xpointer="w"/> <xi:include href="standard-specifiers.xml" xpointer="w"/>
<xi:include href="standard-specifiers.xml" xpointer="W"/> <xi:include href="standard-specifiers.xml" xpointer="W"/>
<xi:include href="standard-specifiers.xml" xpointer="percent"/> <row>
<entry><literal>%%</literal></entry>
<entry>Single percent sign</entry>
<entry>Use <literal>%%</literal> in place of <literal>%</literal> to specify a single percent sign.</entry>
</row>
</tbody> </tbody>
</tgroup> </tgroup>
</table> </table>

View File

@ -252,17 +252,33 @@ r - 500-900
</thead> </thead>
<tbody> <tbody>
<xi:include href="standard-specifiers.xml" xpointer="a"/> <xi:include href="standard-specifiers.xml" xpointer="a"/>
<xi:include href="standard-specifiers.xml" xpointer="b"/> <row>
<entry><literal>%b</literal></entry>
<entry>Boot ID</entry>
<entry>The boot ID of the running system, formatted as string. See <citerefentry><refentrytitle>random</refentrytitle><manvolnum>4</manvolnum></citerefentry> for more information.</entry>
</row>
<xi:include href="standard-specifiers.xml" xpointer="B"/> <xi:include href="standard-specifiers.xml" xpointer="B"/>
<xi:include href="standard-specifiers.xml" xpointer="H"/> <row>
<xi:include href="standard-specifiers.xml" xpointer="m"/> <entry><literal>%H</literal></entry>
<entry>Host name</entry>
<entry>The hostname of the running system.</entry>
</row>
<row>
<entry><literal>%m</literal></entry>
<entry>Machine ID</entry>
<entry>The machine ID of the running system, formatted as string. See <citerefentry><refentrytitle>machine-id</refentrytitle><manvolnum>5</manvolnum></citerefentry> for more information.</entry>
</row>
<xi:include href="standard-specifiers.xml" xpointer="o"/> <xi:include href="standard-specifiers.xml" xpointer="o"/>
<row> <row>
<entry><literal>%T</literal></entry> <entry><literal>%T</literal></entry>
<entry>Directory for temporary files</entry> <entry>Directory for temporary files</entry>
<entry>This is either <filename>/tmp</filename> or the path <literal>$TMPDIR</literal>, <literal>$TEMP</literal> or <literal>$TMP</literal> are set to.</entry> <entry>This is either <filename>/tmp</filename> or the path <literal>$TMPDIR</literal>, <literal>$TEMP</literal> or <literal>$TMP</literal> are set to.</entry>
</row> </row>
<xi:include href="standard-specifiers.xml" xpointer="v"/> <row>
<entry><literal>%v</literal></entry>
<entry>Kernel release</entry>
<entry>Identical to <command>uname -r</command> output.</entry>
</row>
<row> <row>
<entry><literal>%V</literal></entry> <entry><literal>%V</literal></entry>
<entry>Directory for larger and persistent temporary files</entry> <entry>Directory for larger and persistent temporary files</entry>
@ -270,7 +286,11 @@ r - 500-900
</row> </row>
<xi:include href="standard-specifiers.xml" xpointer="w"/> <xi:include href="standard-specifiers.xml" xpointer="w"/>
<xi:include href="standard-specifiers.xml" xpointer="W"/> <xi:include href="standard-specifiers.xml" xpointer="W"/>
<xi:include href="standard-specifiers.xml" xpointer="percent"/> <row>
<entry><literal>%%</literal></entry>
<entry>Escaped <literal>%</literal></entry>
<entry>Single percent sign.</entry>
</row>
</tbody> </tbody>
</tgroup> </tgroup>
</table> </table>

View File

@ -633,7 +633,11 @@ w- /proc/sys/vm/swappiness - - - - 10</programlisting></para>
</thead> </thead>
<tbody> <tbody>
<xi:include href="standard-specifiers.xml" xpointer="a"/> <xi:include href="standard-specifiers.xml" xpointer="a"/>
<xi:include href="standard-specifiers.xml" xpointer="b"/> <row>
<entry><literal>%b</literal></entry>
<entry>Boot ID</entry>
<entry>The boot ID of the running system, formatted as string. See <citerefentry><refentrytitle>random</refentrytitle><manvolnum>4</manvolnum></citerefentry> for more information.</entry>
</row>
<xi:include href="standard-specifiers.xml" xpointer="B"/> <xi:include href="standard-specifiers.xml" xpointer="B"/>
<row> <row>
<entry><literal>%C</literal></entry> <entry><literal>%C</literal></entry>
@ -645,13 +649,21 @@ w- /proc/sys/vm/swappiness - - - - 10</programlisting></para>
<entry>User home directory</entry> <entry>User home directory</entry>
<entry>This is the home directory of the user running the command. In case of the system instance this resolves to <literal>/root</literal>.</entry> <entry>This is the home directory of the user running the command. In case of the system instance this resolves to <literal>/root</literal>.</entry>
</row> </row>
<xi:include href="standard-specifiers.xml" xpointer="H"/> <row>
<entry><literal>%H</literal></entry>
<entry>Host name</entry>
<entry>The hostname of the running system.</entry>
</row>
<row> <row>
<entry><literal>%L</literal></entry> <entry><literal>%L</literal></entry>
<entry>System or user log directory</entry> <entry>System or user log directory</entry>
<entry>In <option>--user</option> mode, this is the same as <varname>$XDG_CONFIG_HOME</varname> with <filename index="false">/log</filename> appended, and <filename>/var/log</filename> otherwise.</entry> <entry>In <option>--user</option> mode, this is the same as <varname>$XDG_CONFIG_HOME</varname> with <filename index="false">/log</filename> appended, and <filename>/var/log</filename> otherwise.</entry>
</row> </row>
<xi:include href="standard-specifiers.xml" xpointer="m"/> <row>
<entry><literal>%m</literal></entry>
<entry>Machine ID</entry>
<entry>The machine ID of the running system, formatted as string. See <citerefentry><refentrytitle>machine-id</refentrytitle><manvolnum>5</manvolnum></citerefentry> for more information.</entry>
</row>
<xi:include href="standard-specifiers.xml" xpointer="o"/> <xi:include href="standard-specifiers.xml" xpointer="o"/>
<row> <row>
<entry><literal>%S</literal></entry> <entry><literal>%S</literal></entry>
@ -688,7 +700,11 @@ w- /proc/sys/vm/swappiness - - - - 10</programlisting></para>
<entry>User UID</entry> <entry>User UID</entry>
<entry>This is the numeric UID of the user running the command. In case of the system instance this resolves to <constant>0</constant>.</entry> <entry>This is the numeric UID of the user running the command. In case of the system instance this resolves to <constant>0</constant>.</entry>
</row> </row>
<xi:include href="standard-specifiers.xml" xpointer="v"/> <row>
<entry><literal>%v</literal></entry>
<entry>Kernel release</entry>
<entry>Identical to <command>uname -r</command> output.</entry>
</row>
<row> <row>
<entry><literal>%V</literal></entry> <entry><literal>%V</literal></entry>
<entry>Directory for larger and persistent temporary files</entry> <entry>Directory for larger and persistent temporary files</entry>
@ -696,7 +712,11 @@ w- /proc/sys/vm/swappiness - - - - 10</programlisting></para>
</row> </row>
<xi:include href="standard-specifiers.xml" xpointer="w"/> <xi:include href="standard-specifiers.xml" xpointer="w"/>
<xi:include href="standard-specifiers.xml" xpointer="W"/> <xi:include href="standard-specifiers.xml" xpointer="W"/>
<xi:include href="standard-specifiers.xml" xpointer="percent"/> <row>
<entry><literal>%%</literal></entry>
<entry>Escaped <literal>%</literal></entry>
<entry>Single percent sign.</entry>
</row>
</tbody> </tbody>
</tgroup> </tgroup>
</table> </table>

View File

@ -3486,16 +3486,6 @@ static int outer_child(
if (r < 0) if (r < 0)
return r; return r;
r = mount_custom(
directory,
arg_custom_mounts,
arg_n_custom_mounts,
arg_uid_shift,
arg_selinux_apifs_context,
MOUNT_NON_ROOT_ONLY);
if (r < 0)
return r;
r = setup_timezone(directory); r = setup_timezone(directory);
if (r < 0) if (r < 0)
return r; return r;
@ -3512,6 +3502,16 @@ static int outer_child(
if (r < 0) if (r < 0)
return r; return r;
r = mount_custom(
directory,
arg_custom_mounts,
arg_n_custom_mounts,
arg_uid_shift,
arg_selinux_apifs_context,
MOUNT_NON_ROOT_ONLY);
if (r < 0)
return r;
if (!arg_use_cgns) { if (!arg_use_cgns) {
r = mount_cgroups( r = mount_cgroups(
directory, directory,

View File

@ -1241,7 +1241,7 @@ static int table_data_compare(const size_t *a, const size_t *b, Table *t) {
return CMP(*a, *b); return CMP(*a, *b);
} }
static const char *table_data_format(Table *t, TableData *d, bool avoid_uppercasing) { static const char *table_data_format(Table *t, TableData *d) {
assert(d); assert(d);
if (d->formatted) if (d->formatted)
@ -1253,7 +1253,7 @@ static const char *table_data_format(Table *t, TableData *d, bool avoid_uppercas
case TABLE_STRING: case TABLE_STRING:
case TABLE_PATH: case TABLE_PATH:
if (d->uppercase && !avoid_uppercasing) { if (d->uppercase) {
char *p, *q; char *p, *q;
d->formatted = new(char, strlen(d->string) + 1); d->formatted = new(char, strlen(d->string) + 1);
@ -1602,7 +1602,7 @@ static int table_data_requested_width_height(
const char *t; const char *t;
int r; int r;
t = table_data_format(table, d, false); t = table_data_format(table, d);
if (!t) if (!t)
return -ENOMEM; return -ENOMEM;
@ -1784,7 +1784,7 @@ int table_print(Table *t, FILE *f) {
* ellipsis. Hence, let's figure out the last line, and account for its * ellipsis. Hence, let's figure out the last line, and account for its
* length plus ellipsis. */ * length plus ellipsis. */
field = table_data_format(t, d, false); field = table_data_format(t, d);
if (!field) if (!field)
return -ENOMEM; return -ENOMEM;
@ -1969,7 +1969,7 @@ int table_print(Table *t, FILE *f) {
assert_se(d = row[t->display_map ? t->display_map[j] : j]); assert_se(d = row[t->display_map ? t->display_map[j] : j]);
field = table_data_format(t, d, false); field = table_data_format(t, d);
if (!field) if (!field)
return -ENOMEM; return -ENOMEM;
@ -2256,24 +2256,6 @@ static int table_data_to_json(TableData *d, JsonVariant **ret) {
} }
} }
static char* string_to_json_field_name(const char *f) {
char *c, *x;
/* Tries to make a string more suitable as JSON field name. There are no strict rules defined what a
* field name can be hence this is a bit vague and black magic. Right now we only convert spaces to
* underscores and leave everything as is. */
c = strdup(f);
if (!c)
return NULL;
for (x = c; *x; x++)
if (isspace(*x))
*x = '_';
return c;
}
int table_to_json(Table *t, JsonVariant **ret) { int table_to_json(Table *t, JsonVariant **ret) {
JsonVariant **rows = NULL, **elements = NULL; JsonVariant **rows = NULL, **elements = NULL;
_cleanup_free_ size_t *sorted = NULL; _cleanup_free_ size_t *sorted = NULL;
@ -2316,27 +2298,11 @@ int table_to_json(Table *t, JsonVariant **ret) {
} }
for (j = 0; j < display_columns; j++) { for (j = 0; j < display_columns; j++) {
_cleanup_free_ char *mangled = NULL;
const char *formatted;
TableData *d; TableData *d;
assert_se(d = t->data[t->display_map ? t->display_map[j] : j]); assert_se(d = t->data[t->display_map ? t->display_map[j] : j]);
/* Field names must be strings, hence format whatever we got here as a string first */ r = table_data_to_json(d, elements + j*2);
formatted = table_data_format(t, d, true);
if (!formatted) {
r = -ENOMEM;
goto finish;
}
/* Arbitrary strings suck as field names, try to mangle them into something more suitable hence */
mangled = string_to_json_field_name(formatted);
if (!mangled) {
r = -ENOMEM;
goto finish;
}
r = json_variant_new_string(elements + j*2, mangled);
if (r < 0) if (r < 0)
goto finish; goto finish;
} }

View File

@ -131,7 +131,7 @@ static int field_set_test(Set *fields, const char *name, size_t n) {
if (!s) if (!s)
return log_oom(); return log_oom();
return set_contains(fields, s); return set_get(fields, s) ? 1 : 0;
} }
static bool shall_print(const char *p, size_t l, OutputFlags flags) { static bool shall_print(const char *p, size_t l, OutputFlags flags) {
@ -158,7 +158,7 @@ static bool print_multiline(
bool audit, bool audit,
const char* message, const char* message,
size_t message_len, size_t message_len,
size_t highlight[static 2]) { size_t highlight[2]) {
const char *color_on = "", *color_off = "", *highlight_on = ""; const char *color_on = "", *color_off = "", *highlight_on = "";
const char *pos, *end; const char *pos, *end;
@ -370,7 +370,7 @@ static int output_short(
unsigned n_columns, unsigned n_columns,
OutputFlags flags, OutputFlags flags,
Set *output_fields, Set *output_fields,
const size_t highlight[static 2]) { const size_t highlight[2]) {
int r; int r;
const void *data; const void *data;
@ -534,7 +534,7 @@ static int output_verbose(
unsigned n_columns, unsigned n_columns,
OutputFlags flags, OutputFlags flags,
Set *output_fields, Set *output_fields,
const size_t highlight[static 2]) { const size_t highlight[2]) {
const void *data; const void *data;
size_t length; size_t length;
@ -653,7 +653,7 @@ static int output_export(
unsigned n_columns, unsigned n_columns,
OutputFlags flags, OutputFlags flags,
Set *output_fields, Set *output_fields,
const size_t highlight[static 2]) { const size_t highlight[2]) {
sd_id128_t boot_id; sd_id128_t boot_id;
char sid[SD_ID128_STRING_MAX]; char sid[SD_ID128_STRING_MAX];
@ -883,7 +883,7 @@ static int output_json(
unsigned n_columns, unsigned n_columns,
OutputFlags flags, OutputFlags flags,
Set *output_fields, Set *output_fields,
const size_t highlight[static 2]) { const size_t highlight[2]) {
char sid[SD_ID128_STRING_MAX], usecbuf[DECIMAL_STR_MAX(usec_t)]; char sid[SD_ID128_STRING_MAX], usecbuf[DECIMAL_STR_MAX(usec_t)];
_cleanup_(json_variant_unrefp) JsonVariant *object = NULL; _cleanup_(json_variant_unrefp) JsonVariant *object = NULL;
@ -1016,57 +1016,6 @@ finish:
return r; return r;
} }
static int output_cat_field(
FILE *f,
sd_journal *j,
OutputFlags flags,
const char *field,
const size_t highlight[static 2]) {
const char *highlight_on, *highlight_off;
const void *data;
size_t l, fl;
int r;
if (FLAGS_SET(flags, OUTPUT_COLOR)) {
highlight_on = ANSI_HIGHLIGHT_RED;
highlight_off = ANSI_NORMAL;
} else
highlight_on = highlight_off = "";
r = sd_journal_get_data(j, field, &data, &l);
if (r == -EBADMSG) {
log_debug_errno(r, "Skipping message we can't read: %m");
return 0;
}
if (r == -ENOENT) /* An entry without the requested field */
return 0;
if (r < 0)
return log_error_errno(r, "Failed to get data: %m");
fl = strlen(field);
assert(l >= fl + 1);
assert(((char*) data)[fl] == '=');
data = (const uint8_t*) data + fl + 1;
l -= fl + 1;
if (highlight && FLAGS_SET(flags, OUTPUT_COLOR)) {
assert(highlight[0] <= highlight[1]);
assert(highlight[1] <= l);
fwrite((const char*) data, 1, highlight[0], f);
fwrite(highlight_on, 1, strlen(highlight_on), f);
fwrite((const char*) data + highlight[0], 1, highlight[1] - highlight[0], f);
fwrite(highlight_off, 1, strlen(highlight_off), f);
fwrite((const char*) data + highlight[1], 1, l - highlight[1], f);
} else
fwrite((const char*) data, 1, l, f);
fputc('\n', f);
return 0;
}
static int output_cat( static int output_cat(
FILE *f, FILE *f,
sd_journal *j, sd_journal *j,
@ -1074,26 +1023,51 @@ static int output_cat(
unsigned n_columns, unsigned n_columns,
OutputFlags flags, OutputFlags flags,
Set *output_fields, Set *output_fields,
const size_t highlight[static 2]) { const size_t highlight[2]) {
const char *field; const void *data;
Iterator iterator; size_t l;
int r; int r;
const char *highlight_on = "", *highlight_off = "";
assert(j); assert(j);
assert(f); assert(f);
(void) sd_journal_set_data_threshold(j, 0); if (flags & OUTPUT_COLOR) {
highlight_on = ANSI_HIGHLIGHT_RED;
if (set_isempty(output_fields)) highlight_off = ANSI_NORMAL;
return output_cat_field(f, j, flags, "MESSAGE", highlight);
SET_FOREACH(field, output_fields, iterator) {
r = output_cat_field(f, j, flags, field, streq(field, "MESSAGE") ? highlight : NULL);
if (r < 0)
return r;
} }
sd_journal_set_data_threshold(j, 0);
r = sd_journal_get_data(j, "MESSAGE", &data, &l);
if (r == -EBADMSG) {
log_debug_errno(r, "Skipping message we can't read: %m");
return 0;
}
if (r < 0) {
/* An entry without MESSAGE=? */
if (r == -ENOENT)
return 0;
return log_error_errno(r, "Failed to get data: %m");
}
assert(l >= 8);
if (highlight && (flags & OUTPUT_COLOR)) {
assert(highlight[0] <= highlight[1]);
assert(highlight[1] <= l - 8);
fwrite((const char*) data + 8, 1, highlight[0], f);
fwrite(highlight_on, 1, strlen(highlight_on), f);
fwrite((const char*) data + 8 + highlight[0], 1, highlight[1] - highlight[0], f);
fwrite(highlight_off, 1, strlen(highlight_off), f);
fwrite((const char*) data + 8 + highlight[1], 1, l - 8 - highlight[1], f);
} else
fwrite((const char*) data + 8, 1, l - 8, f);
fputc('\n', f);
return 0; return 0;
} }
@ -1104,7 +1078,7 @@ static int (*output_funcs[_OUTPUT_MODE_MAX])(
unsigned n_columns, unsigned n_columns,
OutputFlags flags, OutputFlags flags,
Set *output_fields, Set *output_fields,
const size_t highlight[static 2]) = { const size_t highlight[2]) = {
[OUTPUT_SHORT] = output_short, [OUTPUT_SHORT] = output_short,
[OUTPUT_SHORT_ISO] = output_short, [OUTPUT_SHORT_ISO] = output_short,
@ -1130,7 +1104,7 @@ int show_journal_entry(
unsigned n_columns, unsigned n_columns,
OutputFlags flags, OutputFlags flags,
char **output_fields, char **output_fields,
const size_t highlight[static 2], const size_t highlight[2],
bool *ellipsized) { bool *ellipsized) {
int ret; int ret;

View File

@ -20,7 +20,7 @@ int show_journal_entry(
unsigned n_columns, unsigned n_columns,
OutputFlags flags, OutputFlags flags,
char **output_fields, char **output_fields,
const size_t highlight[static 2], const size_t highlight[2],
bool *ellipsized); bool *ellipsized);
int show_journal( int show_journal(
FILE *f, FILE *f,

View File

@ -525,7 +525,7 @@ int main(int argc, char *argv[]) {
} }
if (need_umount || need_swapoff || need_loop_detach || need_dm_detach) if (need_umount || need_swapoff || need_loop_detach || need_dm_detach)
log_error("Failed to finalize%s%s%s%s ignoring.", log_error("Failed to finalize %s%s%s%s ignoring",
need_umount ? " file systems," : "", need_umount ? " file systems," : "",
need_swapoff ? " swap devices," : "", need_swapoff ? " swap devices," : "",
need_loop_detach ? " loop devices," : "", need_loop_detach ? " loop devices," : "",

View File

@ -390,21 +390,6 @@ static bool output_show_unit(const UnitInfo *u, char **patterns) {
return true; return true;
} }
static int output_table(Table *table) {
int r;
assert(table);
if (OUTPUT_MODE_IS_JSON(arg_output))
r = table_print_json(table, NULL, output_mode_to_json_format_flags(arg_output) | JSON_FORMAT_COLOR_AUTO);
else
r = table_print(table, NULL);
if (r < 0)
return log_error_errno(r, "Failed to show table: %m");
return 0;
}
static int output_units_list(const UnitInfo *unit_infos, unsigned c) { static int output_units_list(const UnitInfo *unit_infos, unsigned c) {
_cleanup_(table_unrefp) Table *table = NULL; _cleanup_(table_unrefp) Table *table = NULL;
const UnitInfo *u; const UnitInfo *u;
@ -488,9 +473,9 @@ static int output_units_list(const UnitInfo *unit_infos, unsigned c) {
return log_error_errno(r, "Failed to hide column: %m"); return log_error_errno(r, "Failed to hide column: %m");
} }
r = output_table(table); r = table_print(table, NULL);
if (r < 0) if (r < 0)
return r; return log_error_errno(r, "Failed to print the table: %m");
if (!arg_no_legend) { if (!arg_no_legend) {
const char *on, *off; const char *on, *off;
@ -1054,9 +1039,9 @@ static int output_sockets_list(struct socket_info *socket_infos, unsigned cs) {
off = ansi_normal(); off = ansi_normal();
} }
r = output_table(table); r = table_print(table, NULL);
if (r < 0) if (r < 0)
return r; return log_error_errno(r, "Failed to print the table: %m");
if (!arg_no_legend) { if (!arg_no_legend) {
printf("\n%s%u sockets listed.%s\n", on, cs, off); printf("\n%s%u sockets listed.%s\n", on, cs, off);
@ -1300,9 +1285,9 @@ static int output_timers_list(struct timer_info *timer_infos, unsigned n) {
off = ansi_normal(); off = ansi_normal();
} }
r = output_table(table); r = table_print(table, NULL);
if (r < 0) if (r < 0)
return r; return log_error_errno(r, "Failed to print the table: %m");
if (!arg_no_legend) { if (!arg_no_legend) {
printf("\n%s%u timers listed.%s\n", on, n, off); printf("\n%s%u timers listed.%s\n", on, n, off);
@ -1516,9 +1501,9 @@ static int output_unit_file_list(const UnitFileList *units, unsigned c) {
return table_log_add_error(r); return table_log_add_error(r);
} }
r = output_table(table); r = table_print(table, NULL);
if (r < 0) if (r < 0)
return r; return log_error_errno(r, "Failed to print the table: %m");
if (!arg_no_legend) if (!arg_no_legend)
printf("\n%u unit files listed.\n", c); printf("\n%u unit files listed.\n", c);
@ -2048,9 +2033,9 @@ static int output_machines_list(struct machine_info *machine_infos, unsigned n)
return table_log_add_error(r); return table_log_add_error(r);
} }
r = output_table(table); r = table_print(table, NULL);
if (r < 0) if (r < 0)
return r; return log_error_errno(r, "Failed to print the table: %m");
if (!arg_no_legend) { if (!arg_no_legend) {
printf("\n"); printf("\n");
@ -8616,11 +8601,6 @@ static int systemctl_parse_argv(int argc, char *argv[]) {
return log_error_errno(SYNTHETIC_ERRNO(EINVAL), return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
"Unknown output '%s'.", "Unknown output '%s'.",
optarg); optarg);
if (OUTPUT_MODE_IS_JSON(arg_output)) {
arg_no_legend = true;
arg_plain = true;
}
break; break;
case 'i': case 'i':