]>
Commit | Line | Data |
---|---|---|
53e1b683 | 1 | /* SPDX-License-Identifier: LGPL-2.1+ */ |
c2f1db8f | 2 | #pragma once |
5cb5a6ff | 3 | |
a7334b09 | 4 | /*** |
a7334b09 | 5 | Copyright 2010 Lennart Poettering |
a7334b09 LP |
6 | ***/ |
7 | ||
57b7a260 FS |
8 | #include "unit.h" |
9 | ||
5cb5a6ff LP |
10 | typedef struct Device Device; |
11 | ||
66f3fdbb LP |
12 | /* A mask specifying where we have seen the device currently. This is a bitmask because the device might show up |
13 | * asynchronously from each other at various places. For example, in very common case a device might already be mounted | |
14 | * before udev finished probing it (think: a script setting up a loopback block device, formatting it and mounting it | |
15 | * in quick succession). Hence we need to track precisely where it is already visible and where not. */ | |
628c89cc | 16 | typedef enum DeviceFound { |
66f3fdbb LP |
17 | DEVICE_NOT_FOUND = 0, |
18 | DEVICE_FOUND_UDEV = 1U << 1, /* The device has shown up in the udev database */ | |
19 | DEVICE_FOUND_MOUNT = 1U << 2, /* The device has shown up in /proc/self/mountinfo */ | |
20 | DEVICE_FOUND_SWAP = 1U << 3, /* The device has shown up in /proc/swaps */ | |
21 | DEVICE_FOUND_MASK = DEVICE_FOUND_UDEV|DEVICE_FOUND_MOUNT|DEVICE_FOUND_SWAP, | |
628c89cc LP |
22 | } DeviceFound; |
23 | ||
5cb5a6ff | 24 | struct Device { |
ac155bb8 | 25 | Unit meta; |
5cb5a6ff | 26 | |
25ac040b | 27 | char *sysfs; |
8fe914ec | 28 | |
66f3fdbb LP |
29 | /* In order to be able to distinguish dependencies on different device nodes we might end up creating multiple |
30 | * devices for the same sysfs path. We chain them up here. */ | |
8fe914ec | 31 | LIST_FIELDS(struct Device, same_sysfs); |
7fab9d01 | 32 | |
f6200941 | 33 | DeviceState state, deserialized_state; |
66f3fdbb | 34 | DeviceFound found, deserialized_found, enumerated_found; |
ebc8968b FB |
35 | |
36 | bool bind_mounts; | |
5cb5a6ff LP |
37 | }; |
38 | ||
87f0e418 | 39 | extern const UnitVTable device_vtable; |
5cb5a6ff | 40 | |
485ae697 | 41 | void device_found_node(Manager *m, const char *node, DeviceFound found, DeviceFound mask); |
ebc8968b | 42 | bool device_shall_be_bound_by(Unit *device, Unit *u); |
57b7a260 FS |
43 | |
44 | DEFINE_CAST(DEVICE, Device); |