chiark / gitweb /
path-lookup: unconditionally check /usr and /usr/share unit directories
[elogind.git] / src / sd-daemon.c
index e6b9a6f3c217ca2fff601929627ac4cb648c98f4..cb568b5e65194a08ea088d8bf03e60f7c1095220 100644 (file)
@@ -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
+}