- snprintf(tmp, 64, "%s%s", uci_path, q->name);
- log_printf("unlinking %s\n", tmp);
- unlink(tmp);
+ char dev_link[64];
+
+ snprintf(dev_link, sizeof(dev_link), "%s%s", uci_path, q->name);
+ if (err == -EBUSY) {
+ /* Create "tmp" symlink to non-existing path */
+ snprintf(tmp, sizeof(tmp), "%s%s", uci_path, "tmp");
+ symlink("## DEVICE MISSING ##", tmp);
+
+ /* Replace old symlink with the not working one */
+ rename(tmp, dev_link);
+ } else {
+ log_printf("unlinking %s\n", dev_link);
+ unlink(dev_link);
+ }