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">
6 This file is part of systemd.
8 Copyright 2010 Lennart Poettering
10 systemd is free software; you can redistribute it and/or modify it
11 under the terms of the GNU General Public License as published by
12 the Free Software Foundation; either version 2 of the License, or
13 (at your option) any later version.
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
18 General Public License for more details.
20 You should have received a copy of the GNU General Public License
21 along with systemd; If not, see <http://www.gnu.org/licenses/>.
24 <refentry id="sd_booted">
27 <title>sd_booted</title>
28 <productname>systemd</productname>
32 <contrib>Developer</contrib>
33 <firstname>Lennart</firstname>
34 <surname>Poettering</surname>
35 <email>lennart@poettering.net</email>
41 <refentrytitle>sd_booted</refentrytitle>
42 <manvolnum>3</manvolnum>
46 <refname>sd_booted</refname>
47 <refpurpose>Test whether the system is running the systemd init system.</refpurpose>
52 <funcsynopsisinfo>#include "sd-daemon.h"</funcsynopsisinfo>
55 <funcdef>int <function>sd_booted</function></funcdef>
56 <paramdef>void</paramdef>
62 <title>Description</title>
63 <para><function>sd_booted()</function> checks whether
64 the system was booted up using the systemd init system.</para>
68 <title>Return Value</title>
70 <para>On failure, this call returns a negative
71 errno-style error code. If the system was booted up
72 with systemd as init system, this call returns a
73 positive return value, zero otherwise.</para>
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>
87 <para>Internally, this function checks whether the
88 <filename>/sys/fs/cgroup/systemd</filename> virtual file
89 system is mounted, by comparing the st_dev value of
90 the <function>stat()</function> data of
91 <filename>/sys/fs/cgroup</filename> and
92 <filename>/sys/fs/cgroup/systemd</filename>.</para>
94 <para>For details about the algorithm check the
95 liberally licensed reference implementation sources:
96 <ulink url="http://cgit.freedesktop.org/systemd/tree/src/sd-daemon.c"/>
98 url="http://cgit.freedesktop.org/systemd/tree/src/sd-daemon.h"/></para>
100 <para><function>sd_booted()</function> is implemented
101 in the reference implementation's drop-in
102 <filename>sd-daemon.c</filename> and
103 <filename>sd-daemon.h</filename> files. It is
104 recommended that applications consuming these APIs
105 copy the implementation into their source tree. For
106 more details about the reference implementation see
107 <citerefentry><refentrytitle>sd_daemon</refentrytitle><manvolnum>7</manvolnum></citerefentry></para>
109 <para>If -DDISABLE_SYSTEMD is set during compilation
110 this function will always return 0 and otherwise
115 <title>See Also</title>
117 <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
118 <citerefentry><refentrytitle>sd_daemon</refentrytitle><manvolnum>7</manvolnum></citerefentry>