mirror of
https://github.com/systemd/systemd-stable.git
synced 2024-12-23 17:34:00 +03:00
udev-util: introduce udev_available() helper function
(cherry picked from commit f92c5bb18c
)
This commit is contained in:
parent
160eeab224
commit
c809c046be
@ -19,6 +19,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"
|
||||
@ -718,3 +719,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);
|
||||
}
|
||||
|
@ -55,6 +55,8 @@ int udev_queue_init(void);
|
||||
|
||||
int on_ac_power(void);
|
||||
|
||||
bool udev_available(void);
|
||||
|
||||
#if HAVE_SYS_SDT_H
|
||||
|
||||
/* Each trace point can have different number of additional arguments. Note that when the macro is used only
|
||||
|
Loading…
Reference in New Issue
Block a user