summaryrefslogtreecommitdiff
path: root/udev/lib/libudev-device.c
diff options
context:
space:
mode:
authorKay Sievers <kay.sievers@vrfy.org>2008-09-21 23:28:56 -0700
committerKay Sievers <kay.sievers@vrfy.org>2008-09-21 23:28:56 -0700
commit4c9dff47f696b1e6c89cc6e0a7ba683067927821 (patch)
treeb2b2c472b551d62cc6bf9132b5d825c5fd490337 /udev/lib/libudev-device.c
parentfb762bb928772f1923fef1e342d8ebca9bf7691f (diff)
libudev: add udev_device_new_from_devnum()
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;