diff options
author | Kay Sievers <kay.sievers@vrfy.org> | 2010-12-12 20:07:15 +0100 |
---|---|---|
committer | Kay Sievers <kay.sievers@vrfy.org> | 2010-12-12 20:07:15 +0100 |
commit | cad40a5fe75d876af22f68b688494b9cd98cc899 (patch) | |
tree | e83a3a87fe2d8e9de28febd10741a379ad711f63 /libudev/libudev-device.c | |
parent | 24d1076696ebe6696a8b8df414ab265aa6fc89c2 (diff) |
udevd: switch to common id_filename functions
Diffstat (limited to 'libudev/libudev-device.c')
-rw-r--r-- | libudev/libudev-device.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/libudev/libudev-device.c b/libudev/libudev-device.c index ac206a0e16..8698d98e1c 100644 --- a/libudev/libudev-device.c +++ b/libudev/libudev-device.c @@ -475,6 +475,32 @@ struct udev_device *udev_device_new_from_devnum(struct udev *udev, char type, de return udev_device_new_from_syspath(udev, path); } +struct udev_device *udev_device_new_from_id_filename(struct udev *udev, char *id) +{ + char type; + int maj, min; + char subsys[UTIL_PATH_SIZE]; + char *sysname; + + switch(id[0]) { + case 'b': + case 'c': + if (sscanf(id, "%c%i:%i", &type, &maj, &min) != 3) + return NULL; + return udev_device_new_from_devnum(udev, type, makedev(maj, min)); + case '+': + util_strscpy(subsys, sizeof(subsys), &id[1]); + sysname = strchr(subsys, ':'); + if (sysname == NULL) + return NULL; + sysname[0] = '\0'; + sysname = &sysname[1]; + return udev_device_new_from_subsystem_sysname(udev, subsys, sysname); + default: + return NULL; + } +} + /** * udev_device_new_from_subsystem_sysname: * @udev: udev library context |