summaryrefslogtreecommitdiff
path: root/udev/lib/libudev-device.c
diff options
context:
space:
mode:
authorKay Sievers <kay.sievers@vrfy.org>2008-10-06 13:52:43 +0200
committerKay Sievers <kay.sievers@vrfy.org>2008-10-06 13:52:43 +0200
commit1e75cda3454d08ff880600f86d296a23bfa1f996 (patch)
treef2150324551072d7089a9c4bf275b1f55b4fe542 /udev/lib/libudev-device.c
parentfa03f6ae4b76d7f4cbf61c328ffdd0265f7476c2 (diff)
store node name and symlinks into db symlink target if they are small enough
Diffstat (limited to 'udev/lib/libudev-device.c')
-rw-r--r--udev/lib/libudev-device.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/udev/lib/libudev-device.c b/udev/lib/libudev-device.c
index 8e4360a7f4..2113ebd43c 100644
--- a/udev/lib/libudev-device.c
+++ b/udev/lib/libudev-device.c
@@ -83,6 +83,7 @@ static int device_read_db(struct udev_device *udev_device)
if ((stats.st_mode & S_IFMT) == S_IFLNK) {
char target[UTIL_PATH_SIZE];
int target_len;
+ char *next;
target_len = readlink(filename, target, sizeof(target));
if (target_len > 0)
@@ -91,8 +92,29 @@ static int device_read_db(struct udev_device *udev_device)
info(udev_device->udev, "error reading db link %s: %m\n", filename);
return -1;
}
+
+ next = strchr(target, ' ');
+ if (next != NULL) {
+ next[0] = '\0';
+ next = &next[1];
+ }
if (asprintf(&udev_device->devnode, "%s/%s", udev_get_dev_path(udev_device->udev), target) < 0)
return -ENOMEM;
+ while (next != NULL) {
+ char linkname[UTIL_PATH_SIZE];
+ const char *lnk;
+
+ lnk = next;
+ next = strchr(next, ' ');
+ if (next != NULL) {
+ next[0] = '\0';
+ next = &next[1];
+ }
+ util_strlcpy(linkname, udev_get_dev_path(udev_device->udev), sizeof(linkname));
+ util_strlcat(linkname, "/", sizeof(linkname));
+ util_strlcat(linkname, next, sizeof(linkname));
+ device_add_devlink(udev_device, linkname);
+ }
info(udev_device->udev, "device %p filled with db symlink data '%s'\n", udev_device, udev_device->devnode);
return 0;
}