]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
sd-daemon: Simplify sd_booted() check
authorLennart Poettering <lennart@poettering.net>
Wed, 23 Sep 2015 15:23:18 +0000 (17:23 +0200)
committerLennart Poettering <lennart@poettering.net>
Tue, 29 Sep 2015 19:55:51 +0000 (21:55 +0200)
We can just use access() to check whether /run/system/system/ is a
directory, no need to involve stat(). The trick is to suffix the path
name with a dash.

src/libsystemd/sd-daemon/sd-daemon.c

index 9ec73406c6b44f2f6713ccc57f26d90c2aafd9d5..ba7b8da85fbbbb2befa7bcb24271d4fed0116b04 100644 (file)
@@ -498,16 +498,11 @@ _public_ int sd_notifyf(int unset_environment, const char *format, ...) {
 }
 
 _public_ int sd_booted(void) {
-        struct stat st;
-
         /* 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("/run/systemd/system/", &st) < 0)
-                return 0;
-
-        return !!S_ISDIR(st.st_mode);
+        return laccess("/run/systemd/system/", F_OK) >= 0;
 }
 
 _public_ int sd_watchdog_enabled(int unset_environment, uint64_t *usec) {