dcavalca / rpms / util-linux

Forked from rpms/util-linux 2 years ago
Clone

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

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