X-Git-Url: http://git.ipfire.org/?a=blobdiff_plain;f=src%2Fcore%2Fdevice.h;h=a119b33e57f34d05c19ae0c6c6c84178e80fa880;hb=88116909ec60724ddce47feb2cc40c52bdb81bdf;hp=d52700b66f66bf9ea452018e1d5f351bf7f0fbb6;hpb=f5ce2e764fdab02e3d28eb653253686cffd71920;p=thirdparty%2Fsystemd.git diff --git a/src/core/device.h b/src/core/device.h index d52700b66f6..a119b33e57f 100644 --- a/src/core/device.h +++ b/src/core/device.h @@ -1,39 +1,43 @@ /* SPDX-License-Identifier: LGPL-2.1+ */ #pragma once -/*** - This file is part of systemd. - - Copyright 2010 Lennart Poettering -***/ +#include "unit.h" typedef struct Device Device; +/* A mask specifying where we have seen the device currently. This is a bitmask because the device might show up + * asynchronously from each other at various places. For example, in very common case a device might already be mounted + * before udev finished probing it (think: a script setting up a loopback block device, formatting it and mounting it + * in quick succession). Hence we need to track precisely where it is already visible and where not. */ typedef enum DeviceFound { - 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, + DEVICE_NOT_FOUND = 0, + DEVICE_FOUND_UDEV = 1U << 1, /* The device has shown up in the udev database */ + DEVICE_FOUND_MOUNT = 1U << 2, /* The device has shown up in /proc/self/mountinfo */ + DEVICE_FOUND_SWAP = 1U << 3, /* The device has shown up in /proc/swaps */ + DEVICE_FOUND_MASK = DEVICE_FOUND_UDEV|DEVICE_FOUND_MOUNT|DEVICE_FOUND_SWAP, } DeviceFound; struct Device { Unit meta; char *sysfs; - DeviceFound found; - /* In order to be able to distinguish dependencies on - different device nodes we might end up creating multiple - devices for the same sysfs path. We chain them up here. */ + /* In order to be able to distinguish dependencies on different device nodes we might end up creating multiple + * devices for the same sysfs path. We chain them up here. */ LIST_FIELDS(struct Device, same_sysfs); DeviceState state, deserialized_state; + DeviceFound found, deserialized_found, enumerated_found; bool bind_mounts; + + /* The SYSTEMD_WANTS udev property for this device the last time we saw it */ + char **wants_property; }; extern const UnitVTable device_vtable; -int device_found_node(Manager *m, const char *node, bool add, DeviceFound found, bool now); +void device_found_node(Manager *m, const char *node, DeviceFound found, DeviceFound mask); bool device_shall_be_bound_by(Unit *device, Unit *u); + +DEFINE_CAST(DEVICE, Device);