summaryrefslogtreecommitdiff
path: root/src/sd-daemon.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/sd-daemon.c')
-rw-r--r--src/sd-daemon.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/sd-daemon.c b/src/sd-daemon.c
index e6b9a6f3c2..cb568b5e65 100644
--- a/src/sd-daemon.c
+++ b/src/sd-daemon.c
@@ -426,3 +426,23 @@ int sd_notifyf(int unset_environment, const char *format, ...) {
return r;
#endif
}
+
+int sd_booted(void) {
+#if defined(DISABLE_SYSTEMD) || !defined(__linux__)
+ return 0;
+#else
+
+ struct stat a, b;
+
+ /* We simply test whether the systemd cgroup hierarchy is
+ * mounted */
+
+ if (lstat("/cgroup", &a) < 0)
+ return 0;
+
+ if (lstat("/cgroup/systemd", &b) < 0)
+ return 0;
+
+ return a.st_dev != b.st_dev;
+#endif
+}