cdown / rpms / util-linux

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