]>
Commit | Line | Data |
---|---|---|
db9ecf05 | 1 | /* SPDX-License-Identifier: LGPL-2.1-or-later */ |
c2f1db8f | 2 | #pragma once |
5cb5a6ff | 3 | |
836e4e7e | 4 | #include "core-forward.h" |
57b7a260 FS |
5 | #include "unit.h" |
6 | ||
66f3fdbb LP |
7 | /* A mask specifying where we have seen the device currently. This is a bitmask because the device might show up |
8 | * asynchronously from each other at various places. For example, in very common case a device might already be mounted | |
9 | * before udev finished probing it (think: a script setting up a loopback block device, formatting it and mounting it | |
10 | * in quick succession). Hence we need to track precisely where it is already visible and where not. */ | |
628c89cc | 11 | typedef enum DeviceFound { |
66f3fdbb | 12 | DEVICE_NOT_FOUND = 0, |
4cf997be LP |
13 | DEVICE_FOUND_UDEV = 1 << 0, /* The device has shown up in the udev database */ |
14 | DEVICE_FOUND_MOUNT = 1 << 1, /* The device has shown up in /proc/self/mountinfo */ | |
15 | DEVICE_FOUND_SWAP = 1 << 2, /* The device has shown up in /proc/swaps */ | |
777f6900 | 16 | _DEVICE_FOUND_MASK = DEVICE_FOUND_UDEV|DEVICE_FOUND_MOUNT|DEVICE_FOUND_SWAP, |
628c89cc LP |
17 | } DeviceFound; |
18 | ||
4ea4abb6 | 19 | typedef struct Device { |
ac155bb8 | 20 | Unit meta; |
5cb5a6ff | 21 | |
1ea74fca | 22 | char *sysfs, *deserialized_sysfs; |
367a2597 | 23 | char *path; /* syspath, device node, alias, or devlink */ |
8fe914ec | 24 | |
66f3fdbb LP |
25 | /* In order to be able to distinguish dependencies on different device nodes we might end up creating multiple |
26 | * devices for the same sysfs path. We chain them up here. */ | |
8fe914ec | 27 | LIST_FIELDS(struct Device, same_sysfs); |
7fab9d01 | 28 | |
f6200941 | 29 | DeviceState state, deserialized_state; |
66f3fdbb | 30 | DeviceFound found, deserialized_found, enumerated_found; |
ad920b4c YW |
31 | bool processed; /* Whether udevd has done processing the device, i.e. the device has database and |
32 | * ID_PROCESSING=1 udev property is not set. This is used only by enumeration and | |
33 | * subsequent catchup process. */ | |
ebc8968b | 34 | bool bind_mounts; |
88116909 LP |
35 | |
36 | /* The SYSTEMD_WANTS udev property for this device the last time we saw it */ | |
37 | char **wants_property; | |
4ea4abb6 | 38 | } Device; |
5cb5a6ff | 39 | |
87f0e418 | 40 | extern const UnitVTable device_vtable; |
5cb5a6ff | 41 | |
485ae697 | 42 | void device_found_node(Manager *m, const char *node, DeviceFound found, DeviceFound mask); |
ebc8968b | 43 | bool device_shall_be_bound_by(Unit *device, Unit *u); |
57b7a260 FS |
44 | |
45 | DEFINE_CAST(DEVICE, Device); |