1
0
mirror of https://github.com/systemd/systemd.git synced 2024-11-08 11:27:32 +03:00

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.
This commit is contained in:
Lennart Poettering 2015-09-23 17:23:18 +02:00
parent 94f099d813
commit 31021ba085

View 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) {