diff options
Diffstat (limited to 'src/shared/udev-util.c')
-rw-r--r-- | src/shared/udev-util.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/shared/udev-util.c b/src/shared/udev-util.c index e2574b9af3..2f21ee6dbe 100644 --- a/src/shared/udev-util.c +++ b/src/shared/udev-util.c @@ -20,6 +20,7 @@ #include "path-util.h" #include "signal-util.h" #include "socket-util.h" +#include "stat-util.h" #include "string-table.h" #include "string-util.h" #include "strxcpyx.h" @@ -723,3 +724,17 @@ int on_ac_power(void) { return found_online || !found_offline; } + +bool udev_available(void) { + static int cache = -1; + + /* The service systemd-udevd is started only when /sys is read write. + * See systemd-udevd.service: ConditionPathIsReadWrite=/sys + * Also, our container interface (http://systemd.io/CONTAINER_INTERFACE/) states that /sys must + * be mounted in read-only mode in containers. */ + + if (cache >= 0) + return cache; + + return (cache = path_is_read_only_fs("/sys/") <= 0); +} |