+134
@@ -0,0 +1,134 @@
|
||||
From 00e53f17c8462cb34ece08cc10db60a7da29a305 Mon Sep 17 00:00:00 2001
|
||||
From: Karel Zak <kzak@redhat.com>
|
||||
Date: Tue, 4 Feb 2020 15:11:19 +0100
|
||||
Subject: [PATCH] libfdisk: (script) accept sector-size, ignore unknown headers
|
||||
|
||||
- add sector-size between supported headers (already in --dump output)
|
||||
|
||||
- report unknown headers by -ENOTSUP
|
||||
|
||||
- ignore ENOTSUP in sfdisk (but print warning) and in fdisk_script_read_file()
|
||||
|
||||
Addresses: https://github.com/karelzak/util-linux/issues/949
|
||||
Signed-off-by: Karel Zak <kzak@redhat.com>
|
||||
---
|
||||
disk-utils/sfdisk.c | 6 +++++-
|
||||
libfdisk/src/script.c | 49 +++++++++++++++++++++++--------------------
|
||||
2 files changed, 31 insertions(+), 24 deletions(-)
|
||||
|
||||
diff --git a/disk-utils/sfdisk.c b/disk-utils/sfdisk.c
|
||||
index bb6e1c6df..c0bea7046 100644
|
||||
--- a/disk-utils/sfdisk.c
|
||||
+++ b/disk-utils/sfdisk.c
|
||||
@@ -1782,7 +1782,11 @@ static int command_fdisk(struct sfdisk *sf, int argc, char **argv)
|
||||
}
|
||||
|
||||
rc = fdisk_script_read_line(dp, stdin, buf, sizeof(buf));
|
||||
- if (rc < 0) {
|
||||
+ if (rc == -ENOTSUP) {
|
||||
+ buf[sizeof(buf) - 1] = '\0';
|
||||
+ fdisk_warnx(sf->cxt, _("Unknown script header '%s' -- ignore."), buf);
|
||||
+ continue;
|
||||
+ } else if (rc < 0) {
|
||||
DBG(PARSE, ul_debug("script parsing failed, trying sfdisk specific commands"));
|
||||
buf[sizeof(buf) - 1] = '\0';
|
||||
rc = loop_control_commands(sf, dp, buf);
|
||||
diff --git a/libfdisk/src/script.c b/libfdisk/src/script.c
|
||||
index a21771b6a..d3e67fa9c 100644
|
||||
--- a/libfdisk/src/script.c
|
||||
+++ b/libfdisk/src/script.c
|
||||
@@ -805,8 +805,12 @@ static inline int is_header_line(const char *s)
|
||||
/* parses "<name>: value", note modifies @s*/
|
||||
static int parse_line_header(struct fdisk_script *dp, char *s)
|
||||
{
|
||||
- int rc = -EINVAL;
|
||||
+ size_t i;
|
||||
char *name, *value;
|
||||
+ static const char *supported[] = {
|
||||
+ "label", "unit", "label-id", "device", "grain",
|
||||
+ "first-lba", "last-lba", "table-length", "sector-size"
|
||||
+ };
|
||||
|
||||
DBG(SCRIPT, ul_debugobj(dp, " parse header '%s'", s));
|
||||
|
||||
@@ -816,7 +820,7 @@ static int parse_line_header(struct fdisk_script *dp, char *s)
|
||||
name = s;
|
||||
value = strchr(s, ':');
|
||||
if (!value)
|
||||
- goto done;
|
||||
+ return -EINVAL;
|
||||
*value = '\0';
|
||||
value++;
|
||||
|
||||
@@ -825,32 +829,30 @@ static int parse_line_header(struct fdisk_script *dp, char *s)
|
||||
ltrim_whitespace((unsigned char *) value);
|
||||
rtrim_whitespace((unsigned char *) value);
|
||||
|
||||
+ if (!*name || !*value)
|
||||
+ return -EINVAL;
|
||||
+
|
||||
+ /* check header name */
|
||||
+ for (i = 0; i < ARRAY_SIZE(supported); i++) {
|
||||
+ if (strcmp(name, supported[i]) == 0)
|
||||
+ break;
|
||||
+ }
|
||||
+ if (i == ARRAY_SIZE(supported))
|
||||
+ return -ENOTSUP;
|
||||
+
|
||||
+ /* header specific actions */
|
||||
if (strcmp(name, "label") == 0) {
|
||||
if (dp->cxt && !fdisk_get_label(dp->cxt, value))
|
||||
- goto done; /* unknown label name */
|
||||
+ return -EINVAL; /* unknown label name */
|
||||
dp->force_label = 1;
|
||||
+
|
||||
} else if (strcmp(name, "unit") == 0) {
|
||||
if (strcmp(value, "sectors") != 0)
|
||||
- goto done; /* only "sectors" supported */
|
||||
- } else if (strcmp(name, "label-id") == 0
|
||||
- || strcmp(name, "device") == 0
|
||||
- || strcmp(name, "grain") == 0
|
||||
- || strcmp(name, "first-lba") == 0
|
||||
- || strcmp(name, "last-lba") == 0
|
||||
- || strcmp(name, "table-length") == 0) {
|
||||
- ; /* whatever is possible */
|
||||
- } else
|
||||
- goto done; /* unknown header */
|
||||
+ return -EINVAL; /* only "sectors" supported */
|
||||
|
||||
- if (*name && *value)
|
||||
- rc = fdisk_script_set_header(dp, name, value);
|
||||
-done:
|
||||
- if (rc)
|
||||
- DBG(SCRIPT, ul_debugobj(dp, "header parse error: "
|
||||
- "[rc=%d, name='%s', value='%s']",
|
||||
- rc, name, value));
|
||||
- return rc;
|
||||
+ }
|
||||
|
||||
+ return fdisk_script_set_header(dp, name, value);
|
||||
}
|
||||
|
||||
/* returns zero terminated string with next token and @str is updated */
|
||||
@@ -1363,7 +1365,8 @@ int fdisk_script_set_fgets(struct fdisk_script *dp,
|
||||
*
|
||||
* Reads next line into dump.
|
||||
*
|
||||
- * Returns: 0 on success, <0 on error, 1 when nothing to read.
|
||||
+ * Returns: 0 on success, <0 on error, 1 when nothing to read. For unknown headers
|
||||
+ * returns -ENOTSUP, it's usually safe to ignore this error.
|
||||
*/
|
||||
int fdisk_script_read_line(struct fdisk_script *dp, FILE *f, char *buf, size_t bufsz)
|
||||
{
|
||||
@@ -1428,7 +1431,7 @@ int fdisk_script_read_file(struct fdisk_script *dp, FILE *f)
|
||||
|
||||
while (!feof(f)) {
|
||||
rc = fdisk_script_read_line(dp, f, buf, sizeof(buf));
|
||||
- if (rc)
|
||||
+ if (rc && rc != -ENOTSUP)
|
||||
break;
|
||||
}
|
||||
|
||||
--
|
||||
2.24.1
|
||||
|
||||
@@ -0,0 +1,80 @@
|
||||
From 91b636b5654576d0b808d0030ca9d773099e1db9 Mon Sep 17 00:00:00 2001
|
||||
From: Karel Zak <kzak@redhat.com>
|
||||
Date: Tue, 25 Feb 2020 15:31:23 +0100
|
||||
Subject: [PATCH] lsblk: fix -P regression from v2.34
|
||||
|
||||
Since v2.34 --list prints devices only once to make the output
|
||||
user-readable. Unfortunately, it's regression for scripts/applications
|
||||
where we need to parse lsblk output. So, let's make --pairs and --raw
|
||||
backwardly compatible with versions before 2.34 and print all hierarchy.
|
||||
|
||||
Addresses: https://github.com/ibm-s390-tools/s390-tools/issues/80
|
||||
Signed-off-by: Karel Zak <kzak@redhat.com>
|
||||
---
|
||||
misc-utils/lsblk.8 | 10 ++++++----
|
||||
misc-utils/lsblk.c | 9 +++++----
|
||||
2 files changed, 11 insertions(+), 8 deletions(-)
|
||||
|
||||
diff --git a/misc-utils/lsblk.8 b/misc-utils/lsblk.8
|
||||
index 373a80ee2..416b28298 100644
|
||||
--- a/misc-utils/lsblk.8
|
||||
+++ b/misc-utils/lsblk.8
|
||||
@@ -96,7 +96,8 @@ also \fB\-\-tree\fR if necessary.
|
||||
.BR \-l , " \-\-list"
|
||||
Produce output in the form of a list. The output does not provide information
|
||||
about relationships between devices and since version 2.34 every device is
|
||||
-printed only once.
|
||||
+printed only once if \fB\-\-pairs\fR or \fB\-\-raw\fR not specified (the
|
||||
+parsable outputs are maintained in backwardly compatible way).
|
||||
.TP
|
||||
.BR \-M , " \-\-merge"
|
||||
Group parents of sub-trees to provide more readable output for RAIDs and
|
||||
@@ -122,14 +123,15 @@ specified in the format \fI+list\fP (e.g., \fBlsblk \-o +UUID\fP).
|
||||
Output all available columns.
|
||||
.TP
|
||||
.BR \-P , " \-\-pairs"
|
||||
-Produce output in the form of key="value" pairs.
|
||||
-All potentially unsafe characters are hex-escaped (\\x<code>).
|
||||
+Produce output in the form of key="value" pairs. The output lines are still ordered by
|
||||
+dependencies. All potentially unsafe characters are hex-escaped (\\x<code>).
|
||||
.TP
|
||||
.BR \-p , " \-\-paths"
|
||||
Print full device paths.
|
||||
.TP
|
||||
.BR \-r , " \-\-raw"
|
||||
-Produce output in raw format. All potentially unsafe characters are hex-escaped
|
||||
+Produce output in raw format. The output lines are still ordered by
|
||||
+dependencies. All potentially unsafe characters are hex-escaped
|
||||
(\\x<code>) in the NAME, KNAME, LABEL, PARTLABEL and MOUNTPOINT columns.
|
||||
.TP
|
||||
.BR \-S , " \-\-scsi"
|
||||
diff --git a/misc-utils/lsblk.c b/misc-utils/lsblk.c
|
||||
index 441655e24..72ac7b483 100644
|
||||
--- a/misc-utils/lsblk.c
|
||||
+++ b/misc-utils/lsblk.c
|
||||
@@ -1058,8 +1058,8 @@ static void device_to_scols(
|
||||
if (!parent && dev->wholedisk)
|
||||
parent = dev->wholedisk;
|
||||
|
||||
- /* Do not print device more than one in --list mode */
|
||||
- if (!(lsblk->flags & LSBLK_TREE) && dev->is_printed)
|
||||
+ /* Do not print device more than once on --list if tree order is not requested */
|
||||
+ if (!(lsblk->flags & LSBLK_TREE) && !lsblk->force_tree_order && dev->is_printed)
|
||||
return;
|
||||
|
||||
if (lsblk->merge && list_count_entries(&dev->parents) > 1) {
|
||||
@@ -2044,8 +2044,9 @@ int main(int argc, char *argv[])
|
||||
* /sys is no more sorted */
|
||||
lsblk->sort_id = COL_MAJMIN;
|
||||
|
||||
- /* For --inverse --list we still follow parent->child relation */
|
||||
- if (lsblk->inverse && !(lsblk->flags & LSBLK_TREE))
|
||||
+ /* For --{inverse,raw,pairs} --list we still follow parent->child relation */
|
||||
+ if (!(lsblk->flags & LSBLK_TREE)
|
||||
+ && (lsblk->inverse || lsblk->flags & LSBLK_EXPORT || lsblk->flags & LSBLK_RAW))
|
||||
lsblk->force_tree_order = 1;
|
||||
|
||||
if (lsblk->sort_id >= 0 && column_id_to_number(lsblk->sort_id) < 0) {
|
||||
--
|
||||
2.24.1
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
<IsA>library</IsA>
|
||||
<Summary>Various useful Linux utilities</Summary>
|
||||
<Description>The util-linux package contains a large variety of low-level system utilities that are necessary for a Linux system to function.</Description>
|
||||
<Archive sha1sum="36757c996c9c7ff4150b8ee26fc51255279de14f" type="tarxz">https://mirrors.edge.kernel.org/pub/linux/utils/util-linux/v2.35/util-linux-2.35-rc1.tar.xz</Archive>
|
||||
<Archive sha1sum="a3fba2e7fe0ce117525a38498ef4eda9687bf3b3" type="tarxz">https://mirrors.edge.kernel.org/pub/linux/utils/util-linux/v2.35/util-linux-2.35.1.tar.xz</Archive>
|
||||
<BuildDependencies>
|
||||
<Dependency>zlib-devel</Dependency>
|
||||
<Dependency>eudev-devel</Dependency>
|
||||
@@ -23,11 +23,13 @@
|
||||
<Dependency>ncurses-devel</Dependency>
|
||||
<Dependency>libcap-ng-devel</Dependency>
|
||||
<Dependency>pam-devel</Dependency>
|
||||
<Dependency>libpcre2-devel</Dependency>
|
||||
<Dependency>libpcre2-devel</Dependency>
|
||||
<!-- <Dependency releaseFrom="2">utempter-devel</Dependency>-->
|
||||
</BuildDependencies>
|
||||
<Patches>
|
||||
<Patch level="1">upstream/util-linux-ng-2.21-login-lastlog.patch</Patch>
|
||||
<Patch level="1">0001-libfdisk-script-accept-sector-size-ignore-unknown-he.patch</Patch>
|
||||
<Patch level="1">0003-lsblk-fix-P-regression-from-v2.34.patch</Patch>
|
||||
<!-- <Patch level="1">0001-lsblk-force-to-print-PKNAME-for-partition.patch</Patch> -->
|
||||
<!--Patch level="1">upstream/0001-sfdisk-support-empty-label-use-case.patch </Patch-->
|
||||
</Patches>
|
||||
@@ -45,7 +47,7 @@
|
||||
<Dependency>eudev</Dependency>
|
||||
<!--<Dependency>utempter</Dependency>-->
|
||||
<Dependency>libcap-ng</Dependency>
|
||||
<Dependency>libpcre2</Dependency>
|
||||
<Dependency>libpcre2</Dependency>
|
||||
</RuntimeDependencies>
|
||||
<Files>
|
||||
<Path fileType="config">/etc</Path>
|
||||
@@ -148,6 +150,13 @@
|
||||
</Package>
|
||||
|
||||
<History>
|
||||
<Update release="13">
|
||||
<Date>2020-04-20</Date>
|
||||
<Version>2.35.1</Version>
|
||||
<Comment>Version bump.</Comment>
|
||||
<Name>Mustafa Cinasal</Name>
|
||||
<Email>muscnsl@gmail.com</Email>
|
||||
</Update>
|
||||
<Update release="12">
|
||||
<Date>2019-12-25</Date>
|
||||
<Version>2.35_rc1</Version>
|
||||
|
||||
Reference in New Issue
Block a user