From 08183c4b90505866e806d308213d0a2d293b2659 Mon Sep 17 00:00:00 2001 From: "jkluebs@luebsphoto.com" Date: Thu, 10 Mar 2005 17:34:31 +0100 Subject: [PATCH] [PATCH] This patch causes the remove handler to check that each symlink --- udev_remove.c | 46 +++++++++++++++++++++++----------------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/udev_remove.c b/udev_remove.c index 1fd36d24..c3a7880b 100644 --- a/udev_remove.c +++ b/udev_remove.c @@ -78,13 +78,33 @@ static int delete_node(struct udevice *udev) int i; int num; + list_for_each_entry(name_loop, &udev->symlink_list, node) { + snprintf(filename, sizeof(filename), "%s/%s", udev_root, name_loop->name); + filename[sizeof(filename)-1] = '\0'; + + if (stat(filename, &stats) != 0) { + dbg("symlink '%s' not found", filename); + continue; + } + if (udev->devt && stats.st_rdev != udev->devt) { + info("symlink '%s' points to a different device, skip removal", filename); + continue;; + } + + dbg("removing symlink '%s'", filename); + unlink(filename); + + if (strchr(filename, '/')) + delete_path(filename); + } + snprintf(filename, sizeof(filename), "%s/%s", udev_root, udev->name); filename[sizeof(filename)-1] = '\0'; - dbg("checking major/minor of device node '%s'", filename); - if (stat(filename, &stats) != 0) + if (stat(filename, &stats) != 0) { + dbg("device node '%s' not found", filename); return -1; - + } if (udev->devt && stats.st_rdev != udev->devt) { info("device node '%s' points to a different device, skip removal", filename); return -1; @@ -95,7 +115,6 @@ static int delete_node(struct udevice *udev) if (retval) return retval; - /* remove all_partitions nodes */ num = udev->partitions; if (num > 0) { info("removing all_partitions '%s[1-%i]'", filename, num); @@ -110,28 +129,9 @@ static int delete_node(struct udevice *udev) } } - /* remove subdirectories */ if (strchr(udev->name, '/')) delete_path(filename); - list_for_each_entry(name_loop, &udev->symlink_list, node) { - snprintf(filename, sizeof(filename), "%s/%s", udev_root, name_loop->name); - filename[sizeof(filename)-1] = '\0'; - - dbg("unlinking symlink '%s'", filename); - retval = unlink(filename); - if (errno == ENOENT) - retval = 0; - if (retval) { - dbg("unlink(%s) failed with error '%s'", - filename, strerror(errno)); - return retval; - } - if (strchr(filename, '/')) { - delete_path(filename); - } - } - return retval; } -- 2.39.5