chiark / gitweb /
[PATCH] add wait_for_sysfs test script to the tarball to help people debug their...
[elogind.git] / udev_remove.c
index 7ad7c2402a8e05f77d23a1451ab9b891372a8116..d4be8bd6f9cd6c8e5ed214964339e21032df90df 100644 (file)
@@ -109,6 +109,7 @@ static int delete_node(struct udevice *dev)
        int i;
        char *pos;
        int len;
+       int num;
 
        strfieldcpy(filename, udev_root);
        strfieldcat(filename, dev->name);
@@ -118,10 +119,15 @@ static int delete_node(struct udevice *dev)
        if (retval)
                return retval;
 
-       /* remove partition nodes */
-       if (dev->partitions > 0) {
-               info("removing partitions '%s[1-%i]'", filename, dev->partitions);
-               for (i = 1; i <= dev->partitions; i++) {
+       /* remove all_partitions nodes */
+       num = dev->partitions;
+       if (num > 0) {
+               info("removing all_partitions '%s[1-%i]'", filename, num);
+               if (num > PARTITIONS_COUNT) {
+                       info("garbage from udev database, skip all_partitions removal");
+                       return -1;
+               }
+               for (i = 1; i <= num; i++) {
                        strfieldcpy(partitionname, filename);
                        strintcat(partitionname, i);
                        secure_unlink(partitionname);