summaryrefslogtreecommitdiff
path: root/udev/lib/libudev-utils.c
diff options
context:
space:
mode:
authorKay Sievers <kay.sievers@vrfy.org>2008-09-09 18:14:54 +0200
committerKay Sievers <kay.sievers@vrfy.org>2008-09-09 18:14:54 +0200
commit95d90c4fe0581d8b630c62e38591b3af960d131a (patch)
tree8f15713aa846bea364dd26351cc92f5c4f66ea31 /udev/lib/libudev-utils.c
parent9b3a33a9ff9386b4af3229762fa7673e670b00e7 (diff)
libudev: udev_device - read "driver" value
Diffstat (limited to 'udev/lib/libudev-utils.c')
-rw-r--r--udev/lib/libudev-utils.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/udev/lib/libudev-utils.c b/udev/lib/libudev-utils.c
index 8251b64da9..82acb1a481 100644
--- a/udev/lib/libudev-utils.c
+++ b/udev/lib/libudev-utils.c
@@ -32,7 +32,7 @@
#include "libudev-private.h"
#include "../udev.h"
-ssize_t util_get_sys_subsystem(struct udev *udev, const char *devpath, char *subsystem, size_t size)
+static ssize_t get_sys_link(struct udev *udev, const char *slink, const char *devpath, char *subsystem, size_t size)
{
char path[PATH_SIZE];
ssize_t len;
@@ -40,7 +40,8 @@ ssize_t util_get_sys_subsystem(struct udev *udev, const char *devpath, char *sub
strlcpy(path, udev_get_sys_path(udev), sizeof(path));
strlcat(path, devpath, sizeof(path));
- strlcat(path, "/subsystem", sizeof(path));
+ strlcat(path, "/", sizeof(path));
+ strlcat(path, slink, sizeof(path));
len = readlink(path, path, sizeof(path));
if (len < 0 || len >= (ssize_t) sizeof(path))
return -1;
@@ -51,3 +52,14 @@ ssize_t util_get_sys_subsystem(struct udev *udev, const char *devpath, char *sub
pos = &pos[1];
return strlcpy(subsystem, pos, size);
}
+
+ssize_t util_get_sys_subsystem(struct udev *udev, const char *devpath, char *subsystem, size_t size)
+{
+ return get_sys_link(udev, "subsystem", devpath, subsystem, size);
+}
+
+ssize_t util_get_sys_driver(struct udev *udev, const char *devpath, char *driver, size_t size)
+{
+ return get_sys_link(udev, "driver", devpath, driver, size);
+}
+