1
1
mirror of https://github.com/systemd/systemd-stable.git synced 2024-10-30 06:25:25 +03:00

libudev: device - add get_parent_with_subsystem()

This commit is contained in:
Kay Sievers 2008-10-02 21:19:00 +02:00
parent e598c5738c
commit 98f10a9e2a
4 changed files with 19 additions and 0 deletions

1
TODO
View File

@ -1,4 +1,5 @@
convert usb_id to libudev's udev_device
add DEVTYPE
o handle spaces in SYMLINK+=, do not create multiple links
o use libudev device in udev_rules.c

View File

@ -16,6 +16,7 @@ udev_list_entry_get_value
udev_device_new_from_syspath
udev_device_new_from_devnum
udev_device_get_parent
udev_device_get_parent_with_subsystem
udev_device_ref
udev_device_unref
udev_device_get_udev

View File

@ -404,6 +404,22 @@ struct udev_device *udev_device_get_parent(struct udev_device *udev_device)
return udev_device->parent_device;
}
struct udev_device *udev_device_get_parent_with_subsystem(struct udev_device *udev_device, const char *subsystem)
{
struct udev_device *parent;
parent = udev_device_get_parent(udev_device);
while (parent != NULL) {
const char *parent_subsystem;
parent_subsystem = udev_device_get_subsystem(parent);
if (parent_subsystem != NULL && strcmp(parent_subsystem, subsystem) == 0)
break;
parent = udev_device_get_parent(parent);
}
return parent;
}
/**
* udev_device_get_udev:
* @udev_device: udev device

View File

@ -60,6 +60,7 @@ struct udev_device;
extern struct udev_device *udev_device_new_from_syspath(struct udev *udev, const char *syspath);
extern struct udev_device *udev_device_new_from_devnum(struct udev *udev, char type, dev_t devnum);
extern struct udev_device *udev_device_get_parent(struct udev_device *udev_device);
extern struct udev_device *udev_device_get_parent_with_subsystem(struct udev_device *udev_device, const char *subsystem);
extern struct udev_device *udev_device_ref(struct udev_device *udev_device);
extern void udev_device_unref(struct udev_device *udev_device);
extern struct udev *udev_device_get_udev(struct udev_device *udev_device);