X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=blobdiff_plain;f=src%2Fsd-daemon.c;h=cb568b5e65194a08ea088d8bf03e60f7c1095220;hp=0dad73f94d6064e39bad7b84cadf3dea8b3f8b57;hb=bf9a6e8bfc2a03e549e35e72218ed9ad2574a6e2;hpb=8c47c7325fa1ab72febf807f8831ff24c75fbf45 diff --git a/src/sd-daemon.c b/src/sd-daemon.c index 0dad73f94..cb568b5e6 100644 --- a/src/sd-daemon.c +++ b/src/sd-daemon.c @@ -344,10 +344,8 @@ int sd_notify(int unset_environment, const char *state) { goto finish; } - if (!(e = getenv("NOTIFY_SOCKET"))) { - r = 0; - goto finish; - } + if (!(e = getenv("NOTIFY_SOCKET"))) + return 0; /* Must be an abstract socket, or an absolute path */ if ((e[0] != '@' && e[0] != '/') || e[1] == 0) { @@ -394,7 +392,7 @@ int sd_notify(int unset_environment, const char *state) { goto finish; } - r = 0; + r = 1; finish: if (unset_environment) @@ -428,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 +}