mirror of
https://github.com/morgan9e/systemd
synced 2026-04-14 08:25:20 +09:00
udev-util: introduce udev_available() helper function
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user