- retval = chown(filename, 0, 0);
- if (retval) {
- dbg("chown(%s, 0, 0) failed with error '%s'",
- filename, strerror(errno));
- /* We continue nevertheless.
- * I think it's very unlikely for chown
- * to fail here, if the file exists.
- */
- }
- retval = chmod(filename, 0000);
- if (retval) {
- dbg("chmod(%s, 0000) failed with error '%s'",
- filename, strerror(errno));
- /* We continue nevertheless. */
- }
- retval = unlink(filename);
- if (errno == ENOENT)
- retval = 0;
- if (retval) {
- dbg("unlink(%s) failed with error '%s'",
- filename, strerror(errno));
+ 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;;
+ }
+
+ info("removing symlink '%s'", filename);
+ unlink(filename);
+
+ if (strchr(filename, '/'))
+ delete_path(filename);