From 4281da1fa6fda10c15bee984825fc607a8385004 Mon Sep 17 00:00:00 2001 From: Kay Sievers Date: Fri, 10 Dec 2010 01:13:35 +0100 Subject: udevd: use dev_t or netif ifindex as database key We need to preserve the database of network interfaces while we rename them. Use the kernel's numbers wherever possible, instead of the device names. Fix wrong database filenames which contain a '/', translated from '!' in the kernel name. Fix segfault for kobject pathes where the subsystem can not be determined from sysfs. --- udev/udev-node.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'udev/udev-node.c') diff --git a/udev/udev-node.c b/udev/udev-node.c index c8113f10b0..92634427f9 100644 --- a/udev/udev-node.c +++ b/udev/udev-node.c @@ -298,10 +298,8 @@ static void link_update(struct udev_device *dev, const char *slink, bool add) dbg(udev, "update symlink '%s' of '%s'\n", slink, udev_device_get_syspath(dev)); util_path_encode(&slink[strlen(udev_get_dev_path(udev))+1], name_enc, sizeof(name_enc)); - snprintf(dirname, sizeof(dirname), "%s/.udev/links/%s", udev_get_dev_path(udev), name_enc); - snprintf(filename, sizeof(filename), "%s/%c%u:%u", dirname, - strcmp(udev_device_get_subsystem(dev), "block") == 0 ? 'b' : 'c', - major(udev_device_get_devnum(dev)), minor(udev_device_get_devnum(dev))); + util_strscpyl(dirname, sizeof(dirname), udev_get_dev_path(udev), "/.udev/links/", name_enc, NULL); + util_strscpyl(filename, sizeof(filename), dirname, "/", udev_device_get_id_filename(dev), NULL); if (!add) { dbg(udev, "removing index: '%s'\n", filename); -- cgit v1.2.3-54-g00ecf