dcavalca / rpms / util-linux

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