summaryrefslogtreecommitdiffstats
path: root/misc-utils/wipefs.c
diff options
context:
space:
mode:
authorKarel Zak2017-06-16 11:36:41 +0200
committerKarel Zak2017-06-28 10:28:41 +0200
commit193d6f27fb37497669ed429e70b19b11f2b6d4fa (patch)
tree274d86bec212237466bb403750b9476599f98d16 /misc-utils/wipefs.c
parentwipefs: print all signature permutations (diff)
downloadkernel-qcow2-util-linux-193d6f27fb37497669ed429e70b19b11f2b6d4fa.tar.gz
kernel-qcow2-util-linux-193d6f27fb37497669ed429e70b19b11f2b6d4fa.tar.xz
kernel-qcow2-util-linux-193d6f27fb37497669ed429e70b19b11f2b6d4fa.zip
wipefs: don't do step-back if <type> does not match
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'misc-utils/wipefs.c')
-rw-r--r--misc-utils/wipefs.c19
1 files changed, 14 insertions, 5 deletions
diff --git a/misc-utils/wipefs.c b/misc-utils/wipefs.c
index e17d6b4a0..1266ed064 100644
--- a/misc-utils/wipefs.c
+++ b/misc-utils/wipefs.c
@@ -171,13 +171,16 @@ clone_offset(struct wipe_desc *wp0)
}
static struct wipe_desc *
-get_desc_for_probe(struct wipe_desc *wp, blkid_probe pr)
+get_desc_for_probe(struct wipe_desc *wp, blkid_probe pr, int *found)
{
const char *off, *type, *mag, *p, *usage = NULL;
size_t len;
loff_t offset;
int rc, ispt = 0;
+ if (found)
+ *found = 0;
+
/* superblocks */
if (blkid_probe_lookup_value(pr, "TYPE", &type, NULL) == 0) {
rc = blkid_probe_lookup_value(pr, "SBMAGIC_OFFSET", &off, NULL);
@@ -224,6 +227,8 @@ get_desc_for_probe(struct wipe_desc *wp, blkid_probe pr)
if (blkid_probe_lookup_value(pr, "UUID", &p, NULL) == 0)
wp->uuid = xstrdup(p);
+ if (found)
+ *found = 1;
return wp;
}
@@ -278,13 +283,17 @@ read_offsets(struct wipe_desc *wp, const char *devname)
return NULL;
while (blkid_do_probe(pr) == 0) {
- wp = get_desc_for_probe(wp, pr);
+ int found = 0;
+
+ wp = get_desc_for_probe(wp, pr, &found);
if (!wp)
break;
/* hide last detected signature and scan again */
- blkid_probe_hide_range(pr, wp->offset, wp->len);
- blkid_probe_step_back(pr);
+ if (found) {
+ blkid_probe_hide_range(pr, wp->offset, wp->len);
+ blkid_probe_step_back(pr);
+ }
}
blkid_free_probe(pr);
@@ -394,7 +403,7 @@ do_wipe(struct wipe_desc *wp, const char *devname, int flags)
wp0 = clone_offset(wp);
while (blkid_do_probe(pr) == 0) {
- wp = get_desc_for_probe(wp, pr);
+ wp = get_desc_for_probe(wp, pr, NULL);
if (!wp)
break;