05ad79
diff -up util-linux-2.23.2/misc-utils/wipefs.8.kzak util-linux-2.23.2/misc-utils/wipefs.8
05ad79
--- util-linux-2.23.2/misc-utils/wipefs.8.kzak	2013-07-30 10:39:26.232738496 +0200
05ad79
+++ util-linux-2.23.2/misc-utils/wipefs.8	2014-01-23 11:07:54.390022299 +0100
05ad79
@@ -23,6 +23,9 @@ does not erase the filesystem itself nor
05ad79
 When used without options \fB-a\fR or \fB-o\fR, it lists all visible filesystems
05ad79
 and the offsets of their basic signatures.
05ad79
 
05ad79
+.B wipefs
05ad79
+calls BLKRRPART ioctl when erase partition table to inform kernel about the change.
05ad79
+
05ad79
 Note that some filesystems or some partition tables store more magic strings on
05ad79
 the devices.  The
05ad79
 .B wipefs
05ad79
diff -up util-linux-2.23.2/misc-utils/wipefs.c.kzak util-linux-2.23.2/misc-utils/wipefs.c
05ad79
--- util-linux-2.23.2/misc-utils/wipefs.c.kzak	2013-07-30 10:39:26.232738496 +0200
05ad79
+++ util-linux-2.23.2/misc-utils/wipefs.c	2014-01-23 11:12:26.786860550 +0100
05ad79
@@ -40,21 +40,24 @@
05ad79
 #include "c.h"
05ad79
 #include "closestream.h"
05ad79
 #include "optutils.h"
05ad79
+#include "blkdev.h"
05ad79
 
05ad79
 struct wipe_desc {
05ad79
 	loff_t		offset;		/* magic string offset */
05ad79
 	size_t		len;		/* length of magic string */
05ad79
 	unsigned char	*magic;		/* magic string */
05ad79
 
05ad79
-	int		zap;		/* zap this offset? */
05ad79
 	char		*usage;		/* raid, filesystem, ... */
05ad79
 	char		*type;		/* FS type */
05ad79
 	char		*label;		/* FS label */
05ad79
 	char		*uuid;		/* FS uuid */
05ad79
 
05ad79
-	int		on_disk;
05ad79
-
05ad79
 	struct wipe_desc	*next;
05ad79
+
05ad79
+	unsigned int	zap : 1,
05ad79
+			on_disk : 1,
05ad79
+			is_parttable : 1;
05ad79
+
05ad79
 };
05ad79
 
05ad79
 enum {
05ad79
@@ -72,7 +75,7 @@ print_pretty(struct wipe_desc *wp, int l
05ad79
 		printf("----------------------------------------------------------------\n");
05ad79
 	}
05ad79
 
05ad79
-	printf("0x%-17jx  %s   [%s]", wp->offset, wp->type, wp->usage);
05ad79
+	printf("0x%-17jx  %s   [%s]", wp->offset, wp->type, _(wp->usage));
05ad79
 
05ad79
 	if (wp->label && *wp->label)
05ad79
 		printf("\n%27s %s", "LABEL:", wp->label);
05ad79
@@ -141,7 +144,7 @@ add_offset(struct wipe_desc *wp0, loff_t
05ad79
 	wp = xcalloc(1, sizeof(struct wipe_desc));
05ad79
 	wp->offset = offset;
05ad79
 	wp->next = wp0;
05ad79
-	wp->zap = zap;
05ad79
+	wp->zap = zap ? 1 : 0;
05ad79
 	return wp;
05ad79
 }
05ad79
 
05ad79
@@ -164,7 +167,7 @@ get_desc_for_probe(struct wipe_desc *wp,
05ad79
 	const char *off, *type, *mag, *p, *usage = NULL;
05ad79
 	size_t len;
05ad79
 	loff_t offset;
05ad79
-	int rc;
05ad79
+	int rc, ispt = 0;
05ad79
 
05ad79
 	/* superblocks */
05ad79
 	if (blkid_probe_lookup_value(pr, "TYPE", &type, NULL) == 0) {
05ad79
@@ -181,7 +184,8 @@ get_desc_for_probe(struct wipe_desc *wp,
05ad79
 			rc = blkid_probe_lookup_value(pr, "PTMAGIC", &mag, &len;;
05ad79
 		if (rc)
05ad79
 			return wp;
05ad79
-		usage = "partition table";
05ad79
+		usage = N_("partition table");
05ad79
+		ispt = 1;
05ad79
 	} else
05ad79
 		return wp;
05ad79
 
05ad79
@@ -199,6 +203,7 @@ get_desc_for_probe(struct wipe_desc *wp,
05ad79
 
05ad79
 	wp->type = xstrdup(type);
05ad79
 	wp->on_disk = 1;
05ad79
+	wp->is_parttable = ispt ? 1 : 0;
05ad79
 
05ad79
 	wp->magic = xmalloc(len);
05ad79
 	memcpy(wp->magic, mag, len);
05ad79
@@ -309,10 +314,25 @@ static void do_wipe_real(blkid_probe pr,
05ad79
 	putchar('\n');
05ad79
 }
05ad79
 
05ad79
+
05ad79
+static void rereadpt(int fd, const char *devname)
05ad79
+{
05ad79
+#ifdef BLKRRPART
05ad79
+	struct stat st;
05ad79
+
05ad79
+	if (fstat(fd, &st) || !S_ISBLK(st.st_mode))
05ad79
+		return;
05ad79
+
05ad79
+	errno = 0;
05ad79
+	ioctl(fd, BLKRRPART);
05ad79
+	printf(_("%s: calling ioclt to re-read partition table: %m\n"), devname);
05ad79
+#endif
05ad79
+}
05ad79
+
05ad79
 static struct wipe_desc *
05ad79
 do_wipe(struct wipe_desc *wp, const char *devname, int noact, int all, int quiet, int force)
05ad79
 {
05ad79
-	int flags;
05ad79
+	int flags, reread = 0;
05ad79
 	blkid_probe pr;
05ad79
 	struct wipe_desc *w, *wp0;
05ad79
 	int zap = all ? 1 : wp->zap;
05ad79
@@ -345,8 +365,11 @@ do_wipe(struct wipe_desc *wp, const char
05ad79
 		if (!wp->on_disk)
05ad79
 			continue;
05ad79
 
05ad79
-		if (zap)
05ad79
+		if (zap) {
05ad79
 			do_wipe_real(pr, devname, wp, noact, quiet);
05ad79
+			if (wp->is_parttable)
05ad79
+				reread = 1;
05ad79
+		}
05ad79
 	}
05ad79
 
05ad79
 	for (w = wp0; w != NULL; w = w->next) {
05ad79
@@ -355,6 +378,10 @@ do_wipe(struct wipe_desc *wp, const char
05ad79
 	}
05ad79
 
05ad79
 	fsync(blkid_probe_get_fd(pr));
05ad79
+
05ad79
+	if (reread)
05ad79
+		rereadpt(blkid_probe_get_fd(pr), devname);
05ad79
+
05ad79
 	close(blkid_probe_get_fd(pr));
05ad79
 	blkid_free_probe(pr);
05ad79
 	free_wipe(wp0);