chiark / gitweb /
[PATCH] no error on enoent
[elogind.git] / udev-remove.c
index 8794429635bd0caec5f53b294dcd713464f720b2..dcd460bedcee56c3dc5aefa272d6ef94705c49d6 100644 (file)
@@ -51,6 +51,8 @@ static int delete_path(char *path)
 
                /* remove if empty */
                retval = rmdir(path);
+               if (errno == ENOENT)
+                       retval = 0;
                if (retval) {
                        if (errno == ENOTEMPTY)
                                return 0;
@@ -77,6 +79,8 @@ static int delete_node(struct udevice *dev)
 
        info("removing device node '%s'", filename);
        retval = unlink(filename);
+       if (errno == ENOENT)
+               retval = 0;
        if (retval) {
                dbg("unlink(%s) failed with error '%s'",
                        filename, strerror(errno));
@@ -87,7 +91,8 @@ static int delete_node(struct udevice *dev)
        if (dev->partitions > 0) {
                info("removing partitions '%s[1-%i]'", filename, dev->partitions);
                for (i = 1; i <= dev->partitions; i++) {
-                       sprintf(partitionname, "%s%i", filename, i);
+                       strfieldcpy(partitionname, filename);
+                       strintcat(partitionname, i);
                        unlink(partitionname);
                }
        }
@@ -108,6 +113,8 @@ static int delete_node(struct udevice *dev)
 
                        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));