mirror of
https://github.com/ibm-s390-linux/s390-tools.git
synced 2026-08-05 02:14:52 +00:00
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: 6014d07cb1 ("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 Höppner <hoeppner@linux.ibm.com>
This commit is contained in:
committed by
Jan Höppner
parent
aa8c2945cc
commit
6802b86414
@@ -141,13 +141,17 @@ int util_sys_get_dev_addr(const char *dev, char *addr)
|
||||
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);
|
||||
|
||||
Reference in New Issue
Block a user