summaryrefslogtreecommitdiff
path: root/src/core/device.h
diff options
context:
space:
mode:
authorFranck Bui <fbui@suse.com>2018-04-06 15:02:10 +0200
committerFranck Bui <fbui@suse.com>2018-04-20 17:49:28 +0200
commit918e6f1c0151429f5095355f4f3f74f16e79724a (patch)
tree3519766667f96bc82351f4b0b6875346cf6b85a3 /src/core/device.h
parent201b26a3441a46c2acf43d6718c01f1df173f014 (diff)
downloadsystemd-918e6f1c0151429f5095355f4f3f74f16e79724a.tar.gz
device: make sure to always retroactively start device dependencies
PID1 updates the state of device units upon 2 different events: - when it processes an event sent by udev and in this case the device deps are started if the device enters in the "plugged" state. - when it enumerates all devices during its startup or when it is asked to reload its configuration data but in this case the device deps (if any) are not retroactively started. When udev processes a new "add" kernel event, it first registers the new device in its databases then sends an event to systemd. If for any reason, systemd is asked to reload its configuration between the previous 2 steps, it might see for the first time the new device while scanning /sys for all devices. Only during a second step, udev will send the event for the new device. In this peculiar case the device deps wont be started (even though the device is first seen by PID1). Indeed when reloading its configurations, PID1 will put the device unit in the "plugged" state but without starting the device deps. Thereafter PID1 will get the event from udev for the new device but the device unit will be in "plugged" state already therefore it won't see any need to start the device dependencies. Rather than assuming that during the reloading of systemd manager configuration all devices listed in udev DBs have been already processed and should be put in the "plugged" state (done by device_coldplug()), this patch does that only for devices which have been processed via an udev event (device_dispatch_io()) previously. In this case we set "d->found" to "DEVICE_FOUND_UDEV" and we make also sure to no more initialize "d->found" while enumerating devices. Instead this field is now saved/restored while devices are serialized.
Diffstat (limited to 'src/core/device.h')
-rw-r--r--src/core/device.h12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/core/device.h b/src/core/device.h
index 4b970a0d6a..a96aa6d24d 100644
--- a/src/core/device.h
+++ b/src/core/device.h
@@ -10,10 +10,11 @@
typedef struct Device Device;
typedef enum DeviceFound {
- DEVICE_NOT_FOUND = 0,
- DEVICE_FOUND_UDEV = 1,
- DEVICE_FOUND_MOUNT = 2,
- DEVICE_FOUND_SWAP = 4,
+ DEVICE_NOT_FOUND = 0,
+ DEVICE_FOUND_UDEV = 1 << 1,
+ DEVICE_FOUND_UDEV_DB = 1 << 2,
+ DEVICE_FOUND_MOUNT = 1 << 3,
+ DEVICE_FOUND_SWAP = 1 << 4,
} DeviceFound;
struct Device {
@@ -36,3 +37,6 @@ extern const UnitVTable device_vtable;
int device_found_node(Manager *m, const char *node, bool add, DeviceFound found, bool now);
bool device_shall_be_bound_by(Unit *device, Unit *u);
+
+const char *device_found_to_string(DeviceFound f) _const_;
+DeviceFound device_found_from_string(const char *s) _pure_;