{
char p[UTIL_PATH_SIZE];
char *pos;
- int retval;
+ int err = 0;
if (path[0] == '/')
while(path[1] == '/')
if ((pos == p) || (pos == NULL))
break;
- /* remove if empty */
- retval = rmdir(p);
- if (errno == ENOENT)
- retval = 0;
- if (retval) {
- if (errno == ENOTEMPTY)
- return 0;
- err(udev, "rmdir(%s) failed: %m\n", p);
+ err = rmdir(p);
+ if (err < 0) {
+ if (errno == ENOENT)
+ err = 0;
break;
}
- dbg(udev, "removed '%s'\n", p);
}
- return 0;
+ return err;
}
/* Reset permissions on the device node, before unlinking it to make sure,
if (!add) {
dbg(udev, "removing index: '%s'\n", filename);
- unlink(filename);
- util_delete_path(udev, filename);
+ if (unlink(filename) == 0)
+ rmdir(dirname);
}
target = link_find_prioritized(dev, add, dirname, buf, sizeof(buf));
if (target == NULL) {
info(udev, "no reference left, remove '%s'\n", slink);
- unlink(slink);
- util_delete_path(udev, slink);
+ if (unlink(slink) == 0)
+ util_delete_path(udev, slink);
} else {
info(udev, "creating link '%s' to '%s'\n", slink, target);
node_symlink(udev, target, slink);
info(udev, "removing device node '%s'\n", devnode);
err = util_unlink_secure(udev, devnode);
- util_delete_path(udev, devnode);
+ if (err == 0)
+ util_delete_path(udev, devnode);
out:
return err;
}