summaryrefslogtreecommitdiff
path: root/libudev/libudev-device.c
diff options
context:
space:
mode:
authorKay Sievers <kay.sievers@vrfy.org>2009-09-09 18:18:17 +0200
committerKay Sievers <kay.sievers@vrfy.org>2009-09-09 18:49:07 +0200
commit6c29f2b942358d4dd9d3e7c65c13c3612dded3cc (patch)
tree2604ad41d6cd00785e13caa5515996acc3e942ee /libudev/libudev-device.c
parent7f06ec2e19387424de34bae35320c2fe192cb69d (diff)
simplify "symlink name stack"
With well defined and kernel-supplied node names, we no longer need to support a possible stack of conflicting symlinks and node names. Only symlinks with identical names can be claimed by multiple devices. This shrinks the former /dev/.udev/names/ significantly. Also the /dev/{block,char}/MAJ:MIN" links are excluded from the name stack - they are unique and can not conflict.
Diffstat (limited to 'libudev/libudev-device.c')
-rw-r--r--libudev/libudev-device.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/libudev/libudev-device.c b/libudev/libudev-device.c
index 22d8349275..5d1ad9f223 100644
--- a/libudev/libudev-device.c
+++ b/libudev/libudev-device.c
@@ -123,7 +123,7 @@ int udev_device_read_db(struct udev_device *udev_device)
next = &next[1];
}
util_strscpyl(devlink, sizeof(devlink), udev_get_dev_path(udev_device->udev), "/", lnk, NULL);
- udev_device_add_devlink(udev_device, devlink);
+ udev_device_add_devlink(udev_device, devlink, 0);
}
info(udev_device->udev, "device %p filled with db symlink data '%s'\n", udev_device, udev_device->devnode);
return 0;
@@ -150,7 +150,7 @@ int udev_device_read_db(struct udev_device *udev_device)
break;
case 'S':
util_strscpyl(filename, sizeof(filename), udev_get_dev_path(udev_device->udev), "/", val, NULL);
- udev_device_add_devlink(udev_device, filename);
+ udev_device_add_devlink(udev_device, filename, 0);
break;
case 'L':
udev_device_set_devlink_priority(udev_device, atoi(val));
@@ -1118,11 +1118,16 @@ int udev_device_set_devnode(struct udev_device *udev_device, const char *devnode
return 0;
}
-int udev_device_add_devlink(struct udev_device *udev_device, const char *devlink)
+int udev_device_add_devlink(struct udev_device *udev_device, const char *devlink, int unique)
{
+ struct udev_list_entry *list_entry;
+
udev_device->devlinks_uptodate = 0;
- if (udev_list_entry_add(udev_device->udev, &udev_device->devlinks_list, devlink, NULL, 1, 0) == NULL)
+ list_entry = udev_list_entry_add(udev_device->udev, &udev_device->devlinks_list, devlink, NULL, 1, 0);
+ if (list_entry == NULL)
return -ENOMEM;
+ if (unique)
+ udev_list_entry_set_flag(list_entry, 1);
return 0;
}