summaryrefslogtreecommitdiff
path: root/udev_remove.c
diff options
context:
space:
mode:
authorjkluebs@luebsphoto.com <jkluebs@luebsphoto.com>2005-03-10 17:34:31 +0100
committerGreg KH <gregkh@suse.de>2005-04-26 23:51:00 -0700
commit08183c4b90505866e806d308213d0a2d293b2659 (patch)
tree1843b2b5e44a6f3a3efa4c50795dbafc6b6547b5 /udev_remove.c
parent143139a1844dcf96f644f482d6cba007bb6f4fb9 (diff)
[PATCH] This patch causes the remove handler to check that each symlink
Diffstat (limited to 'udev_remove.c')
-rw-r--r--udev_remove.c46
1 files changed, 23 insertions, 23 deletions
diff --git a/udev_remove.c b/udev_remove.c
index 1fd36d24c5..c3a7880b49 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;
}