304038
From df6302339ae99535d3c075712db8cadeedbb6c00 Mon Sep 17 00:00:00 2001
304038
From: Karel Zak <kzak@redhat.com>
304038
Date: Tue, 17 Oct 2017 11:07:56 +0200
304038
Subject: [PATCH 137/141] wipefs: fix -t filter
304038
304038
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1486777
304038
Signed-off-by: Karel Zak <kzak@redhat.com>
304038
---
304038
 misc-utils/wipefs.c | 15 ++++++++++++---
304038
 1 file changed, 12 insertions(+), 3 deletions(-)
304038
304038
diff --git a/misc-utils/wipefs.c b/misc-utils/wipefs.c
304038
index 0144c9ef8..a0852aa97 100644
304038
--- a/misc-utils/wipefs.c
304038
+++ b/misc-utils/wipefs.c
304038
@@ -162,13 +162,16 @@ clone_offset(struct wipe_desc *wp0)
304038
 }
304038
 
304038
 static struct wipe_desc *
304038
-get_desc_for_probe(struct wipe_desc *wp, blkid_probe pr)
304038
+get_desc_for_probe(struct wipe_desc *wp, blkid_probe pr, int *found)
304038
 {
304038
 	const char *off, *type, *mag, *p, *usage = NULL;
304038
 	size_t len;
304038
 	loff_t offset;
304038
 	int rc, ispt = 0;
304038
 
304038
+	if (found)
304038
+		*found = 0;
304038
+
304038
 	/* superblocks */
304038
 	if (blkid_probe_lookup_value(pr, "TYPE", &type, NULL) == 0) {
304038
 		rc = blkid_probe_lookup_value(pr, "SBMAGIC_OFFSET", &off, NULL);
304038
@@ -215,6 +218,8 @@ get_desc_for_probe(struct wipe_desc *wp, blkid_probe pr)
304038
 	if (blkid_probe_lookup_value(pr, "UUID", &p, NULL) == 0)
304038
 		wp->uuid = xstrdup(p);
304038
 
304038
+	if (found)
304038
+		*found = 1;
304038
 	return wp;
304038
 }
304038
 
304038
@@ -266,7 +271,7 @@ read_offsets(struct wipe_desc *wp, const char *devname)
304038
 		return NULL;
304038
 
304038
 	while (blkid_do_probe(pr) == 0) {
304038
-		wp = get_desc_for_probe(wp, pr);
304038
+		wp = get_desc_for_probe(wp, pr, NULL);
304038
 		if (!wp)
304038
 			break;
304038
 	}
304038
@@ -347,9 +352,13 @@ do_wipe(struct wipe_desc *wp, const char *devname, int noact, int all, int quiet
304038
 	wp0 = clone_offset(wp);
304038
 
304038
 	while (blkid_do_probe(pr) == 0) {
304038
-		wp = get_desc_for_probe(wp, pr);
304038
+		int found = 0;
304038
+
304038
+		wp = get_desc_for_probe(wp, pr, &found);
304038
 		if (!wp)
304038
 			break;
304038
+		if (!found)
304038
+			continue;
304038
 
304038
 		/* Check if offset is in provided list */
304038
 		w = wp0;
304038
-- 
304038
2.13.6
304038