]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
sd-daemon: make sd_booted() return negative errno on unexpected error
authorYu Watanabe <watanabe.yu+github@gmail.com>
Wed, 6 Feb 2019 18:07:34 +0000 (19:07 +0100)
committerLennart Poettering <lennart@poettering.net>
Thu, 7 Feb 2019 13:44:44 +0000 (14:44 +0100)
src/libsystemd/sd-daemon/sd-daemon.c

index 218210f234b49932f344d64fb49db27bf948e9b6..9e8f0a73f57c2825c084bf54163e5f39a844fa98 100644 (file)
@@ -604,7 +604,13 @@ _public_ int sd_booted(void) {
          * created. This takes place in mount-setup.c, so is
          * guaranteed to happen very early during boot. */
 
-        return laccess("/run/systemd/system/", F_OK) >= 0;
+        if (laccess("/run/systemd/system/", F_OK) >= 0)
+                return true;
+
+        if (errno == ENOENT)
+                return false;
+
+        return -errno;
 }
 
 _public_ int sd_watchdog_enabled(int unset_environment, uint64_t *usec) {