summaryrefslogtreecommitdiffstats
path: root/misc-utils/wipefs.c
diff options
context:
space:
mode:
authorKarel Zak2017-06-28 12:08:25 +0200
committerKarel Zak2017-06-28 12:08:25 +0200
commit2cd417ea71127e5fbaf43e9c27bd2fa86b3c5100 (patch)
treef5fbffb39d2e0153ec99021c0c5815c12a416672 /misc-utils/wipefs.c
parentwipefs: add control struct (diff)
downloadkernel-qcow2-util-linux-2cd417ea71127e5fbaf43e9c27bd2fa86b3c5100.tar.gz
kernel-qcow2-util-linux-2cd417ea71127e5fbaf43e9c27bd2fa86b3c5100.tar.xz
kernel-qcow2-util-linux-2cd417ea71127e5fbaf43e9c27bd2fa86b3c5100.zip
wipefs: try another magic strings on -o and -t
The commit 92296e9ba2bf95259520fa7537ff8edc2aa9edbc introduces "try all permutations for the same superblock". This feature has to be also available if -o and -t is specified. Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'misc-utils/wipefs.c')
-rw-r--r--misc-utils/wipefs.c24
1 files changed, 20 insertions, 4 deletions
diff --git a/misc-utils/wipefs.c b/misc-utils/wipefs.c
index c1c7dc4ff..6e2e5de31 100644
--- a/misc-utils/wipefs.c
+++ b/misc-utils/wipefs.c
@@ -391,9 +391,12 @@ do_wipe(struct wipe_control *ctl, struct wipe_desc *wp)
free(tmp);
}
+ /* wp0 is the list of wanted offsets */
wp0 = clone_offset(wp);
while (blkid_do_probe(pr) == 0) {
+ int wiped = 0;
+
wp = get_desc_for_probe(ctl, wp, pr, NULL);
if (!wp)
break;
@@ -404,14 +407,14 @@ do_wipe(struct wipe_control *ctl, struct wipe_desc *wp)
w = w->next;
if (wp0 && !w)
- continue;
+ goto done;
/* Mark done if found in provided list */
if (w)
w->on_disk = wp->on_disk;
if (!wp->on_disk)
- continue;
+ goto done;
if (!ctl->force
&& wp->is_parttable
@@ -419,17 +422,30 @@ do_wipe(struct wipe_control *ctl, struct wipe_desc *wp)
warnx(_("%s: ignoring nested \"%s\" partition table "
"on non-whole disk device"), ctl->devname, wp->type);
need_force = 1;
- continue;
+ goto done;
}
-
if (zap) {
if (backup)
do_backup(wp, backup);
do_wipe_real(ctl, pr, wp);
if (wp->is_parttable)
reread = 1;
+ wiped = 1;
+ }
+ done:
+ if (!wiped) {
+ /* if the offset has not been wiped (probably because
+ * filtered out by -t or -o) we need to hide it for
+ * libblkid to try another magic string for the same
+ * superblock, otherwise libblkid will continue with
+ * another superblock. Don't forget that the same
+ * superblock could be detected by more magic strings
+ * */
+ blkid_probe_hide_range(pr, wp->offset, wp->len);
+ blkid_probe_step_back(pr);
}
+
}
for (w = wp0; w != NULL; w = w->next) {