File do-not-create-dm-nodes.patch of Package parted.3440

---
 libparted/arch/linux.c |   45 ++++++++++++++++++++++++++++-----------------
 1 file changed, 28 insertions(+), 17 deletions(-)

Index: parted-3.1/libparted/arch/linux.c
===================================================================
--- parted-3.1.orig/libparted/arch/linux.c
+++ parted-3.1/libparted/arch/linux.c
@@ -33,6 +33,7 @@
 #include <stdio.h>
 #include <syscall.h>
 #include <unistd.h>
+#include <stdlib.h>
 #include <stdbool.h>
 #include <dirent.h>
 #include <sys/ioctl.h>
@@ -2858,29 +2859,39 @@ err:
 static int
 _dm_reread_part_table (PedDisk* disk)
 {
-        int largest_partnum = ped_disk_get_last_partition_num (disk);
-        if (largest_partnum <= 0)
-          return 1;
-
-        int     rc = 1;
-        int     last = PED_MIN (largest_partnum, 16);
-        int     i;
+	int 		dev_minor;
+	int 		dev_major;
+	struct stat	dev_stat;
+	char		name_buf[40];
+	FILE*           f;
 
         sync();
-        if (!_dm_remove_parts(disk->dev))
-                rc = 0;
 
-        for (i = 1; i <= last; i++) {
-                PedPartition*      part;
+	/* Issue uevent for the device */
+	if (!_device_stat (disk->dev, &dev_stat))
+	    	return 0;
 
-                part = ped_disk_get_partition (disk, i);
-                if (!part)
-                        continue;
+	dev_major = major (dev_stat.st_rdev);
+	dev_minor = minor (dev_stat.st_rdev);
 
-                if (!_dm_add_partition (disk, part))
-                        rc = 0;
+	snprintf (name_buf, sizeof (name_buf),
+		  "/sys/dev/block/%d:%d/uevent", dev_major, dev_minor);
+
+	if ((f = fopen (name_buf, "w")) == NULL)
+		return 0;
+
+	if (fputs ("change", f) == EOF)
+		return 0;
+
+	fclose(f);
+
+	/* Wait for udev to finish */
+	if (system ("/sbin/udevadm settle --timeout=20") != 0) {
+		/* udevadm settle failed - let's sleep for a while */
+		sleep (2);
         }
-        return rc;
+
+        return 1;
 }
 #endif
openSUSE Build Service is sponsored by