1 /* SPDX-License-Identifier: LGPL-2.1+ */
3 This file is part of systemd.
5 Copyright 2010 Lennart Poettering
13 #include "alloc-util.h"
14 #include "dbus-device.h"
17 #include "parse-util.h"
18 #include "path-util.h"
19 #include "stat-util.h"
20 #include "string-util.h"
22 #include "udev-util.h"
23 #include "unit-name.h"
26 static const UnitActiveState state_translation_table
[_DEVICE_STATE_MAX
] = {
27 [DEVICE_DEAD
] = UNIT_INACTIVE
,
28 [DEVICE_TENTATIVE
] = UNIT_ACTIVATING
,
29 [DEVICE_PLUGGED
] = UNIT_ACTIVE
,
32 static int device_dispatch_io(sd_event_source
*source
, int fd
, uint32_t revents
, void *userdata
);
34 static void device_unset_sysfs(Device
*d
) {
43 /* Remove this unit from the chain of devices which share the
45 devices
= UNIT(d
)->manager
->devices_by_sysfs
;
46 first
= hashmap_get(devices
, d
->sysfs
);
47 LIST_REMOVE(same_sysfs
, first
, d
);
50 hashmap_remove_and_replace(devices
, d
->sysfs
, first
->sysfs
, first
);
52 hashmap_remove(devices
, d
->sysfs
);
54 d
->sysfs
= mfree(d
->sysfs
);
57 static int device_set_sysfs(Device
*d
, const char *sysfs
) {
64 if (streq_ptr(d
->sysfs
, sysfs
))
67 r
= hashmap_ensure_allocated(&UNIT(d
)->manager
->devices_by_sysfs
, &path_hash_ops
);
75 device_unset_sysfs(d
);
77 first
= hashmap_get(UNIT(d
)->manager
->devices_by_sysfs
, sysfs
);
78 LIST_PREPEND(same_sysfs
, first
, d
);
80 r
= hashmap_replace(UNIT(d
)->manager
->devices_by_sysfs
, copy
, first
);
82 LIST_REMOVE(same_sysfs
, first
, d
);
92 static void device_init(Unit
*u
) {
93 Device
*d
= DEVICE(u
);
96 assert(UNIT(d
)->load_state
== UNIT_STUB
);
98 /* In contrast to all other unit types we timeout jobs waiting
99 * for devices by default. This is because they otherwise wait
100 * indefinitely for plugged in devices, something which cannot
101 * happen for the other units since their operations time out
103 u
->job_running_timeout
= u
->manager
->default_timeout_start_usec
;
105 u
->ignore_on_isolate
= true;
108 static void device_done(Unit
*u
) {
109 Device
*d
= DEVICE(u
);
113 device_unset_sysfs(d
);
116 static void device_set_state(Device
*d
, DeviceState state
) {
117 DeviceState old_state
;
120 old_state
= d
->state
;
123 if (state
!= old_state
)
124 log_unit_debug(UNIT(d
), "Changed %s -> %s", device_state_to_string(old_state
), device_state_to_string(state
));
126 unit_notify(UNIT(d
), state_translation_table
[old_state
], state_translation_table
[state
], true);
129 static int device_coldplug(Unit
*u
) {
130 Device
*d
= DEVICE(u
);
133 assert(d
->state
== DEVICE_DEAD
);
135 if (d
->found
& DEVICE_FOUND_UDEV
)
136 /* If udev says the device is around, it's around */
137 device_set_state(d
, DEVICE_PLUGGED
);
138 else if (d
->found
!= DEVICE_NOT_FOUND
&& d
->deserialized_state
!= DEVICE_PLUGGED
)
139 /* If a device is found in /proc/self/mountinfo or
140 * /proc/swaps, and was not yet announced via udev,
141 * it's "tentatively" around. */
142 device_set_state(d
, DEVICE_TENTATIVE
);
147 static int device_serialize(Unit
*u
, FILE *f
, FDSet
*fds
) {
148 Device
*d
= DEVICE(u
);
154 unit_serialize_item(u
, f
, "state", device_state_to_string(d
->state
));
159 static int device_deserialize_item(Unit
*u
, const char *key
, const char *value
, FDSet
*fds
) {
160 Device
*d
= DEVICE(u
);
167 if (streq(key
, "state")) {
170 state
= device_state_from_string(value
);
172 log_unit_debug(u
, "Failed to parse state value: %s", value
);
174 d
->deserialized_state
= state
;
176 log_unit_debug(u
, "Unknown serialization key: %s", key
);
181 static void device_dump(Unit
*u
, FILE *f
, const char *prefix
) {
182 Device
*d
= DEVICE(u
);
187 "%sDevice State: %s\n"
188 "%sSysfs Path: %s\n",
189 prefix
, device_state_to_string(d
->state
),
190 prefix
, strna(d
->sysfs
));
193 _pure_
static UnitActiveState
device_active_state(Unit
*u
) {
196 return state_translation_table
[DEVICE(u
)->state
];
199 _pure_
static const char *device_sub_state_to_string(Unit
*u
) {
202 return device_state_to_string(DEVICE(u
)->state
);
205 static int device_update_description(Unit
*u
, struct udev_device
*dev
, const char *path
) {
213 model
= udev_device_get_property_value(dev
, "ID_MODEL_FROM_DATABASE");
215 model
= udev_device_get_property_value(dev
, "ID_MODEL");
220 /* Try to concatenate the device model string with a label, if there is one */
221 label
= udev_device_get_property_value(dev
, "ID_FS_LABEL");
223 label
= udev_device_get_property_value(dev
, "ID_PART_ENTRY_NAME");
225 label
= udev_device_get_property_value(dev
, "ID_PART_ENTRY_NUMBER");
228 _cleanup_free_
char *j
;
230 j
= strjoin(model
, " ", label
);
232 r
= unit_set_description(u
, j
);
236 r
= unit_set_description(u
, model
);
238 r
= unit_set_description(u
, path
);
241 log_unit_error_errno(u
, r
, "Failed to set device description: %m");
246 static int device_add_udev_wants(Unit
*u
, struct udev_device
*dev
) {
247 const char *wants
, *property
;
253 property
= MANAGER_IS_USER(u
->manager
) ? "SYSTEMD_USER_WANTS" : "SYSTEMD_WANTS";
255 wants
= udev_device_get_property_value(dev
, property
);
260 _cleanup_free_
char *word
= NULL
, *k
= NULL
;
262 r
= extract_first_word(&wants
, &word
, NULL
, EXTRACT_QUOTES
);
268 return log_unit_error_errno(u
, r
, "Failed to parse property %s with value %s: %m", property
, wants
);
270 if (unit_name_is_valid(word
, UNIT_NAME_TEMPLATE
) && DEVICE(u
)->sysfs
) {
271 _cleanup_free_
char *escaped
= NULL
;
273 /* If the unit name is specified as template, then automatically fill in the sysfs path of the
274 * device as instance name, properly escaped. */
276 r
= unit_name_path_escape(DEVICE(u
)->sysfs
, &escaped
);
278 return log_unit_error_errno(u
, r
, "Failed to escape %s: %m", DEVICE(u
)->sysfs
);
280 r
= unit_name_replace_instance(word
, escaped
, &k
);
282 return log_unit_error_errno(u
, r
, "Failed to build %s instance of template %s: %m", escaped
, word
);
284 /* If this is not a template, then let's mangle it so, that it becomes a valid unit name. */
286 r
= unit_name_mangle(word
, UNIT_NAME_MANGLE_WARN
, &k
);
288 return log_unit_error_errno(u
, r
, "Failed to mangle unit name \"%s\": %m", word
);
291 r
= unit_add_dependency_by_name(u
, UNIT_WANTS
, k
, NULL
, true, UNIT_DEPENDENCY_UDEV
);
293 return log_unit_error_errno(u
, r
, "Failed to add Wants= dependency: %m");
297 static bool device_is_bound_by_mounts(Device
*d
, struct udev_device
*dev
) {
298 const char *bound_by
;
304 bound_by
= udev_device_get_property_value(dev
, "SYSTEMD_MOUNT_DEVICE_BOUND");
306 r
= parse_boolean(bound_by
);
308 log_warning_errno(r
, "Failed to parse SYSTEMD_MOUNT_DEVICE_BOUND='%s' udev property of %s, ignoring: %m", bound_by
, strna(d
->sysfs
));
310 d
->bind_mounts
= r
> 0;
312 d
->bind_mounts
= false;
314 return d
->bind_mounts
;
317 static int device_upgrade_mount_deps(Unit
*u
) {
323 /* Let's upgrade Requires= to BindsTo= on us. (Used when SYSTEMD_MOUNT_DEVICE_BOUND is set) */
325 HASHMAP_FOREACH_KEY(v
, other
, u
->dependencies
[UNIT_REQUIRED_BY
], i
) {
326 if (other
->type
!= UNIT_MOUNT
)
329 r
= unit_add_dependency(other
, UNIT_BINDS_TO
, u
, true, UNIT_DEPENDENCY_UDEV
);
336 static int device_setup_unit(Manager
*m
, struct udev_device
*dev
, const char *path
, bool main
) {
337 _cleanup_free_
char *e
= NULL
;
338 const char *sysfs
= NULL
;
347 sysfs
= udev_device_get_syspath(dev
);
352 r
= unit_name_from_path(path
, ".device", &e
);
354 return log_error_errno(r
, "Failed to generate unit name from device path: %m");
356 u
= manager_get_unit(m
, e
);
358 /* The device unit can still be present even if the device was unplugged: a mount unit can reference it hence
359 * preventing the GC to have garbaged it. That's desired since the device unit may have a dependency on the
360 * mount unit which was added during the loading of the later. */
361 if (dev
&& DEVICE(u
)->state
== DEVICE_PLUGGED
) {
363 /* This unit is in plugged state: we're sure it's attached to a device. */
364 if (!path_equal(DEVICE(u
)->sysfs
, sysfs
)) {
365 log_unit_debug(u
, "Dev %s appeared twice with different sysfs paths %s and %s",
366 e
, DEVICE(u
)->sysfs
, sysfs
);
373 /* Let's remove all dependencies generated due to udev properties. We'll readd whatever is configured
375 unit_remove_dependencies(u
, UNIT_DEPENDENCY_UDEV
);
379 r
= unit_new_for_name(m
, sizeof(Device
), e
, &u
);
383 unit_add_to_load_queue(u
);
386 /* If this was created via some dependency and has not
387 * actually been seen yet ->sysfs will not be
388 * initialized. Hence initialize it if necessary. */
390 r
= device_set_sysfs(DEVICE(u
), sysfs
);
394 (void) device_update_description(u
, dev
, path
);
396 /* The additional systemd udev properties we only interpret
397 * for the main object */
399 (void) device_add_udev_wants(u
, dev
);
402 /* So the user wants the mount units to be bound to the device but a mount unit might has been seen by systemd
403 * before the device appears on its radar. In this case the device unit is partially initialized and includes
404 * the deps on the mount unit but at that time the "bind mounts" flag wasn't not present. Fix this up now. */
405 if (dev
&& device_is_bound_by_mounts(DEVICE(u
), dev
))
406 device_upgrade_mount_deps(u
);
408 /* Note that this won't dispatch the load queue, the caller has to do that if needed and appropriate */
410 unit_add_to_dbus_queue(u
);
414 log_unit_warning_errno(u
, r
, "Failed to set up device unit: %m");
422 static int device_process_new(Manager
*m
, struct udev_device
*dev
) {
423 const char *sysfs
, *dn
, *alias
;
424 struct udev_list_entry
*item
= NULL
, *first
= NULL
;
429 sysfs
= udev_device_get_syspath(dev
);
433 /* Add the main unit named after the sysfs path */
434 r
= device_setup_unit(m
, dev
, sysfs
, true);
438 /* Add an additional unit for the device node */
439 dn
= udev_device_get_devnode(dev
);
441 (void) device_setup_unit(m
, dev
, dn
, false);
443 /* Add additional units for all symlinks */
444 first
= udev_device_get_devlinks_list_entry(dev
);
445 udev_list_entry_foreach(item
, first
) {
449 /* Don't bother with the /dev/block links */
450 p
= udev_list_entry_get_name(item
);
452 if (path_startswith(p
, "/dev/block/") ||
453 path_startswith(p
, "/dev/char/"))
456 /* Verify that the symlink in the FS actually belongs
457 * to this device. This is useful to deal with
458 * conflicting devices, e.g. when two disks want the
459 * same /dev/disk/by-label/xxx link because they have
460 * the same label. We want to make sure that the same
461 * device that won the symlink wins in systemd, so we
462 * check the device node major/minor */
463 if (stat(p
, &st
) >= 0)
464 if ((!S_ISBLK(st
.st_mode
) && !S_ISCHR(st
.st_mode
)) ||
465 st
.st_rdev
!= udev_device_get_devnum(dev
))
468 (void) device_setup_unit(m
, dev
, p
, false);
471 /* Add additional units for all explicitly configured
473 alias
= udev_device_get_property_value(dev
, "SYSTEMD_ALIAS");
475 _cleanup_free_
char *word
= NULL
;
477 r
= extract_first_word(&alias
, &word
, NULL
, EXTRACT_QUOTES
);
483 return log_warning_errno(r
, "Failed to add parse SYSTEMD_ALIAS for %s: %m", sysfs
);
485 if (path_is_absolute(word
))
486 (void) device_setup_unit(m
, dev
, word
, false);
488 log_warning("SYSTEMD_ALIAS for %s is not an absolute path, ignoring: %s", sysfs
, word
);
492 static void device_update_found_one(Device
*d
, bool add
, DeviceFound found
, bool now
) {
493 DeviceFound n
, previous
;
497 n
= add
? (d
->found
| found
) : (d
->found
& ~found
);
507 /* Didn't exist before, but does now? if so, generate a new invocation ID for it */
508 if (previous
== DEVICE_NOT_FOUND
&& d
->found
!= DEVICE_NOT_FOUND
)
509 (void) unit_acquire_invocation_id(UNIT(d
));
511 if (d
->found
& DEVICE_FOUND_UDEV
)
512 /* When the device is known to udev we consider it
514 device_set_state(d
, DEVICE_PLUGGED
);
515 else if (d
->found
!= DEVICE_NOT_FOUND
&& (previous
& DEVICE_FOUND_UDEV
) == 0)
516 /* If the device has not been seen by udev yet, but is
517 * now referenced by the kernel, then we assume the
518 * kernel knows it now, and udev might soon too. */
519 device_set_state(d
, DEVICE_TENTATIVE
);
521 /* If nobody sees the device, or if the device was
522 * previously seen by udev and now is only referenced
523 * from the kernel, then we consider the device is
524 * gone, the kernel just hasn't noticed it yet. */
526 device_set_state(d
, DEVICE_DEAD
);
527 device_unset_sysfs(d
);
532 static int device_update_found_by_sysfs(Manager
*m
, const char *sysfs
, bool add
, DeviceFound found
, bool now
) {
538 if (found
== DEVICE_NOT_FOUND
)
541 l
= hashmap_get(m
->devices_by_sysfs
, sysfs
);
542 LIST_FOREACH_SAFE(same_sysfs
, d
, n
, l
)
543 device_update_found_one(d
, add
, found
, now
);
548 static int device_update_found_by_name(Manager
*m
, const char *path
, bool add
, DeviceFound found
, bool now
) {
549 _cleanup_free_
char *e
= NULL
;
556 if (found
== DEVICE_NOT_FOUND
)
559 r
= unit_name_from_path(path
, ".device", &e
);
561 return log_error_errno(r
, "Failed to generate unit name from device path: %m");
563 u
= manager_get_unit(m
, e
);
567 device_update_found_one(DEVICE(u
), add
, found
, now
);
571 static bool device_is_ready(struct udev_device
*dev
) {
576 ready
= udev_device_get_property_value(dev
, "SYSTEMD_READY");
580 return parse_boolean(ready
) != 0;
583 static Unit
*device_following(Unit
*u
) {
584 Device
*d
= DEVICE(u
);
585 Device
*other
, *first
= NULL
;
589 if (startswith(u
->id
, "sys-"))
592 /* Make everybody follow the unit that's named after the sysfs path */
593 for (other
= d
->same_sysfs_next
; other
; other
= other
->same_sysfs_next
)
594 if (startswith(UNIT(other
)->id
, "sys-"))
597 for (other
= d
->same_sysfs_prev
; other
; other
= other
->same_sysfs_prev
) {
598 if (startswith(UNIT(other
)->id
, "sys-"))
607 static int device_following_set(Unit
*u
, Set
**_set
) {
608 Device
*d
= DEVICE(u
), *other
;
615 if (LIST_JUST_US(same_sysfs
, d
)) {
624 LIST_FOREACH_AFTER(same_sysfs
, other
, d
) {
625 r
= set_put(set
, other
);
630 LIST_FOREACH_BEFORE(same_sysfs
, other
, d
) {
631 r
= set_put(set
, other
);
644 static void device_shutdown(Manager
*m
) {
647 m
->udev_event_source
= sd_event_source_unref(m
->udev_event_source
);
648 m
->udev_monitor
= udev_monitor_unref(m
->udev_monitor
);
649 m
->devices_by_sysfs
= hashmap_free(m
->devices_by_sysfs
);
652 static void device_enumerate(Manager
*m
) {
653 _cleanup_udev_enumerate_unref_
struct udev_enumerate
*e
= NULL
;
654 struct udev_list_entry
*item
= NULL
, *first
= NULL
;
659 if (!m
->udev_monitor
) {
660 m
->udev_monitor
= udev_monitor_new_from_netlink(m
->udev
, "udev");
661 if (!m
->udev_monitor
) {
666 /* This will fail if we are unprivileged, but that
667 * should not matter much, as user instances won't run
669 (void) udev_monitor_set_receive_buffer_size(m
->udev_monitor
, 128*1024*1024);
671 r
= udev_monitor_filter_add_match_tag(m
->udev_monitor
, "systemd");
673 log_error_errno(r
, "Failed to add udev tag match: %m");
677 r
= udev_monitor_enable_receiving(m
->udev_monitor
);
679 log_error_errno(r
, "Failed to enable udev event reception: %m");
683 r
= sd_event_add_io(m
->event
, &m
->udev_event_source
, udev_monitor_get_fd(m
->udev_monitor
), EPOLLIN
, device_dispatch_io
, m
);
685 log_error_errno(r
, "Failed to watch udev file descriptor: %m");
689 (void) sd_event_source_set_description(m
->udev_event_source
, "device");
692 e
= udev_enumerate_new(m
->udev
);
698 r
= udev_enumerate_add_match_tag(e
, "systemd");
700 log_error_errno(r
, "Failed to create udev tag enumeration: %m");
704 r
= udev_enumerate_add_match_is_initialized(e
);
706 log_error_errno(r
, "Failed to install initialization match into enumeration: %m");
710 r
= udev_enumerate_scan_devices(e
);
712 log_error_errno(r
, "Failed to enumerate devices: %m");
716 first
= udev_enumerate_get_list_entry(e
);
717 udev_list_entry_foreach(item
, first
) {
718 _cleanup_udev_device_unref_
struct udev_device
*dev
= NULL
;
721 sysfs
= udev_list_entry_get_name(item
);
723 dev
= udev_device_new_from_syspath(m
->udev
, sysfs
);
729 if (!device_is_ready(dev
))
732 (void) device_process_new(m
, dev
);
734 device_update_found_by_sysfs(m
, sysfs
, true, DEVICE_FOUND_UDEV
, false);
743 static int device_dispatch_io(sd_event_source
*source
, int fd
, uint32_t revents
, void *userdata
) {
744 _cleanup_udev_device_unref_
struct udev_device
*dev
= NULL
;
745 Manager
*m
= userdata
;
746 const char *action
, *sysfs
;
751 if (revents
!= EPOLLIN
) {
752 static RATELIMIT_DEFINE(limit
, 10*USEC_PER_SEC
, 5);
754 if (!ratelimit_test(&limit
))
755 log_error_errno(errno
, "Failed to get udev event: %m");
756 if (!(revents
& EPOLLIN
))
761 * libudev might filter-out devices which pass the bloom
762 * filter, so getting NULL here is not necessarily an error.
764 dev
= udev_monitor_receive_device(m
->udev_monitor
);
768 sysfs
= udev_device_get_syspath(dev
);
770 log_error("Failed to get udev sys path.");
774 action
= udev_device_get_action(dev
);
776 log_error("Failed to get udev action string.");
780 if (streq(action
, "change")) {
784 l
= hashmap_get(m
->devices_by_sysfs
, sysfs
);
785 LIST_FOREACH_SAFE(same_sysfs
, d
, n
, l
) {
787 if (u
&& UNIT_VTABLE(u
)->active_state(u
) == UNIT_ACTIVE
) {
788 r
= manager_propagate_reload(m
, u
, JOB_REPLACE
, NULL
);
790 log_error_errno(r
, "Failed to propagate reload: %m");
795 /* A change event can signal that a device is becoming ready, in particular if
796 * the device is using the SYSTEMD_READY logic in udev
797 * so we need to reach the else block of the follwing if, even for change events */
798 if (streq(action
, "remove")) {
799 r
= swap_process_device_remove(m
, dev
);
801 log_error_errno(r
, "Failed to process swap device remove event: %m");
803 /* If we get notified that a device was removed by
804 * udev, then it's completely gone, hence unset all
806 device_update_found_by_sysfs(m
, sysfs
, false, DEVICE_FOUND_UDEV
|DEVICE_FOUND_MOUNT
|DEVICE_FOUND_SWAP
, true);
808 } else if (device_is_ready(dev
)) {
810 (void) device_process_new(m
, dev
);
812 r
= swap_process_device_new(m
, dev
);
814 log_error_errno(r
, "Failed to process swap device new event: %m");
816 manager_dispatch_load_queue(m
);
818 /* The device is found now, set the udev found bit */
819 device_update_found_by_sysfs(m
, sysfs
, true, DEVICE_FOUND_UDEV
, true);
822 /* The device is nominally around, but not ready for
823 * us. Hence unset the udev bit, but leave the rest
826 device_update_found_by_sysfs(m
, sysfs
, false, DEVICE_FOUND_UDEV
, true);
832 static bool device_supported(void) {
833 static int read_only
= -1;
835 /* If /sys is read-only we don't support device units, and any
836 * attempts to start one should fail immediately. */
839 read_only
= path_is_read_only_fs("/sys");
841 return read_only
<= 0;
844 int device_found_node(Manager
*m
, const char *node
, bool add
, DeviceFound found
, bool now
) {
845 _cleanup_udev_device_unref_
struct udev_device
*dev
= NULL
;
851 if (!device_supported())
854 /* This is called whenever we find a device referenced in
855 * /proc/swaps or /proc/self/mounts. Such a device might be
856 * mounted/enabled at a time where udev has not finished
857 * probing it yet, and we thus haven't learned about it
858 * yet. In this case we will set the device unit to
859 * "tentative" state. */
862 if (!path_startswith(node
, "/dev"))
865 /* We make an extra check here, if the device node
866 * actually exists. If it's missing, then this is an
867 * indication that device was unplugged but is still
868 * referenced in /proc/swaps or
869 * /proc/self/mountinfo. Note that this check doesn't
870 * really cover all cases where a device might be gone
871 * away, since drives that can have a medium inserted
872 * will still have a device node even when the medium
875 if (stat(node
, &st
) >= 0) {
876 if (!S_ISBLK(st
.st_mode
) && !S_ISCHR(st
.st_mode
))
879 dev
= udev_device_new_from_devnum(m
->udev
, S_ISBLK(st
.st_mode
) ? 'b' : 'c', st
.st_rdev
);
880 if (!dev
&& errno
!= ENOENT
)
881 return log_error_errno(errno
, "Failed to get udev device from devnum %u:%u: %m", major(st
.st_rdev
), minor(st
.st_rdev
));
883 } else if (errno
!= ENOENT
)
884 return log_error_errno(errno
, "Failed to stat device node file %s: %m", node
);
886 /* If the device is known in the kernel and newly
887 * appeared, then we'll create a device unit for it,
888 * under the name referenced in /proc/swaps or
889 * /proc/self/mountinfo. */
891 (void) device_setup_unit(m
, dev
, node
, false);
894 /* Update the device unit's state, should it exist */
895 return device_update_found_by_name(m
, node
, add
, found
, now
);
898 bool device_shall_be_bound_by(Unit
*device
, Unit
*u
) {
900 if (u
->type
!= UNIT_MOUNT
)
903 return DEVICE(device
)->bind_mounts
;
906 const UnitVTable device_vtable
= {
907 .object_size
= sizeof(Device
),
917 .load
= unit_load_fragment_and_dropin_optional
,
919 .coldplug
= device_coldplug
,
921 .serialize
= device_serialize
,
922 .deserialize_item
= device_deserialize_item
,
926 .active_state
= device_active_state
,
927 .sub_state_to_string
= device_sub_state_to_string
,
929 .bus_vtable
= bus_device_vtable
,
931 .following
= device_following
,
932 .following_set
= device_following_set
,
934 .enumerate
= device_enumerate
,
935 .shutdown
= device_shutdown
,
936 .supported
= device_supported
,
938 .status_message_formats
= {
939 .starting_stopping
= {
940 [0] = "Expecting device %s...",
942 .finished_start_job
= {
943 [JOB_DONE
] = "Found device %s.",
944 [JOB_TIMEOUT
] = "Timed out waiting for device %s.",