From 31021ba0853d40ffdd8fdcd6611bddd4419a7357 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Wed, 23 Sep 2015 17:23:18 +0200 Subject: sd-daemon: Simplify sd_booted() check 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 | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) (limited to 'src/libsystemd/sd-daemon/sd-daemon.c') diff --git a/src/libsystemd/sd-daemon/sd-daemon.c b/src/libsystemd/sd-daemon/sd-daemon.c index 9ec73406c6..ba7b8da85f 100644 --- a/src/libsystemd/sd-daemon/sd-daemon.c +++ b/src/libsystemd/sd-daemon/sd-daemon.c @@ -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) { -- cgit v1.2.3-54-g00ecf