Blame SOURCES/0014-blkid-make-PART_ENTRY_-tags-optional-add-no-part-det.patch

cbc4cf
From 64473a830dc93e7fcd246a64bb8389d66f0034b8 Mon Sep 17 00:00:00 2001
cbc4cf
From: Karel Zak <kzak@redhat.com>
cbc4cf
Date: Thu, 29 Nov 2018 13:21:36 +0100
cbc4cf
Subject: [PATCH 14/14] blkid: make PART_ENTRY_* tags optional (add
cbc4cf
 --no-part-details)
cbc4cf
cbc4cf
blkid(8) returns information from partition table also for empty
cbc4cf
partitions. This is necessary for example for udev, but it could be
cbc4cf
confusing if you care about on-device content only.
cbc4cf
cbc4cf
Default:
cbc4cf
 # blkid -p /dev/md0p1; echo $?
cbc4cf
 /dev/md0p1: PART_ENTRY_SCHEME="dos" PART_ENTRY_UUID="6d8796b1-01" PART_ENTRY_TYPE="0x83" PART_ENTRY_NUMBER="1" PART_ENTRY_OFFSET="2048" PART_ENTRY_SIZE="204800" PART_ENTRY_DISK="9:0"
cbc4cf
 0
cbc4cf
cbc4cf
With --no-part-details:
cbc4cf
 # blkid -p /dev/md0p1 --no-part-details; echo $?
cbc4cf
 2
cbc4cf
cbc4cf
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1653413
cbc4cf
Upstream: http://github.com/karelzak/util-linux/commit/5e91d5dd716ebc6144bcb0cabb0ec847a678be9e
cbc4cf
Signed-off-by: Karel Zak <kzak@redhat.com>
cbc4cf
---
cbc4cf
 misc-utils/blkid.8 |  6 +++++-
cbc4cf
 misc-utils/blkid.c | 15 +++++++++++----
cbc4cf
 2 files changed, 16 insertions(+), 5 deletions(-)
cbc4cf
cbc4cf
diff --git a/misc-utils/blkid.8 b/misc-utils/blkid.8
cbc4cf
index 13b5edb4d..d1cec1dea 100644
cbc4cf
--- a/misc-utils/blkid.8
cbc4cf
+++ b/misc-utils/blkid.8
cbc4cf
@@ -35,6 +35,7 @@ blkid \- locate/print block device attributes
cbc4cf
 .IR list ]
cbc4cf
 .RB [ \-\-usages
cbc4cf
 .IR list ]
cbc4cf
+.RB [ \-\-no\-part\-details ]
cbc4cf
 .IR device " ..."
cbc4cf
 
cbc4cf
 .IP \fBblkid\fR
cbc4cf
@@ -114,6 +115,9 @@ Don't encode non-printing characters.  The non-printing characters are encoded
cbc4cf
 by ^ and M- notation by default.  Note that the \fB\-\-output udev\fR output format uses
cbc4cf
 a different encoding which cannot be disabled.
cbc4cf
 .TP
cbc4cf
+\fB\-D\fR, \fB\-\-no\-part\-details\fR 
cbc4cf
+Don't print information (PART_ENTRY_* tags) from partition table in low-level probing mode.
cbc4cf
+.TP
cbc4cf
 \fB\-g\fR, \fB\-\-garbage\-collect\fR
cbc4cf
 Perform a garbage collection pass on the blkid cache to remove
cbc4cf
 devices which no longer exist.
cbc4cf
@@ -224,7 +228,7 @@ Note that low-level probing also returns information about partition table type
cbc4cf
 (PTTYPE tag) and partitions (PART_ENTRY_* tags). The tag names produced by
cbc4cf
 low-level probing are based on names used internally by libblkid and it may be
cbc4cf
 different than when executed without \fB\-\-probe\fR (for example PART_ENTRY_UUID= vs
cbc4cf
-PARTUUID=).
cbc4cf
+PARTUUID=). See also \fB\-\-no\-part\-details\fR.
cbc4cf
 .TP
cbc4cf
 \fB\-s\fR, \fB\-\-match\-tag\fR \fItag\fR
cbc4cf
 For each (specified) device, show only the tags that match
cbc4cf
diff --git a/misc-utils/blkid.c b/misc-utils/blkid.c
cbc4cf
index 4cd85317f..61a6994c2 100644
cbc4cf
--- a/misc-utils/blkid.c
cbc4cf
+++ b/misc-utils/blkid.c
cbc4cf
@@ -58,6 +58,7 @@ struct blkid_control {
cbc4cf
 		lowprobe:1,
cbc4cf
 		lowprobe_superblocks:1,
cbc4cf
 		lowprobe_topology:1,
cbc4cf
+		no_part_details:1,
cbc4cf
 		raw_chars:1;
cbc4cf
 };
