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;