2 * libudev - interface to udev device information
4 * Copyright (C) 2008-2010 Kay Sievers <kay.sievers@vrfy.org>
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
22 #include <sys/param.h>
25 #include "libudev-private.h"
28 * SECTION:libudev-enumerate
29 * @short_description: lookup and sort sys devices
31 * Lookup devices in the sys filesystem, filter devices by properties,
32 * and return a sorted list of devices.
43 * Opaque object representing one device lookup/sort context.
45 struct udev_enumerate {
48 struct udev_list sysattr_match_list;
49 struct udev_list sysattr_nomatch_list;
50 struct udev_list subsystem_match_list;
51 struct udev_list subsystem_nomatch_list;
52 struct udev_list sysname_match_list;
53 struct udev_list properties_match_list;
54 struct udev_list tags_match_list;
55 struct udev_device *parent_match;
56 struct udev_list devices_list;
57 struct syspath *devices;
58 unsigned int devices_cur;
59 unsigned int devices_max;
60 bool devices_uptodate:1;
61 bool match_is_initialized;
66 * @udev: udev library context
68 * Returns: an enumeration context
70 _public_ struct udev_enumerate *udev_enumerate_new(struct udev *udev)
72 struct udev_enumerate *udev_enumerate;
74 udev_enumerate = calloc(1, sizeof(struct udev_enumerate));
75 if (udev_enumerate == NULL)
77 udev_enumerate->refcount = 1;
78 udev_enumerate->udev = udev;
79 udev_list_init(udev, &udev_enumerate->sysattr_match_list, false);
80 udev_list_init(udev, &udev_enumerate->sysattr_nomatch_list, false);
81 udev_list_init(udev, &udev_enumerate->subsystem_match_list, true);
82 udev_list_init(udev, &udev_enumerate->subsystem_nomatch_list, true);
83 udev_list_init(udev, &udev_enumerate->sysname_match_list, true);
84 udev_list_init(udev, &udev_enumerate->properties_match_list, false);
85 udev_list_init(udev, &udev_enumerate->tags_match_list, true);
86 udev_list_init(udev, &udev_enumerate->devices_list, false);
87 return udev_enumerate;
92 * @udev_enumerate: context
94 * Take a reference of a enumeration context.
96 * Returns: the passed enumeration context
98 _public_ struct udev_enumerate *udev_enumerate_ref(struct udev_enumerate *udev_enumerate)
100 if (udev_enumerate == NULL)
102 udev_enumerate->refcount++;
103 return udev_enumerate;
107 * udev_enumerate_unref:
108 * @udev_enumerate: context
110 * Drop a reference of an enumeration context. If the refcount reaches zero,
111 * all resources of the enumeration context will be released.
113 _public_ void udev_enumerate_unref(struct udev_enumerate *udev_enumerate)
117 if (udev_enumerate == NULL)
119 udev_enumerate->refcount--;
120 if (udev_enumerate->refcount > 0)
122 udev_list_cleanup(&udev_enumerate->sysattr_match_list);
123 udev_list_cleanup(&udev_enumerate->sysattr_nomatch_list);
124 udev_list_cleanup(&udev_enumerate->subsystem_match_list);
125 udev_list_cleanup(&udev_enumerate->subsystem_nomatch_list);
126 udev_list_cleanup(&udev_enumerate->sysname_match_list);
127 udev_list_cleanup(&udev_enumerate->properties_match_list);
128 udev_list_cleanup(&udev_enumerate->tags_match_list);
129 udev_device_unref(udev_enumerate->parent_match);
130 udev_list_cleanup(&udev_enumerate->devices_list);
131 for (i = 0; i < udev_enumerate->devices_cur; i++)
132 free(udev_enumerate->devices[i].syspath);
133 free(udev_enumerate->devices);
134 free(udev_enumerate);
138 * udev_enumerate_get_udev:
139 * @udev_enumerate: context
141 * Returns: the udev library context.
143 _public_ struct udev *udev_enumerate_get_udev(struct udev_enumerate *udev_enumerate)
145 if (udev_enumerate == NULL)
147 return udev_enumerate->udev;
150 static int syspath_add(struct udev_enumerate *udev_enumerate, const char *syspath)
153 struct syspath *entry;
155 /* double array size if needed */
156 if (udev_enumerate->devices_cur >= udev_enumerate->devices_max) {
160 add = udev_enumerate->devices_max;
163 buf = realloc(udev_enumerate->devices, (udev_enumerate->devices_max + add) * sizeof(struct syspath));
166 udev_enumerate->devices = buf;
167 udev_enumerate->devices_max += add;
170 path = strdup(syspath);
173 entry = &udev_enumerate->devices[udev_enumerate->devices_cur];
174 entry->syspath = path;
175 entry->len = strlen(path);
176 udev_enumerate->devices_cur++;
177 udev_enumerate->devices_uptodate = false;
181 static int syspath_cmp(const void *p1, const void *p2)
183 const struct syspath *path1 = p1;
184 const struct syspath *path2 = p2;
188 len = MIN(path1->len, path2->len);
189 ret = memcmp(path1->syspath, path2->syspath, len);
191 if (path1->len < path2->len)
193 else if (path1->len > path2->len)
199 /* For devices that should be moved to the absolute end of the list */
200 static bool devices_delay_end(struct udev *udev, const char *syspath)
202 static const char *delay_device_list[] = {
209 for (i = 0; delay_device_list[i] != NULL; i++) {
210 if (strstr(syspath + strlen("/sys"), delay_device_list[i]) != NULL)
216 /* For devices that should just be moved a little bit later, just
217 * before the point where some common path prefix changes. Returns the
218 * number of characters that make up that common prefix */
219 static size_t devices_delay_later(struct udev *udev, const char *syspath)
223 /* For sound cards the control device must be enumerated last
224 * to make sure it's the final device node that gets ACLs
225 * applied. Applications rely on this fact and use ACL changes
226 * on the control node as an indicator that the ACL change of
227 * the entire sound card completed. The kernel makes this
228 * guarantee when creating those devices, and hence we should
229 * too when enumerating them. */
231 if ((c = strstr(syspath, "/sound/card"))) {
233 c += strcspn(c, "/");
235 if (strncmp(c, "/controlC", 9) == 0)
236 return c - syspath + 1;
243 * udev_enumerate_get_list_entry:
244 * @udev_enumerate: context
246 * Returns: the first entry of the sorted list of device paths.
248 _public_ struct udev_list_entry *udev_enumerate_get_list_entry(struct udev_enumerate *udev_enumerate)
250 if (udev_enumerate == NULL)
252 if (!udev_enumerate->devices_uptodate) {
255 struct syspath *prev = NULL, *move_later = NULL;
256 size_t move_later_prefix = 0;
258 udev_list_cleanup(&udev_enumerate->devices_list);
259 qsort(udev_enumerate->devices, udev_enumerate->devices_cur, sizeof(struct syspath), syspath_cmp);
261 max = udev_enumerate->devices_cur;
262 for (i = 0; i < max; i++) {
263 struct syspath *entry = &udev_enumerate->devices[i];
265 /* skip duplicated entries */
267 entry->len == prev->len &&
268 memcmp(entry->syspath, prev->syspath, entry->len) == 0)
272 /* skip to be delayed devices, and add them to the end of the list */
273 if (devices_delay_end(udev_enumerate->udev, entry->syspath)) {
274 syspath_add(udev_enumerate, entry->syspath);
275 /* need to update prev here for the case realloc() gives a different address */
276 prev = &udev_enumerate->devices[i];
280 /* skip to be delayed devices, and move the to
281 * the point where the prefix changes. We can
282 * only move one item at a time. */
284 move_later_prefix = devices_delay_later(udev_enumerate->udev, entry->syspath);
286 if (move_later_prefix > 0) {
293 strncmp(entry->syspath, move_later->syspath, move_later_prefix) != 0) {
295 udev_list_entry_add(&udev_enumerate->devices_list, move_later->syspath, NULL);
299 udev_list_entry_add(&udev_enumerate->devices_list, entry->syspath, NULL);
303 udev_list_entry_add(&udev_enumerate->devices_list, move_later->syspath, NULL);
305 /* add and cleanup delayed devices from end of list */
306 for (i = max; i < udev_enumerate->devices_cur; i++) {
307 struct syspath *entry = &udev_enumerate->devices[i];
309 udev_list_entry_add(&udev_enumerate->devices_list, entry->syspath, NULL);
310 free(entry->syspath);
312 udev_enumerate->devices_cur = max;
314 udev_enumerate->devices_uptodate = true;
316 return udev_list_get_entry(&udev_enumerate->devices_list);
320 * udev_enumerate_add_match_subsystem:
321 * @udev_enumerate: context
322 * @subsystem: filter for a subsystem of the device to include in the list
324 * Returns: 0 on success, otherwise a negative error value.
326 _public_ int udev_enumerate_add_match_subsystem(struct udev_enumerate *udev_enumerate, const char *subsystem)
328 if (udev_enumerate == NULL)
330 if (subsystem == NULL)
332 if (udev_list_entry_add(&udev_enumerate->subsystem_match_list, subsystem, NULL) == NULL)
338 * udev_enumerate_add_nomatch_subsystem:
339 * @udev_enumerate: context
340 * @subsystem: filter for a subsystem of the device to exclude from the list
342 * Returns: 0 on success, otherwise a negative error value.
344 _public_ int udev_enumerate_add_nomatch_subsystem(struct udev_enumerate *udev_enumerate, const char *subsystem)
346 if (udev_enumerate == NULL)
348 if (subsystem == NULL)
350 if (udev_list_entry_add(&udev_enumerate->subsystem_nomatch_list, subsystem, NULL) == NULL)
356 * udev_enumerate_add_match_sysattr:
357 * @udev_enumerate: context
358 * @sysattr: filter for a sys attribute at the device to include in the list
359 * @value: optional value of the sys attribute
361 * Returns: 0 on success, otherwise a negative error value.
363 _public_ int udev_enumerate_add_match_sysattr(struct udev_enumerate *udev_enumerate, const char *sysattr, const char *value)
365 if (udev_enumerate == NULL)
369 if (udev_list_entry_add(&udev_enumerate->sysattr_match_list, sysattr, value) == NULL)
375 * udev_enumerate_add_nomatch_sysattr:
376 * @udev_enumerate: context
377 * @sysattr: filter for a sys attribute at the device to exclude from the list
378 * @value: optional value of the sys attribute
380 * Returns: 0 on success, otherwise a negative error value.
382 _public_ int udev_enumerate_add_nomatch_sysattr(struct udev_enumerate *udev_enumerate, const char *sysattr, const char *value)
384 if (udev_enumerate == NULL)
388 if (udev_list_entry_add(&udev_enumerate->sysattr_nomatch_list, sysattr, value) == NULL)
393 static int match_sysattr_value(struct udev_device *dev, const char *sysattr, const char *match_val)
395 const char *val = NULL;
398 val = udev_device_get_sysattr_value(dev, sysattr);
401 if (match_val == NULL) {
405 if (fnmatch(match_val, val, 0) == 0) {
414 * udev_enumerate_add_match_property:
415 * @udev_enumerate: context
416 * @property: filter for a property of the device to include in the list
417 * @value: value of the property
419 * Returns: 0 on success, otherwise a negative error value.
421 _public_ int udev_enumerate_add_match_property(struct udev_enumerate *udev_enumerate, const char *property, const char *value)
423 if (udev_enumerate == NULL)
425 if (property == NULL)
427 if (udev_list_entry_add(&udev_enumerate->properties_match_list, property, value) == NULL)
433 * udev_enumerate_add_match_tag:
434 * @udev_enumerate: context
435 * @tag: filter for a tag of the device to include in the list
437 * Returns: 0 on success, otherwise a negative error value.
439 _public_ int udev_enumerate_add_match_tag(struct udev_enumerate *udev_enumerate, const char *tag)
441 if (udev_enumerate == NULL)
445 if (udev_list_entry_add(&udev_enumerate->tags_match_list, tag, NULL) == NULL)
451 * udev_enumerate_add_match_parent:
452 * @udev_enumerate: context
453 * @parent: parent device where to start searching
455 * Return the devices on the subtree of one given device. The parent
456 * itself is included in the list.
458 * A reference for the device is held until the udev_enumerate context
461 * Returns: 0 on success, otherwise a negative error value.
463 _public_ int udev_enumerate_add_match_parent(struct udev_enumerate *udev_enumerate, struct udev_device *parent)
465 if (udev_enumerate == NULL)
469 if (udev_enumerate->parent_match != NULL)
470 udev_device_unref(udev_enumerate->parent_match);
471 udev_enumerate->parent_match = udev_device_ref(parent);
476 * udev_enumerate_add_match_is_initialized:
477 * @udev_enumerate: context
479 * Match only devices which udev has set up already. This makes
480 * sure, that the device node permissions and context are properly set
481 * and that network devices are fully renamed.
483 * Usually, devices which are found in the kernel but not already
484 * handled by udev, have still pending events. Services should subscribe
485 * to monitor events and wait for these devices to become ready, instead
486 * of using uninitialized devices.
488 * For now, this will not affect devices which do not have a device node
489 * and are not network interfaces.
491 * Returns: 0 on success, otherwise a negative error value.
493 _public_ int udev_enumerate_add_match_is_initialized(struct udev_enumerate *udev_enumerate)
495 if (udev_enumerate == NULL)
497 udev_enumerate->match_is_initialized = true;
502 * udev_enumerate_add_match_sysname:
503 * @udev_enumerate: context
504 * @sysname: filter for the name of the device to include in the list
506 * Returns: 0 on success, otherwise a negative error value.
508 _public_ int udev_enumerate_add_match_sysname(struct udev_enumerate *udev_enumerate, const char *sysname)
510 if (udev_enumerate == NULL)
514 if (udev_list_entry_add(&udev_enumerate->sysname_match_list, sysname, NULL) == NULL)
519 static bool match_sysattr(struct udev_enumerate *udev_enumerate, struct udev_device *dev)
521 struct udev_list_entry *list_entry;
524 udev_list_entry_foreach(list_entry, udev_list_get_entry(&udev_enumerate->sysattr_nomatch_list)) {
525 if (match_sysattr_value(dev, udev_list_entry_get_name(list_entry),
526 udev_list_entry_get_value(list_entry)))
530 if (udev_list_get_entry(&udev_enumerate->sysattr_match_list) != NULL) {
531 udev_list_entry_foreach(list_entry, udev_list_get_entry(&udev_enumerate->sysattr_match_list)) {
532 /* anything that does not match, will make it FALSE */
533 if (!match_sysattr_value(dev, udev_list_entry_get_name(list_entry),
534 udev_list_entry_get_value(list_entry)))
542 static bool match_property(struct udev_enumerate *udev_enumerate, struct udev_device *dev)
544 struct udev_list_entry *list_entry;
547 /* no match always matches */
548 if (udev_list_get_entry(&udev_enumerate->properties_match_list) == NULL)
551 /* loop over matches */
552 udev_list_entry_foreach(list_entry, udev_list_get_entry(&udev_enumerate->properties_match_list)) {
553 const char *match_key = udev_list_entry_get_name(list_entry);
554 const char *match_value = udev_list_entry_get_value(list_entry);
555 struct udev_list_entry *property_entry;
557 /* loop over device properties */
558 udev_list_entry_foreach(property_entry, udev_device_get_properties_list_entry(dev)) {
559 const char *dev_key = udev_list_entry_get_name(property_entry);
560 const char *dev_value = udev_list_entry_get_value(property_entry);
562 if (fnmatch(match_key, dev_key, 0) != 0)
564 if (match_value == NULL && dev_value == NULL) {
568 if (match_value == NULL || dev_value == NULL)
570 if (fnmatch(match_value, dev_value, 0) == 0) {
580 static bool match_tag(struct udev_enumerate *udev_enumerate, struct udev_device *dev)
582 struct udev_list_entry *list_entry;
584 /* no match always matches */
585 if (udev_list_get_entry(&udev_enumerate->tags_match_list) == NULL)
588 /* loop over matches */
589 udev_list_entry_foreach(list_entry, udev_list_get_entry(&udev_enumerate->tags_match_list))
590 if (!udev_device_has_tag(dev, udev_list_entry_get_name(list_entry)))
596 static bool match_parent(struct udev_enumerate *udev_enumerate, struct udev_device *dev)
600 if (udev_enumerate->parent_match == NULL)
603 parent = udev_device_get_devpath(udev_enumerate->parent_match);
604 return strncmp(parent, udev_device_get_devpath(dev), strlen(parent)) == 0;
607 static bool match_sysname(struct udev_enumerate *udev_enumerate, const char *sysname)
609 struct udev_list_entry *list_entry;
611 if (udev_list_get_entry(&udev_enumerate->sysname_match_list) == NULL)
614 udev_list_entry_foreach(list_entry, udev_list_get_entry(&udev_enumerate->sysname_match_list)) {
615 if (fnmatch(udev_list_entry_get_name(list_entry), sysname, 0) != 0)
622 static int scan_dir_and_add_devices(struct udev_enumerate *udev_enumerate,
623 const char *basedir, const char *subdir1, const char *subdir2)
625 char path[UTIL_PATH_SIZE];
632 l = util_strpcpyl(&s, sizeof(path), "/sys/", basedir, NULL);
634 l = util_strpcpyl(&s, l, "/", subdir1, NULL);
636 util_strpcpyl(&s, l, "/", subdir2, NULL);
640 for (dent = readdir(dir); dent != NULL; dent = readdir(dir)) {
641 char syspath[UTIL_PATH_SIZE];
642 struct udev_device *dev;
644 if (dent->d_name[0] == '.')
647 if (!match_sysname(udev_enumerate, dent->d_name))
650 util_strscpyl(syspath, sizeof(syspath), path, "/", dent->d_name, NULL);
651 dev = udev_device_new_from_syspath(udev_enumerate->udev, syspath);
655 if (udev_enumerate->match_is_initialized) {
657 * All devices with a device node or network interfaces
658 * possibly need udev to adjust the device node permission
659 * or context, or rename the interface before it can be
660 * reliably used from other processes.
662 * For now, we can only check these types of devices, we
663 * might not store a database, and have no way to find out
664 * for all other types of devices.
666 if (!udev_device_get_is_initialized(dev) &&
667 (major(udev_device_get_devnum(dev)) > 0 || udev_device_get_ifindex(dev) > 0))
670 if (!match_parent(udev_enumerate, dev))
672 if (!match_tag(udev_enumerate, dev))
674 if (!match_property(udev_enumerate, dev))
676 if (!match_sysattr(udev_enumerate, dev))
679 syspath_add(udev_enumerate, udev_device_get_syspath(dev));
681 udev_device_unref(dev);
687 static bool match_subsystem(struct udev_enumerate *udev_enumerate, const char *subsystem)
689 struct udev_list_entry *list_entry;
691 udev_list_entry_foreach(list_entry, udev_list_get_entry(&udev_enumerate->subsystem_nomatch_list)) {
692 if (fnmatch(udev_list_entry_get_name(list_entry), subsystem, 0) == 0)
695 if (udev_list_get_entry(&udev_enumerate->subsystem_match_list) != NULL) {
696 udev_list_entry_foreach(list_entry, udev_list_get_entry(&udev_enumerate->subsystem_match_list)) {
697 if (fnmatch(udev_list_entry_get_name(list_entry), subsystem, 0) == 0)
705 static int scan_dir(struct udev_enumerate *udev_enumerate, const char *basedir, const char *subdir, const char *subsystem)
707 char path[UTIL_PATH_SIZE];
711 util_strscpyl(path, sizeof(path), "/sys/", basedir, NULL);
715 for (dent = readdir(dir); dent != NULL; dent = readdir(dir)) {
716 if (dent->d_name[0] == '.')
718 if (!match_subsystem(udev_enumerate, subsystem != NULL ? subsystem : dent->d_name))
720 scan_dir_and_add_devices(udev_enumerate, basedir, dent->d_name, subdir);
727 * udev_enumerate_add_syspath:
728 * @udev_enumerate: context
729 * @syspath: path of a device
731 * Add a device to the list of devices, to retrieve it back sorted in dependency order.
733 * Returns: 0 on success, otherwise a negative error value.
735 _public_ int udev_enumerate_add_syspath(struct udev_enumerate *udev_enumerate, const char *syspath)
737 struct udev_device *udev_device;
739 if (udev_enumerate == NULL)
743 /* resolve to real syspath */
744 udev_device = udev_device_new_from_syspath(udev_enumerate->udev, syspath);
745 if (udev_device == NULL)
747 syspath_add(udev_enumerate, udev_device_get_syspath(udev_device));
748 udev_device_unref(udev_device);
752 static int scan_devices_tags(struct udev_enumerate *udev_enumerate)
754 struct udev_list_entry *list_entry;
756 /* scan only tagged devices, use tags reverse-index, instead of searching all devices in /sys */
757 udev_list_entry_foreach(list_entry, udev_list_get_entry(&udev_enumerate->tags_match_list)) {
760 char path[UTIL_PATH_SIZE];
762 util_strscpyl(path, sizeof(path), "/run/udev/tags/", udev_list_entry_get_name(list_entry), NULL);
766 for (dent = readdir(dir); dent != NULL; dent = readdir(dir)) {
767 struct udev_device *dev;
769 if (dent->d_name[0] == '.')
772 dev = udev_device_new_from_id_filename(udev_enumerate->udev, dent->d_name);
776 if (!match_subsystem(udev_enumerate, udev_device_get_subsystem(dev)))
778 if (!match_sysname(udev_enumerate, udev_device_get_sysname(dev)))
780 if (!match_parent(udev_enumerate, dev))
782 if (!match_property(udev_enumerate, dev))
784 if (!match_sysattr(udev_enumerate, dev))
787 syspath_add(udev_enumerate, udev_device_get_syspath(dev));
789 udev_device_unref(dev);
796 static int parent_add_child(struct udev_enumerate *enumerate, const char *path)
798 struct udev_device *dev;
800 dev = udev_device_new_from_syspath(enumerate->udev, path);
804 if (!match_subsystem(enumerate, udev_device_get_subsystem(dev)))
806 if (!match_sysname(enumerate, udev_device_get_sysname(dev)))
808 if (!match_property(enumerate, dev))
810 if (!match_sysattr(enumerate, dev))
813 syspath_add(enumerate, udev_device_get_syspath(dev));
814 udev_device_unref(dev);
818 static int parent_crawl_children(struct udev_enumerate *enumerate, const char *path, int maxdepth)
827 for (dent = readdir(d); dent != NULL; dent = readdir(d)) {
830 if (dent->d_name[0] == '.')
832 if (dent->d_type != DT_DIR)
834 if (asprintf(&child, "%s/%s", path, dent->d_name) < 0)
836 parent_add_child(enumerate, child);
838 parent_crawl_children(enumerate, child, maxdepth-1);
846 static int scan_devices_children(struct udev_enumerate *enumerate)
850 path = udev_device_get_syspath(enumerate->parent_match);
851 parent_add_child(enumerate, path);
852 return parent_crawl_children(enumerate, path, 256);
855 static int scan_devices_all(struct udev_enumerate *udev_enumerate)
859 if (stat("/sys/subsystem", &statbuf) == 0) {
860 /* we have /subsystem/, forget all the old stuff */
861 scan_dir(udev_enumerate, "subsystem", "devices", NULL);
863 scan_dir(udev_enumerate, "bus", "devices", NULL);
864 scan_dir(udev_enumerate, "class", NULL, NULL);
870 * udev_enumerate_scan_devices:
871 * @udev_enumerate: udev enumeration context
873 * Returns: 0 on success, otherwise a negative error value.
875 _public_ int udev_enumerate_scan_devices(struct udev_enumerate *udev_enumerate)
877 if (udev_enumerate == NULL)
880 /* efficiently lookup tags only, we maintain a reverse-index */
881 if (udev_list_get_entry(&udev_enumerate->tags_match_list) != NULL)
882 return scan_devices_tags(udev_enumerate);
884 /* walk the subtree of one parent device only */
885 if (udev_enumerate->parent_match != NULL)
886 return scan_devices_children(udev_enumerate);
888 /* scan devices of all subsystems */
889 return scan_devices_all(udev_enumerate);
893 * udev_enumerate_scan_subsystems:
894 * @udev_enumerate: udev enumeration context
896 * Returns: 0 on success, otherwise a negative error value.
898 _public_ int udev_enumerate_scan_subsystems(struct udev_enumerate *udev_enumerate)
901 const char *subsysdir;
903 if (udev_enumerate == NULL)
906 /* all kernel modules */
907 if (match_subsystem(udev_enumerate, "module"))
908 scan_dir_and_add_devices(udev_enumerate, "module", NULL, NULL);
910 if (stat("/sys/subsystem", &statbuf) == 0)
911 subsysdir = "subsystem";
915 /* all subsystems (only buses support coldplug) */
916 if (match_subsystem(udev_enumerate, "subsystem"))
917 scan_dir_and_add_devices(udev_enumerate, subsysdir, NULL, NULL);
919 /* all subsystem drivers */
920 if (match_subsystem(udev_enumerate, "drivers"))
921 scan_dir(udev_enumerate, subsysdir, "drivers", "drivers");