]>
Commit | Line | Data |
---|---|---|
f9378423 LP |
1 | <?xml version='1.0'?> <!--*-nxml-*--> |
2 | <!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN" | |
3 | "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd"> | |
4 | ||
5 | <!-- | |
6 | This file is part of systemd. | |
7 | ||
8 | Copyright 2010 Lennart Poettering | |
9 | ||
10 | systemd is free software; you can redistribute it and/or modify it | |
5430f7f2 LP |
11 | under the terms of the GNU Lesser General Public License as published by |
12 | the Free Software Foundation; either version 2.1 of the License, or | |
f9378423 LP |
13 | (at your option) any later version. |
14 | ||
15 | systemd is distributed in the hope that it will be useful, but | |
16 | WITHOUT ANY WARRANTY; without even the implied warranty of | |
17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
5430f7f2 | 18 | Lesser General Public License for more details. |
f9378423 | 19 | |
5430f7f2 | 20 | You should have received a copy of the GNU Lesser General Public License |
f9378423 LP |
21 | along with systemd; If not, see <http://www.gnu.org/licenses/>. |
22 | --> | |
23 | ||
24 | <refentry id="sd_booted"> | |
25 | ||
26 | <refentryinfo> | |
27 | <title>sd_booted</title> | |
28 | <productname>systemd</productname> | |
29 | ||
30 | <authorgroup> | |
31 | <author> | |
32 | <contrib>Developer</contrib> | |
33 | <firstname>Lennart</firstname> | |
34 | <surname>Poettering</surname> | |
35 | <email>lennart@poettering.net</email> | |
36 | </author> | |
37 | </authorgroup> | |
38 | </refentryinfo> | |
39 | ||
40 | <refmeta> | |
41 | <refentrytitle>sd_booted</refentrytitle> | |
42 | <manvolnum>3</manvolnum> | |
43 | </refmeta> | |
44 | ||
45 | <refnamediv> | |
46 | <refname>sd_booted</refname> | |
47 | <refpurpose>Test whether the system is running the systemd init system.</refpurpose> | |
48 | </refnamediv> | |
49 | ||
50 | <refsynopsisdiv> | |
51 | <funcsynopsis> | |
a822cbfa | 52 | <funcsynopsisinfo>#include <systemd/sd-daemon.h></funcsynopsisinfo> |
f9378423 LP |
53 | |
54 | <funcprototype> | |
55 | <funcdef>int <function>sd_booted</function></funcdef> | |
56 | <paramdef>void</paramdef> | |
57 | </funcprototype> | |
58 | </funcsynopsis> | |
59 | </refsynopsisdiv> | |
60 | ||
61 | <refsect1> | |
62 | <title>Description</title> | |
63 | <para><function>sd_booted()</function> checks whether | |
64 | the system was booted up using the systemd init system.</para> | |
65 | </refsect1> | |
66 | ||
67 | <refsect1> | |
68 | <title>Return Value</title> | |
69 | ||
70 | <para>On failure, this call returns a negative | |
71 | errno-style error code. If the system was booted up | |
af62c704 | 72 | with systemd as init system, this call returns a |
436c44a5 | 73 | positive return value, zero otherwise.</para> |
f9378423 LP |
74 | </refsect1> |
75 | ||
76 | <refsect1> | |
77 | <title>Notes</title> | |
78 | ||
79 | <para>This function is provided by the reference | |
80 | implementation of APIs for new-style daemons and | |
81 | distributed with the systemd package. The algorithm it | |
82 | implements is simple, and can easily be reimplemented | |
83 | in daemons if it is important to support this | |
84 | interface without using the reference | |
85 | implementation.</para> | |
86 | ||
87 | <para>Internally, this function checks whether the | |
77d5f105 | 88 | <filename>/sys/fs/cgroup/systemd</filename> virtual file |
f9378423 LP |
89 | system is mounted, by comparing the st_dev value of |
90 | the <function>stat()</function> data of | |
77d5f105 LP |
91 | <filename>/sys/fs/cgroup</filename> and |
92 | <filename>/sys/fs/cgroup/systemd</filename>.</para> | |
f9378423 LP |
93 | |
94 | <para>For details about the algorithm check the | |
95 | liberally licensed reference implementation sources: | |
a26c9cc6 | 96 | <ulink url="http://cgit.freedesktop.org/systemd/systemd/plain/src/sd-daemon.c"/> |
f9378423 | 97 | resp. <ulink |
a26c9cc6 | 98 | url="http://cgit.freedesktop.org/systemd/systemd/plain/src/systemd/sd-daemon.h"/></para> |
f9378423 LP |
99 | |
100 | <para><function>sd_booted()</function> is implemented | |
71e6c1cf | 101 | in the reference implementation's |
f9378423 | 102 | <filename>sd-daemon.c</filename> and |
71e6c1cf LP |
103 | <filename>sd-daemon.h</filename> files. These |
104 | interfaces are available as shared library, which can | |
105 | be compiled and linked to with the | |
106 | <literal>libsystemd-daemon</literal> | |
107 | <citerefentry><refentrytitle>pkg-config</refentrytitle><manvolnum>1</manvolnum></citerefentry> | |
108 | file. Alternatively, applications consuming these APIs | |
109 | may copy the implementation into their source | |
110 | tree. For more details about the reference | |
111 | implementation see | |
112 | <citerefentry><refentrytitle>sd_daemon</refentrytitle><manvolnum>7</manvolnum></citerefentry>.</para> | |
113 | ||
114 | <para>If the reference implementation is used as | |
115 | drop-in files and -DDISABLE_SYSTEMD is set during | |
116 | compilation this function will always return 0 and | |
117 | otherwise become a NOP.</para> | |
f9378423 LP |
118 | </refsect1> |
119 | ||
120 | <refsect1> | |
121 | <title>See Also</title> | |
122 | <para> | |
160cd5c9 LP |
123 | <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>, |
124 | <citerefentry><refentrytitle>sd_daemon</refentrytitle><manvolnum>7</manvolnum></citerefentry> | |
f9378423 LP |
125 | </para> |
126 | </refsect1> | |
127 | ||
128 | </refentry> |