File s390-tools-sles15sp2-02-libutil-determine-base-device-address-in-case-of.patch of Package s390-tools.18705
Subject: [PATCH] [BZ 190371] libutil: determine base device address in case of given partition
From: Stefan Haberland <sth@linux.ibm.com>
Description: zipl: fix multi volume dump creation
Symptom: zipl -M is not working.
Problem: util_sys_get_dev_addr() returns the device address for
a given blockdevice. This does not work for partitions
but some tools like zipl rely on the ability to get the
device address for partitions.
Solution: Add code that determines the base device for a partition.
Reproduction: Run zipl -M.
Upstream-ID: 6802b86414b48c4f118da09c7bf7ee142a459fa0
Problem-ID: 190371
Upstream-Description:
libutil: determine base device address in case of given partition
util_sys_get_dev_addr() returns the device address for a given blockdevice.
This does not work for partitions but some tools rely on the ability to get
the device address for partitions.
Add code that first determines the base device for a partition.
Fixes: 6014d07cb106 ("dasdview/libdasd/zipl: Use util_sys_get_dev_addr() instead of u2s_getbusid()")
Signed-off-by: Stefan Haberland <sth@linux.ibm.com>
Reviewed-by: Jan Hoeppner <hoeppner@linux.ibm.com>
Reviewed-by: Philipp Rudo <prudo@linux.ibm.com>
Signed-off-by: Jan Hoeppner <hoeppner@linux.ibm.com>
Signed-off-by: Stefan Haberland <sth@linux.ibm.com>
---
libutil/util_sys.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
--- a/libutil/util_sys.c
+++ b/libutil/util_sys.c
@@ -141,13 +141,17 @@ int util_sys_get_dev_addr(const char *de
unsigned int maj, min;
struct stat s;
ssize_t len;
+ dev_t base;
char *path;
if (stat(dev, &s) != 0)
return -1;
- maj = major(s.st_rdev);
- min = minor(s.st_rdev);
+ if (util_sys_get_base_dev(s.st_rdev, &base))
+ return -1;
+
+ maj = major(base);
+ min = minor(base);
if (S_ISBLK(s.st_mode))
path = util_path_sysfs("dev/block/%u:%u/device", maj, min);