mirror of
https://github.com/systemd/systemd.git
synced 2025-03-21 02:50:18 +03:00
Merge pull request #8562 from keszybz/docs
Man page and log message fixes
This commit is contained in:
commit
12b6b3b7a4
14
man/.dir-locals.el
Normal file
14
man/.dir-locals.el
Normal file
@ -0,0 +1,14 @@
|
||||
; special .c mode with reduced indentation for man pages
|
||||
((nil . ((indent-tabs-mode . nil)
|
||||
(tab-width . 8)
|
||||
(fill-column . 79)))
|
||||
(c-mode . ((fill-column . 80)
|
||||
(c-basic-offset . 2)
|
||||
(eval . (c-set-offset 'substatement-open 0))
|
||||
(eval . (c-set-offset 'statement-case-open 0))
|
||||
(eval . (c-set-offset 'case-label 0))
|
||||
(eval . (c-set-offset 'arglist-intro '++))
|
||||
(eval . (c-set-offset 'arglist-close 0))))
|
||||
(nxml-mode . ((nxml-child-indent . 2)
|
||||
(fill-column . 119)))
|
||||
(meson-mode . ((meson-indent-basic . 8))))
|
@ -1,70 +1,49 @@
|
||||
/***
|
||||
SPDX-License-Identifier: MIT
|
||||
|
||||
Copyright 2014 Tom Gundersen
|
||||
|
||||
Permission is hereby granted, free of charge, to any person
|
||||
obtaining a copy of this software and associated documentation files
|
||||
(the "Software"), to deal in the Software without restriction,
|
||||
including without limitation the rights to use, copy, modify, merge,
|
||||
publish, distribute, sublicense, and/or sell copies of the Software,
|
||||
and to permit persons to whom the Software is furnished to do so,
|
||||
subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
|
||||
BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
||||
ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
***/
|
||||
/* SPDX-License-Identifier: MIT */
|
||||
/* Copyright 2014 Tom Gundersen */
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <glib.h>
|
||||
#include <systemd/sd-event.h>
|
||||
|
||||
typedef struct SDEventSource {
|
||||
GSource source;
|
||||
GPollFD pollfd;
|
||||
sd_event *event;
|
||||
GSource source;
|
||||
GPollFD pollfd;
|
||||
sd_event *event;
|
||||
} SDEventSource;
|
||||
|
||||
static gboolean event_prepare(GSource *source, gint *timeout_) {
|
||||
return sd_event_prepare(((SDEventSource *)source)->event) > 0;
|
||||
return sd_event_prepare(((SDEventSource *)source)->event) > 0;
|
||||
}
|
||||
|
||||
static gboolean event_check(GSource *source) {
|
||||
return sd_event_wait(((SDEventSource *)source)->event, 0) > 0;
|
||||
return sd_event_wait(((SDEventSource *)source)->event, 0) > 0;
|
||||
}
|
||||
|
||||
static gboolean event_dispatch(GSource *source, GSourceFunc callback, gpointer user_data) {
|
||||
return sd_event_dispatch(((SDEventSource *)source)->event) > 0;
|
||||
return sd_event_dispatch(((SDEventSource *)source)->event) > 0;
|
||||
}
|
||||
|
||||
static void event_finalize(GSource *source) {
|
||||
sd_event_unref(((SDEventSource *)source)->event);
|
||||
sd_event_unref(((SDEventSource *)source)->event);
|
||||
}
|
||||
|
||||
static GSourceFuncs event_funcs = {
|
||||
.prepare = event_prepare,
|
||||
.check = event_check,
|
||||
.dispatch = event_dispatch,
|
||||
.finalize = event_finalize,
|
||||
.prepare = event_prepare,
|
||||
.check = event_check,
|
||||
.dispatch = event_dispatch,
|
||||
.finalize = event_finalize,
|
||||
};
|
||||
|
||||
GSource *g_sd_event_create_source(sd_event *event) {
|
||||
SDEventSource *source;
|
||||
SDEventSource *source;
|
||||
|
||||
source = (SDEventSource *)g_source_new(&event_funcs, sizeof(SDEventSource));
|
||||
source = (SDEventSource *)g_source_new(&event_funcs, sizeof(SDEventSource));
|
||||
|
||||
source->event = sd_event_ref(event);
|
||||
source->pollfd.fd = sd_event_get_fd(event);
|
||||
source->pollfd.events = G_IO_IN | G_IO_HUP | G_IO_ERR;
|
||||
source->event = sd_event_ref(event);
|
||||
source->pollfd.fd = sd_event_get_fd(event);
|
||||
source->pollfd.events = G_IO_IN | G_IO_HUP | G_IO_ERR;
|
||||
|
||||
g_source_add_poll((GSource *)source, &source->pollfd);
|
||||
g_source_add_poll((GSource *)source, &source->pollfd);
|
||||
|
||||
return (GSource *)source;
|
||||
return (GSource *)source;
|
||||
}
|
||||
|
25
man/journal-iterate-poll.c
Normal file
25
man/journal-iterate-poll.c
Normal file
@ -0,0 +1,25 @@
|
||||
#include <poll.h>
|
||||
#include <time.h>
|
||||
#include <systemd/sd-journal.h>
|
||||
|
||||
int wait_for_changes(sd_journal *j) {
|
||||
uint64_t t;
|
||||
int msec;
|
||||
struct pollfd pollfd;
|
||||
|
||||
sd_journal_get_timeout(j, &t);
|
||||
if (t == (uint64_t) -1)
|
||||
msec = -1;
|
||||
else {
|
||||
struct timespec ts;
|
||||
uint64_t n;
|
||||
clock_gettime(CLOCK_MONOTONIC, &ts);
|
||||
n = (uint64_t) ts.tv_sec * 1000000 + ts.tv_nsec / 1000;
|
||||
msec = t > n ? (int) ((t - n + 999) / 1000) : 0;
|
||||
}
|
||||
|
||||
pollfd.fd = sd_journal_get_fd(j);
|
||||
pollfd.events = sd_journal_get_events(j);
|
||||
poll(&pollfd, 1, msec);
|
||||
return sd_journal_process(j);
|
||||
}
|
39
man/journal-iterate-wait.c
Normal file
39
man/journal-iterate-wait.c
Normal file
@ -0,0 +1,39 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <systemd/sd-journal.h>
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
int r;
|
||||
sd_journal *j;
|
||||
r = sd_journal_open(&j, SD_JOURNAL_LOCAL_ONLY);
|
||||
if (r < 0) {
|
||||
fprintf(stderr, "Failed to open journal: %s\n", strerror(-r));
|
||||
return 1;
|
||||
}
|
||||
for (;;) {
|
||||
const void *d;
|
||||
size_t l;
|
||||
r = sd_journal_next(j);
|
||||
if (r < 0) {
|
||||
fprintf(stderr, "Failed to iterate to next entry: %s\n", strerror(-r));
|
||||
break;
|
||||
}
|
||||
if (r == 0) {
|
||||
/* Reached the end, let's wait for changes, and try again */
|
||||
r = sd_journal_wait(j, (uint64_t) -1);
|
||||
if (r < 0) {
|
||||
fprintf(stderr, "Failed to wait for changes: %s\n", strerror(-r));
|
||||
break;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
r = sd_journal_get_data(j, "MESSAGE", &d, &l);
|
||||
if (r < 0) {
|
||||
fprintf(stderr, "Failed to read message field: %s\n", strerror(-r));
|
||||
continue;
|
||||
}
|
||||
printf("%.*s\n", (int) l, (const char*) d);
|
||||
}
|
||||
sd_journal_close(j);
|
||||
return 0;
|
||||
}
|
@ -752,7 +752,7 @@
|
||||
<term><option>--vacuum-time=</option></term>
|
||||
<term><option>--vacuum-files=</option></term>
|
||||
|
||||
<listitem><para>Removes archived journal files until the disk
|
||||
<listitem><para>Removes the oldest archived journal files until the disk
|
||||
space they use falls below the specified size (specified with
|
||||
the usual <literal>K</literal>, <literal>M</literal>,
|
||||
<literal>G</literal> and <literal>T</literal> suffixes), or all
|
||||
@ -930,7 +930,8 @@
|
||||
<para>With one match specified, all entries with a field matching
|
||||
the expression are shown:</para>
|
||||
|
||||
<programlisting>journalctl _SYSTEMD_UNIT=avahi-daemon.service</programlisting>
|
||||
<programlisting>journalctl _SYSTEMD_UNIT=avahi-daemon.service
|
||||
journalctl _SYSTEMD_CGROUP=/user.slice/user-42.slice/session-c1.scope</programlisting>
|
||||
|
||||
<para>If two different fields are matched, only entries matching
|
||||
both expressions at the same time are shown:</para>
|
||||
@ -950,6 +951,19 @@
|
||||
|
||||
<programlisting>journalctl _SYSTEMD_UNIT=avahi-daemon.service _PID=28097 + _SYSTEMD_UNIT=dbus.service</programlisting>
|
||||
|
||||
<para>To show all fields emited <emphasis>by</emphasis> a unit and <emphasis>about</emphasis>
|
||||
the unit, option <option>-u</option>/<option>--unit=</option> should be used.
|
||||
<command>journalctl -u <replaceable>name</replaceable></command>
|
||||
expands to a complex filter similar to
|
||||
<programlisting>_SYSTEMD_UNIT=<replaceable>name</replaceable>.service
|
||||
+ UNIT=<replaceable>name</replaceable>.service _PID=1
|
||||
+ OBJECT_SYSTEMD_UNIT=<replaceable>name</replaceable>.service _UID=0
|
||||
+ COREDUMP_UNIT=<replaceable>name</replaceable>.service _UID=0 MESSAGE_ID=fc2e22bc6ee647b6b90729ab34a250b1
|
||||
</programlisting>
|
||||
(see <citerefentry><refentrytitle>systemd.journal-fields</refentrytitle><manvolnum>5</manvolnum></citerefentry>
|
||||
for an explanation of those patterns).
|
||||
</para>
|
||||
|
||||
<para>Show all logs generated by the D-Bus executable:</para>
|
||||
|
||||
<programlisting>journalctl /usr/bin/dbus-daemon</programlisting>
|
||||
|
@ -255,8 +255,11 @@
|
||||
for, if any. (Only applies to seats with a VT available, such
|
||||
as <literal>seat0</literal>)</para></listitem>
|
||||
</varlistentry>
|
||||
|
||||
</variablelist>
|
||||
|
||||
<para>If not set, <command>pam_systemd</command> will determine the
|
||||
values for <varname>$XDG_SEAT</varname> and <varname>$XDG_VTNR</varname>
|
||||
based on the <varname>$DISPLAY</varname> variable.</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1>
|
||||
|
@ -23,7 +23,7 @@
|
||||
along with systemd; If not, see <http://www.gnu.org/licenses/>.
|
||||
-->
|
||||
|
||||
<refentry id="sd_journal_get_fd">
|
||||
<refentry id="sd_journal_get_fd" xmlns:xi="http://www.w3.org/2001/XInclude">
|
||||
|
||||
<refentryinfo>
|
||||
<title>sd_journal_get_fd</title>
|
||||
@ -263,73 +263,13 @@ else {
|
||||
<para>Iterating through the journal, in a live view tracking all
|
||||
changes:</para>
|
||||
|
||||
<programlisting>#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <systemd/sd-journal.h>
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
int r;
|
||||
sd_journal *j;
|
||||
r = sd_journal_open(&j, SD_JOURNAL_LOCAL_ONLY);
|
||||
if (r < 0) {
|
||||
fprintf(stderr, "Failed to open journal: %s\n", strerror(-r));
|
||||
return 1;
|
||||
}
|
||||
for (;;) {
|
||||
const void *d;
|
||||
size_t l;
|
||||
r = sd_journal_next(j);
|
||||
if (r < 0) {
|
||||
fprintf(stderr, "Failed to iterate to next entry: %s\n", strerror(-r));
|
||||
break;
|
||||
}
|
||||
if (r == 0) {
|
||||
/* Reached the end, let's wait for changes, and try again */
|
||||
r = sd_journal_wait(j, (uint64_t) -1);
|
||||
if (r < 0) {
|
||||
fprintf(stderr, "Failed to wait for changes: %s\n", strerror(-r));
|
||||
break;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
r = sd_journal_get_data(j, "MESSAGE", &d, &l);
|
||||
if (r < 0) {
|
||||
fprintf(stderr, "Failed to read message field: %s\n", strerror(-r));
|
||||
continue;
|
||||
}
|
||||
printf("%.*s\n", (int) l, (const char*) d);
|
||||
}
|
||||
sd_journal_close(j);
|
||||
return 0;
|
||||
}</programlisting>
|
||||
<programlisting><xi:include href="journal-iterate-wait.c" parse="text" /></programlisting>
|
||||
|
||||
<para>Waiting with <function>poll()</function> (this
|
||||
example lacks all error checking for the sake of
|
||||
simplicity):</para>
|
||||
|
||||
<programlisting>#include <poll.h>
|
||||
#include <systemd/sd-journal.h>
|
||||
|
||||
int wait_for_changes(sd_journal *j) {
|
||||
struct pollfd pollfd;
|
||||
int msec;
|
||||
|
||||
sd_journal_get_timeout(m, &t);
|
||||
if (t == (uint64_t) -1)
|
||||
msec = -1;
|
||||
else {
|
||||
struct timespec ts;
|
||||
uint64_t n;
|
||||
clock_gettime(CLOCK_MONOTONIC, &ts);
|
||||
n = (uint64_t) ts.tv_sec * 1000000 + ts.tv_nsec / 1000;
|
||||
msec = t > n ? (int) ((t - n + 999) / 1000) : 0;
|
||||
}
|
||||
|
||||
pollfd.fd = sd_journal_get_fd(j);
|
||||
pollfd.events = sd_journal_get_events(j);
|
||||
poll(&pollfd, 1, msec);
|
||||
return sd_journal_process(j);
|
||||
}</programlisting>
|
||||
<programlisting><xi:include href="journal-iterate-poll.c" parse="text" /></programlisting>
|
||||
</refsect1>
|
||||
|
||||
<refsect1>
|
||||
|
@ -62,8 +62,9 @@
|
||||
generator that automatically discovers root,
|
||||
<filename>/home</filename>, <filename>/srv</filename> and swap
|
||||
partitions and creates mount and swap units for them, based on the
|
||||
partition type GUIDs of GUID partition tables (GPT). It implements
|
||||
the <ulink
|
||||
partition type GUIDs of GUID partition tables (GPT),
|
||||
see <ulink url="http://www.uefi.org/specifications">UEFI Specification</ulink>, chapter 5.
|
||||
It implements the <ulink
|
||||
url="https://www.freedesktop.org/wiki/Specifications/DiscoverablePartitionsSpec/">Discoverable
|
||||
Partitions Specification</ulink>. Note that this generator has no
|
||||
effect on non-GPT systems, or where the directories under the
|
||||
@ -78,13 +79,13 @@
|
||||
same physical disk the EFI System Partition (ESP) is located on.
|
||||
It will only look for the other partitions on the same physical
|
||||
disk the root file system is located on. These partitions will not
|
||||
be searched on systems where the root file system is distributed
|
||||
be searched for on systems where the root file system is distributed
|
||||
on multiple disks, for example via btrfs RAID.</para>
|
||||
|
||||
<para><filename>systemd-gpt-auto-generator</filename> is useful
|
||||
for centralizing file system configuration in the partition table
|
||||
and making manual configuration in <filename>/etc/fstab</filename>
|
||||
or suchlike unnecessary.</para>
|
||||
and making configuration in <filename>/etc/fstab</filename> unnecessary.
|
||||
</para>
|
||||
|
||||
<para>This generator looks for the partitions based on their
|
||||
partition type GUID. The following partition type GUIDs are
|
||||
@ -153,6 +154,48 @@
|
||||
</tgroup>
|
||||
</table>
|
||||
|
||||
<para>This generator understands the following attribute flags for partitions:</para>
|
||||
|
||||
<table>
|
||||
<title>Partition Attributes</title>
|
||||
<tgroup cols='4' align='left' colsep='1' rowsep='1'>
|
||||
<colspec colname="attribute" />
|
||||
<colspec colname="value" />
|
||||
<colspec colname="where" />
|
||||
<colspec colname="explanation" />
|
||||
<thead>
|
||||
<row>
|
||||
<entry>Name</entry>
|
||||
<entry>Value</entry>
|
||||
<entry>Applicable to</entry>
|
||||
<entry>Explanation</entry>
|
||||
</row>
|
||||
</thead>
|
||||
<tbody>
|
||||
<row>
|
||||
<entry><constant>GPT_FLAG_READ_ONLY</constant></entry>
|
||||
<entry>0x1000000000000000</entry>
|
||||
<entry><filename>/</filename>, <filename>/srv</filename>, <filename>/home</filename></entry>
|
||||
<entry>Partition is mounted read-only</entry>
|
||||
</row>
|
||||
|
||||
<row>
|
||||
<entry><constant>GPT_FLAG_NO_AUTO</constant></entry>
|
||||
<entry>0x8000000000000000</entry>
|
||||
<entry><filename>/</filename>, <filename>/srv</filename>, <filename>/home</filename></entry>
|
||||
<entry>Partition is not mounted automatically</entry>
|
||||
</row>
|
||||
|
||||
<row>
|
||||
<entry><constant>GPT_FLAG_NO_BLOCK_IO_PROTOCOL</constant></entry>
|
||||
<entry>0x0000000000000002</entry>
|
||||
<entry>ESP</entry>
|
||||
<entry>Partition is not mounted automatically</entry>
|
||||
</row>
|
||||
</tbody>
|
||||
</tgroup>
|
||||
</table>
|
||||
|
||||
<para>The <filename>/home</filename> and <filename>/srv</filename>
|
||||
partitions may be encrypted in LUKS format. In this case, a device
|
||||
mapper device is set up under the names
|
||||
|
@ -261,9 +261,7 @@ systemd-tmpfiles --create --prefix /var/log/journal</programlisting>
|
||||
<varlistentry>
|
||||
<term><filename>/etc/systemd/journald.conf</filename></term>
|
||||
|
||||
<listitem><para>Configure
|
||||
<command>systemd-journald</command>
|
||||
behavior. See
|
||||
<listitem><para>Configure <command>systemd-journald</command> behavior. See
|
||||
<citerefentry><refentrytitle>journald.conf</refentrytitle><manvolnum>5</manvolnum></citerefentry>.
|
||||
</para></listitem>
|
||||
</varlistentry>
|
||||
@ -274,8 +272,7 @@ systemd-tmpfiles --create --prefix /var/log/journal</programlisting>
|
||||
<term><filename>/var/log/journal/<replaceable>machine-id</replaceable>/*.journal</filename></term>
|
||||
<term><filename>/var/log/journal/<replaceable>machine-id</replaceable>/*.journal~</filename></term>
|
||||
|
||||
<listitem><para><command>systemd-journald</command> writes
|
||||
entries to files in
|
||||
<listitem><para><command>systemd-journald</command> writes entries to files in
|
||||
<filename>/run/log/journal/<replaceable>machine-id</replaceable>/</filename>
|
||||
or
|
||||
<filename>/var/log/journal/<replaceable>machine-id</replaceable>/</filename>
|
||||
@ -287,7 +284,24 @@ systemd-tmpfiles --create --prefix /var/log/journal</programlisting>
|
||||
<filename>/var/log/journal</filename> is not available, or
|
||||
when <option>Storage=volatile</option> is set in the
|
||||
<citerefentry><refentrytitle>journald.conf</refentrytitle><manvolnum>5</manvolnum></citerefentry>
|
||||
configuration file.</para></listitem>
|
||||
configuration file.</para>
|
||||
|
||||
<para>When <filename>systemd-journald</filename> ceases writing to a journal file,
|
||||
it will be renamed to <literal><replaceable>original-name</replaceable>@<replaceable>suffix.journal</replaceable></literal>
|
||||
(or <literal><replaceable>original-name</replaceable>@<replaceable>suffix.journal~</replaceable></literal>).
|
||||
Such files are "archived" and will not be written to any more.</para>
|
||||
|
||||
<para>In general, it is safe to read or copy any journal file (active or archived).
|
||||
<citerefentry><refentrytitle>journalctl</refentrytitle><manvolnum>1</manvolnum></citerefentry>
|
||||
and the functions in the
|
||||
<citerefentry><refentrytitle>sd-journal</refentrytitle><manvolnum>3</manvolnum></citerefentry>
|
||||
library should be able to read all entries that have been fully written.</para>
|
||||
|
||||
<para><filename>systemd-journald</filename> will automatically remove the oldest
|
||||
archived journal files to limit disk use. See <varname>SystemMaxUse=</varname>
|
||||
and related settings in
|
||||
<citerefentry><refentrytitle>journald.conf</refentrytitle><manvolnum>5</manvolnum></citerefentry>.
|
||||
</para></listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
|
@ -519,8 +519,10 @@
|
||||
configured with <option>--network-veth</option>. If this
|
||||
option is specified, the CAP_NET_ADMIN capability will be
|
||||
added to the set of capabilities the container retains. The
|
||||
latter may be disabled by using
|
||||
<option>--drop-capability=</option>.</para></listitem>
|
||||
latter may be disabled by using <option>--drop-capability=</option>.
|
||||
If this option is not specified (or implied by one of the options
|
||||
listed below), the container will have full access to the host network.
|
||||
</para></listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
|
@ -3399,10 +3399,15 @@ static int service_dispatch_timer(sd_event_source *source, usec_t usec, void *us
|
||||
break;
|
||||
|
||||
case SERVICE_AUTO_RESTART:
|
||||
log_unit_info(UNIT(s),
|
||||
s->restart_usec > 0 ?
|
||||
"Service hold-off time over, scheduling restart." :
|
||||
"Service has no hold-off time, scheduling restart.");
|
||||
if (s->restart_usec > 0) {
|
||||
char buf_restart[FORMAT_TIMESPAN_MAX];
|
||||
log_unit_info(UNIT(s),
|
||||
"Service RestartSec=%s expired, scheduling restart.",
|
||||
format_timespan(buf_restart, sizeof buf_restart, s->restart_usec, USEC_PER_SEC));
|
||||
} else
|
||||
log_unit_info(UNIT(s),
|
||||
"Service has no hold-off time (RestartSec=0), scheduling restart.");
|
||||
|
||||
service_enter_restart(s);
|
||||
break;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user