cbc4cf
 
cbc4cf
@@ -101,6 +102,7 @@ static void __attribute__((__noreturn__)) usage(void)
cbc4cf
 	fputs(_(	" -O, --offset <offset>      probe at the given offset\n"), out);
cbc4cf
 	fputs(_(	" -u, --usages <list>        filter by \"usage\" (e.g. -u filesystem,raid)\n"), out);
cbc4cf
 	fputs(_(	" -n, --match-types <list>   filter by filesystem type (e.g. -n vfat,ext3)\n"), out);
cbc4cf
+	fputs(_(        " -D, --no-part-details      don't print info from partition table\n"), out);
cbc4cf
 
cbc4cf
 	fputs(USAGE_SEPARATOR, out);
cbc4cf
 	printf(USAGE_HELP_OPTIONS(28));
cbc4cf
@@ -444,7 +446,7 @@ done:
cbc4cf
 	return rc;
cbc4cf
 }
cbc4cf
 
cbc4cf
-static int lowprobe_superblocks(blkid_probe pr)
cbc4cf
+static int lowprobe_superblocks(blkid_probe pr, struct blkid_control *ctl)
cbc4cf
 {
cbc4cf
 	struct stat st;
cbc4cf
 	int rc, fd = blkid_probe_get_fd(pr);
cbc4cf
@@ -470,7 +472,8 @@ static int lowprobe_superblocks(blkid_probe pr)
cbc4cf
 			return 0;	/* partition table detected */
cbc4cf
 	}
cbc4cf
 
cbc4cf
-	blkid_probe_set_partitions_flags(pr, BLKID_PARTS_ENTRY_DETAILS);
cbc4cf
+	if (!ctl->no_part_details)
cbc4cf
+		blkid_probe_set_partitions_flags(pr, BLKID_PARTS_ENTRY_DETAILS);
cbc4cf
 	blkid_probe_enable_superblocks(pr, 1);
cbc4cf
 
cbc4cf
 	return blkid_do_safeprobe(pr);
cbc4cf
@@ -509,7 +512,7 @@ static int lowprobe_device(blkid_probe pr, const char *devname,
cbc4cf
 	if (ctl->lowprobe_topology)
cbc4cf
 		rc = lowprobe_topology(pr);
cbc4cf
 	if (rc >= 0 && ctl->lowprobe_superblocks)
cbc4cf
-		rc = lowprobe_superblocks(pr);
cbc4cf
+		rc = lowprobe_superblocks(pr, ctl);
cbc4cf
 	if (rc < 0)
cbc4cf
 		goto done;
cbc4cf
 
cbc4cf
@@ -661,6 +664,7 @@ int main(int argc, char **argv)
cbc4cf
 	static const struct option longopts[] = {
cbc4cf
 		{ "cache-file",	      required_argument, NULL, 'c' },
cbc4cf
 		{ "no-encoding",      no_argument,	 NULL, 'd' },
cbc4cf
+		{ "no-part-details",  no_argument,       NULL, 'D' },
cbc4cf
 		{ "garbage-collect",  no_argument,	 NULL, 'g' },
cbc4cf
 		{ "output",	      required_argument, NULL, 'o' },
cbc4cf
 		{ "list-filesystems", no_argument,	 NULL, 'k' },
cbc4cf
@@ -694,7 +698,7 @@ int main(int argc, char **argv)
cbc4cf
 	strutils_set_exitcode(BLKID_EXIT_OTHER);
cbc4cf
 
cbc4cf
 	while ((c = getopt_long (argc, argv,
cbc4cf
-			    "c:dghilL:n:ko:O:ps:S:t:u:U:w:Vv", longopts, NULL)) != -1) {
cbc4cf
+			    "c:DdghilL:n:ko:O:ps:S:t:u:U:w:Vv", longopts, NULL)) != -1) {
cbc4cf
 
cbc4cf
 		err_exclusive_options(c, NULL, excl, excl_st);
cbc4cf
 
cbc4cf
@@ -705,6 +709,9 @@ int main(int argc, char **argv)
cbc4cf
 		case 'd':
cbc4cf
 			ctl.raw_chars = 1;
cbc4cf
 			break;
cbc4cf
+		case 'D':
cbc4cf
+			ctl.no_part_details = 1;
cbc4cf
+			break;
cbc4cf
 		case 'L':
cbc4cf
 			ctl.eval = 1;
cbc4cf
 			search_value = xstrdup(optarg);
cbc4cf
-- 
cbc4cf
2.17.2
cbc4cf