]> git.ipfire.org Git - thirdparty/mdadm.git/blobdiff - util.c
Remove partitions from components of an md array
[thirdparty/mdadm.git] / util.c
diff --git a/util.c b/util.c
index 08319cb6bccadb86b9c68884a066f1e96b8ef2f0..f3b7a3970224ffba7f2201287dcdb3a18b03dfbc 100644 (file)
--- a/util.c
+++ b/util.c
@@ -31,6 +31,7 @@
 #include       "md_p.h"
 #include       <sys/utsname.h>
 #include       <ctype.h>
+#include       <linux/blkpg.h>
 
 /*
  * Parse a 128 bit uuid in 4 integers
@@ -118,6 +119,25 @@ int get_linux_version()
        return (a*1000000)+(b*1000)+c;
 }
 
+void remove_partitions(int fd)
+{
+       /* remove partitions from this block devices.
+        * This is used for components added to an array
+        */
+#ifdef BLKPG_DEL_PARTITION
+       struct blkpg_ioctl_arg a;
+       struct blkpg_partition p;
+
+       a.op = BLKPG_DEL_PARTITION;
+       a.data = (void*)&p;
+       a.datalen = sizeof(p);
+       a.flags = 0;
+       memset(a.data, 0, a.datalen);
+       for (p.pno=0; p.pno < 16; p.pno++)
+               ioctl(fd, BLKPG, &a);
+#endif
+}
+
 int enough(int level, int raid_disks, int layout,
           char *avail, int avail_disks)
 {