Line data Source code
1 : /* SPDX-License-Identifier: LGPL-2.1+ */ 2 : #pragma once 3 : 4 : #include "unit.h" 5 : 6 : typedef struct Device Device; 7 : 8 : /* A mask specifying where we have seen the device currently. This is a bitmask because the device might show up 9 : * asynchronously from each other at various places. For example, in very common case a device might already be mounted 10 : * before udev finished probing it (think: a script setting up a loopback block device, formatting it and mounting it 11 : * in quick succession). Hence we need to track precisely where it is already visible and where not. */ 12 : typedef enum DeviceFound { 13 : DEVICE_NOT_FOUND = 0, 14 : DEVICE_FOUND_UDEV = 1 << 0, /* The device has shown up in the udev database */ 15 : DEVICE_FOUND_MOUNT = 1 << 1, /* The device has shown up in /proc/self/mountinfo */ 16 : DEVICE_FOUND_SWAP = 1 << 2, /* The device has shown up in /proc/swaps */ 17 : DEVICE_FOUND_MASK = DEVICE_FOUND_UDEV|DEVICE_FOUND_MOUNT|DEVICE_FOUND_SWAP, 18 : } DeviceFound; 19 : 20 : struct Device { 21 : Unit meta; 22 : 23 : char *sysfs; 24 : 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. */ 27 : LIST_FIELDS(struct Device, same_sysfs); 28 : 29 : DeviceState state, deserialized_state; 30 : DeviceFound found, deserialized_found, enumerated_found; 31 : 32 : bool bind_mounts; 33 : 34 : /* The SYSTEMD_WANTS udev property for this device the last time we saw it */ 35 : char **wants_property; 36 : }; 37 : 38 : extern const UnitVTable device_vtable; 39 : 40 : void device_found_node(Manager *m, const char *node, DeviceFound found, DeviceFound mask); 41 : bool device_shall_be_bound_by(Unit *device, Unit *u); 42 : 43 19305 : DEFINE_CAST(DEVICE, Device);