diff options
author | Kay Sievers <kay.sievers@vrfy.org> | 2008-09-21 23:28:56 -0700 |
---|---|---|
committer | Kay Sievers <kay.sievers@vrfy.org> | 2008-09-21 23:28:56 -0700 |
commit | 4c9dff47f696b1e6c89cc6e0a7ba683067927821 (patch) | |
tree | b2b2c472b551d62cc6bf9132b5d825c5fd490337 /udev/lib/test-libudev.c | |
parent | fb762bb928772f1923fef1e342d8ebca9bf7691f (diff) |
libudev: add udev_device_new_from_devnum()
Diffstat (limited to 'udev/lib/test-libudev.c')
-rw-r--r-- | udev/lib/test-libudev.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/udev/lib/test-libudev.c b/udev/lib/test-libudev.c index 0a0d754b38..8afd294a2f 100644 --- a/udev/lib/test-libudev.c +++ b/udev/lib/test-libudev.c @@ -24,6 +24,7 @@ #include <string.h> #include <getopt.h> #include <syslog.h> +#include <fcntl.h> #include <sys/select.h> #include "libudev.h" @@ -114,6 +115,20 @@ static int test_device_parents(struct udev *udev, const char *syspath) return 0; } +static int test_device_devnum(struct udev *udev) +{ + dev_t devnum = makedev(1, 3); + struct udev_device *device; + + printf("looking up device: %u:%u\n", major(devnum), minor(devnum)); + device = udev_device_new_from_devnum(udev, 'c', devnum); + if (device == NULL) + return -1; + print_device(device); + udev_device_unref(device); + return 0; +} + static int devices_enum_cb(struct udev_device *device, void *data) { printf("device: '%s' (%s) '%s'\n", @@ -253,6 +268,7 @@ int main(int argc, char *argv[], char *envp[]) } test_device(udev, syspath); + test_device_devnum(udev); test_device_parents(udev, syspath); test_enumerate(udev, subsystem); test_monitor(udev, socket); |