dcavalca / rpms / util-linux

Forked from rpms/util-linux 2 years ago
Clone
531551
diff -up util-linux-2.23.2/misc-utils/wipefs.8.kzak util-linux-2.23.2/misc-utils/wipefs.8
531551
--- util-linux-2.23.2/misc-utils/wipefs.8.kzak	2014-09-24 10:41:31.061930168 +0200
531551
+++ util-linux-2.23.2/misc-utils/wipefs.8	2014-09-24 10:46:30.142783728 +0200
531551
@@ -37,6 +37,11 @@ table will still be visible by another m
531551
 When used with option \fB-a\fR, all magic strings that are visible for libblkid are
531551
 erased.
531551
 
531551
+Note that by default
531551
+.B wipefs
531551
+does not erase nested partition tables on non-whole disk devices. The option 
531551
+\-\-force is required.
531551
+
531551
 .SH OPTIONS
531551
 .TP
531551
 .BR \-a , " \-\-all"
531551
diff -up util-linux-2.23.2/misc-utils/wipefs.c.kzak util-linux-2.23.2/misc-utils/wipefs.c
531551
--- util-linux-2.23.2/misc-utils/wipefs.c.kzak	2014-09-24 10:41:31.061930168 +0200
531551
+++ util-linux-2.23.2/misc-utils/wipefs.c	2014-09-24 10:50:07.728859738 +0200
531551
@@ -332,7 +332,7 @@ static void rereadpt(int fd, const char
531551
 static struct wipe_desc *
531551
 do_wipe(struct wipe_desc *wp, const char *devname, int noact, int all, int quiet, int force)
531551
 {
531551
-	int flags, reread = 0;
531551
+	int flags, reread = 0, need_force = 0;
531551
 	blkid_probe pr;
531551
 	struct wipe_desc *w, *wp0;
531551
 	int zap = all ? 1 : wp->zap;
531551
@@ -365,6 +365,15 @@ do_wipe(struct wipe_desc *wp, const char
531551
 		if (!wp->on_disk)
531551
 			continue;
531551
 
531551
+		if (!force
531551
+		    && wp->is_parttable
531551
+		    && !blkid_probe_is_wholedisk(pr)) {
531551
+			warnx(_("%s: ignore nested \"%s\" partition "
531551
+				"table on non-whole disk device."), devname, wp->type);
531551
+			need_force = 1;
531551
+			continue;
531551
+		}
531551
+
531551
 		if (zap) {
531551
 			do_wipe_real(pr, devname, wp, noact, quiet);
531551
 			if (wp->is_parttable)
531551
@@ -377,6 +386,9 @@ do_wipe(struct wipe_desc *wp, const char
531551
 			warnx(_("%s: offset 0x%jx not found"), devname, w->offset);
531551
 	}
531551
 
531551
+	if (need_force)
531551
+		warnx(_("Use the --force option to force erase."));
531551
+
531551
 	fsync(blkid_probe_get_fd(pr));
531551
 
531551
 	if (reread)