X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Fsd-daemon.c;h=5df70e38d524d2f5866c31f54eb84e854761d941;hb=71a6f7538199f571b92e0c9fbb5819f8ce0e0d20;hp=e6b9a6f3c217ca2fff601929627ac4cb648c98f4;hpb=08bfb8106b3a337ebf9a4bf3a8ddd2e494d18b48;p=elogind.git diff --git a/src/sd-daemon.c b/src/sd-daemon.c index e6b9a6f3c..5df70e38d 100644 --- a/src/sd-daemon.c +++ b/src/sd-daemon.c @@ -141,7 +141,7 @@ int sd_is_fifo(int fd, const char *path) { struct stat st_path; memset(&st_path, 0, sizeof(st_path)); - if (fstat(fd, &st_path) < 0) { + if (stat(path, &st_path) < 0) { if (errno == ENOENT || errno == ENOTDIR) return 0; @@ -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 +}