]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
wipefs: don't do step-back if <type> does not match
authorKarel Zak <kzak@redhat.com>
Fri, 16 Jun 2017 09:36:41 +0000 (11:36 +0200)
committerKarel Zak <kzak@redhat.com>
Wed, 28 Jun 2017 08:28:41 +0000 (10:28 +0200)
Signed-off-by: Karel Zak <kzak@redhat.com>
misc-utils/wipefs.c

index e17d6b4a0d32f967df2120ba83c39fcf5ea97696..1266ed06474b7735a62102c5884b401fc35db426 100644 (file)
@@ -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;