- if (dev->symlink[0] != '\0') {
- symlinks = dev->symlink;
- while (1) {
- linkname = strsep(&symlinks, " ");
- if (linkname == NULL)
- break;
-
- strfieldcpy(filename, udev_root);
- strfieldcat(filename, linkname);
-
- dbg("unlinking symlink '%s'", filename);
- retval = unlink(filename);
- if (retval) {
- dbg("unlink(%s) failed with error '%s'",
- filename, strerror(errno));
- return retval;
- }
- if (strchr(dev->symlink, '/')) {
- delete_path(filename);
- }
+ foreach_strpart(dev->symlink, " ", pos, len) {
+ strfieldcpymax(linkname, pos, len+1);
+ strfieldcpy(filename, udev_root);
+ strfieldcat(filename, linkname);
+
+ 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(dev->symlink, '/')) {
+ delete_path(filename);