summaryrefslogtreecommitdiff
path: root/libudev
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
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')
-rw-r--r--libudev/libudev-device.c13
-rw-r--r--libudev/libudev-monitor.c4
-rw-r--r--libudev/libudev-private.h2
3 files changed, 12 insertions, 7 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;
}
diff --git a/libudev/libudev-monitor.c b/libudev/libudev-monitor.c
index 657f23d727..ee855afac4 100644
--- a/libudev/libudev-monitor.c
+++ b/libudev/libudev-monitor.c
@@ -628,12 +628,12 @@ retry:
next = strchr(slink, ' ');
while (next != NULL) {
next[0] = '\0';
- udev_device_add_devlink(udev_device, slink);
+ udev_device_add_devlink(udev_device, slink, 0);
slink = &next[1];
next = strchr(slink, ' ');
}
if (slink[0] != '\0')
- udev_device_add_devlink(udev_device, slink);
+ udev_device_add_devlink(udev_device, slink, 0);
} else if (strncmp(key, "DRIVER=", 7) == 0) {
udev_device_set_driver(udev_device, &key[7]);
} else if (strncmp(key, "ACTION=", 7) == 0) {
diff --git a/libudev/libudev-private.h b/libudev/libudev-private.h
index e90c79cb3e..285b9d48c1 100644
--- a/libudev/libudev-private.h
+++ b/libudev/libudev-private.h
@@ -69,7 +69,7 @@ int udev_device_set_syspath(struct udev_device *udev_device, const char *syspath
int udev_device_set_subsystem(struct udev_device *udev_device, const char *subsystem);
int udev_device_set_devtype(struct udev_device *udev_device, const char *devtype);
int udev_device_set_devnode(struct udev_device *udev_device, const char *devnode);
-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);
void udev_device_cleanup_devlinks_list(struct udev_device *udev_device);
struct udev_list_entry *udev_device_add_property(struct udev_device *udev_device, const char *key, const char *value);
struct udev_list_entry *udev_device_add_property_from_string(struct udev_device *udev_device, const char *property);