dcavalca / rpms / util-linux

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