Skip to content

Commit

Permalink
libutil: determine base device address in case of given partition
Browse files Browse the repository at this point in the history
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: 6014d07 ("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>
  • Loading branch information
Stefan Haberland authored and hoeppnerj committed Oct 28, 2020
1 parent aa8c294 commit 6802b86
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions libutil/util_sys.c
Expand Up @@ -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);
Expand Down

0 comments on commit 6802b86

Please sign in to comment.