From 09751a7990575307459135befbd102938f13c68b Mon Sep 17 00:00:00 2001 From: Martin Pitt Date: Thu, 21 Mar 2013 09:37:48 +0100 Subject: [PATCH 2/3] Update sd-daemon.[hc] from upstream This fixes sd_booted() to actually mean "have systemd init", which we need for _dbus_init_system_log() to decide whether systemd journal is being used. https://bugs.freedesktop.org/show_bug.cgi?id=62585 --- dbus/sd-daemon.c | 35 ++++++++++++++++------------------- 1 file changed, 16 insertions(+), 19 deletions(-) diff --git a/dbus/sd-daemon.c b/dbus/sd-daemon.c index 80aadf7..79d8ca3 100644 --- a/dbus/sd-daemon.c +++ b/dbus/sd-daemon.c @@ -25,7 +25,7 @@ ***/ #ifndef _GNU_SOURCE -#define _GNU_SOURCE +# define _GNU_SOURCE #endif #include @@ -33,9 +33,9 @@ #include #include #ifdef __BIONIC__ -#include +# include #else -#include +# include #endif #include #include @@ -48,21 +48,21 @@ #include #if defined(__linux__) -#include +# include #endif #include "sd-daemon.h" #if (__GNUC__ >= 4) -#ifdef SD_EXPORT_SYMBOLS +# ifdef SD_EXPORT_SYMBOLS /* Export symbols */ -#define _sd_export_ __attribute__ ((visibility("default"))) -#else +# define _sd_export_ __attribute__ ((visibility("default"))) +# else /* Don't export the symbols */ -#define _sd_export_ __attribute__ ((visibility("hidden"))) -#endif +# define _sd_export_ __attribute__ ((visibility("hidden"))) +# endif #else -#define _sd_export_ +# define _sd_export_ #endif _sd_export_ int sd_listen_fds(int unset_environment) { @@ -519,18 +519,15 @@ _sd_export_ int sd_booted(void) { #if defined(DISABLE_SYSTEMD) || !defined(__linux__) return 0; #else + struct stat st; - struct stat a, b; - - /* We simply test whether the systemd cgroup hierarchy is - * mounted */ - - if (lstat("/sys/fs/cgroup", &a) < 0) - return 0; + /* We test whether the runtime unit file directory has been + * created. This takes place in mount-setup.c, so is + * guaranteed to happen very early during boot. */ - if (lstat("/sys/fs/cgroup/systemd", &b) < 0) + if (lstat("/run/systemd/system/", &st) < 0) return 0; - return a.st_dev != b.st_dev; + return !!S_ISDIR(st.st_mode); #endif } -- 1.8.1.2