summaryrefslogtreecommitdiff
path: root/udev/lib/libudev-device.c
diff options
context:
space:
mode:
Diffstat (limited to 'udev/lib/libudev-device.c')
-rw-r--r--udev/lib/libudev-device.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/udev/lib/libudev-device.c b/udev/lib/libudev-device.c
index 731230efd0..8103c7fcc4 100644
--- a/udev/lib/libudev-device.c
+++ b/udev/lib/libudev-device.c
@@ -216,6 +216,20 @@ struct udev_device *udev_device_new_from_syspath(struct udev *udev, const char *
return udev_device;
}
+struct udev_device *udev_device_new_from_devnum(struct udev *udev, char type, dev_t devnum)
+{
+ char path[UTIL_PATH_SIZE];
+
+ snprintf(path, sizeof(path), "%s/dev/%s/%u:%u",
+ udev_get_sys_path(udev),
+ type == 'b' ? "block" : "char",
+ major(devnum), minor(devnum));
+ if (util_resolve_sys_link(udev, path, sizeof(path)) < 0)
+ return NULL;
+
+ return udev_device_new_from_syspath(udev, path);
+}
+
static struct udev_device *device_new_from_parent(struct udev_device *udev_device)
{
struct udev_device *udev_device_parent = NULL;