From: Martin Pitt Date: Thu, 21 Mar 2013 08:37:48 +0000 (+0100) Subject: Update sd-daemon.[hc] from upstream X-Git-Tag: dbus-1.7.2~22 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=751f6783c4e185b05765e7217c782dcb6f0df3e9;p=thirdparty%2Fdbus.git 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. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=62585 Reviewed-by: Simon McVittie --- diff --git a/dbus/sd-daemon.c b/dbus/sd-daemon.c index 80aadf7ad..79d8ca370 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 }