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