summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKay Sievers <kay.sievers@vrfy.org>2011-07-08 00:57:58 +0200
committerKay Sievers <kay.sievers@vrfy.org>2011-07-08 00:57:58 +0200
commit6ed03d1e2c1e2e300dda7a7cf4a5ffe10ef18356 (patch)
tree2a0e6af44232e5d34a01dd603f6bc1bd52b971bd
parentb05211fa3e19608f96db53f388959ab57f88c566 (diff)
libudev: enumerate - include parent device itself with match_parent()
-rw-r--r--libudev/libudev-enumerate.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/libudev/libudev-enumerate.c b/libudev/libudev-enumerate.c
index 320ab66647..399bbdaf46 100644
--- a/libudev/libudev-enumerate.c
+++ b/libudev/libudev-enumerate.c
@@ -862,6 +862,15 @@ static int parent_crawl_children(struct udev_enumerate *enumerate, const char *p
return 0;
}
+static int scan_devices_children(struct udev_enumerate *enumerate)
+{
+ const char *path;
+
+ path = udev_device_get_syspath(enumerate->parent_match);
+ parent_add_child(enumerate, path);
+ return parent_crawl_children(enumerate, path, 256);
+}
+
static int scan_devices_all(struct udev_enumerate *udev_enumerate)
{
struct udev *udev = udev_enumerate_get_udev(udev_enumerate);
@@ -893,12 +902,15 @@ UDEV_EXPORT int udev_enumerate_scan_devices(struct udev_enumerate *udev_enumerat
if (udev_enumerate == NULL)
return -EINVAL;
+ /* efficiently lookup tags only, we maintain a reverse-index */
if (udev_list_get_entry(&udev_enumerate->tags_match_list) != NULL)
return scan_devices_tags(udev_enumerate);
+ /* walk the subtree of one parent device only */
if (udev_enumerate->parent_match != NULL)
- return parent_crawl_children(udev_enumerate, udev_device_get_syspath(udev_enumerate->parent_match), 256);
+ return scan_devices_children(udev_enumerate);
+ /* scan devices of all subsystems */
return scan_devices_all(udev_enumerate);
}