summaryrefslogtreecommitdiff
path: root/udev/lib/libudev-device.c
diff options
context:
space:
mode:
authorKay Sievers <kay.sievers@vrfy.org>2008-09-28 17:39:31 +0200
committerKay Sievers <kay.sievers@vrfy.org>2008-09-28 17:39:31 +0200
commitbc8184ede9cff156709fe053e3e02ef309cb2920 (patch)
tree60789acfeb936b123de0c311d5a7236dc9310267 /udev/lib/libudev-device.c
parent41b7a00922bdb1a501cbf2e39282fe64bb94cb6d (diff)
libudev: enumerate - accept list of subsystems to scan, or skip
Diffstat (limited to 'udev/lib/libudev-device.c')
-rw-r--r--udev/lib/libudev-device.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/udev/lib/libudev-device.c b/udev/lib/libudev-device.c
index a201fb25df..3437d69798 100644
--- a/udev/lib/libudev-device.c
+++ b/udev/lib/libudev-device.c
@@ -252,7 +252,7 @@ struct udev_device *udev_device_new_from_syspath(struct udev *udev, const char *
subdir = &syspath[len+1];
pos = strrchr(subdir, '/');
if (pos == NULL || pos < &subdir[2]) {
- info(udev, "not in subdir :%s\n", syspath);
+ info(udev, "not a subdir :%s\n", syspath);
return NULL;
}
@@ -312,8 +312,11 @@ struct udev_device *udev_device_new_from_devnum(struct udev *udev, char type, de
if (util_resolve_sys_link(udev, path, sizeof(path)) == 0)
return udev_device_new_from_syspath(udev, path);
- /* fallback to search all sys devices for the major/minor */
- enumerate = udev_enumerate_new_from_subsystems(udev, NULL);
+ /* fallback to search sys devices for the major/minor */
+ if (type == 'b')
+ enumerate = udev_enumerate_new_from_devices(udev, "block", NULL);
+ else if (type == 'c')
+ enumerate = udev_enumerate_new_from_devices(udev, "!block", NULL);
if (enumerate == NULL)
return NULL;
udev_list_entry_foreach(list_entry, udev_enumerate_get_list_entry(enumerate)) {
@@ -322,6 +325,13 @@ struct udev_device *udev_device_new_from_devnum(struct udev *udev, char type, de
device_loop = udev_device_new_from_syspath(udev, udev_list_entry_get_name(list_entry));
if (device_loop != NULL) {
if (udev_device_get_devnum(device_loop) == devnum) {
+ const char *subsystem;
+
+ subsystem = udev_device_get_subsystem(device_loop);
+ if (type == 'b' && strcmp(subsystem, "block") != 0)
+ continue;
+ if (type == 'c' && strcmp(subsystem, "block") == 0)
+ continue;
device = device_loop;
break;
}