forked from pool/s390-tools
50 lines
1.6 KiB
Diff
50 lines
1.6 KiB
Diff
|
Subject: [PATCH] [BZ 143839] chreipl/virtio: fix chreipl node for virtio-blk disks
|
||
|
From: Christian Borntraeger <borntraeger@de.ibm.com>
|
||
|
|
||
|
Description: chreipl/virtio: fix chreipl node for virtio-blk disks
|
||
|
Symptom: chreipl node <mount point> for a virtio-blk disk fails:
|
||
|
Could not find DASD CCW device "virtio1"
|
||
|
Problem: The sysfs walking code to resolve the device is not
|
||
|
handling virtio devices correctly.
|
||
|
Solution: Use the realpath of the device to get the busid for all
|
||
|
supported devices.
|
||
|
Reproduction: Run chreipl node <mountpoint> with virtio-blk devices as
|
||
|
backing for mount point.
|
||
|
Upstream-ID: -
|
||
|
Problem-ID: 143839
|
||
|
|
||
|
Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
|
||
|
---
|
||
|
ipl_tools/ccw.c | 12 +++++-------
|
||
|
1 file changed, 5 insertions(+), 7 deletions(-)
|
||
|
|
||
|
--- a/ipl_tools/ccw.c
|
||
|
+++ b/ipl_tools/ccw.c
|
||
|
@@ -76,21 +76,19 @@ out_fclose:
|
||
|
static int ccw_busid_get_sysfs_new(const char *device, char *busid)
|
||
|
{
|
||
|
char path[PATH_MAX], buf[4096];
|
||
|
- char *ptr;
|
||
|
|
||
|
memset(buf, 0, sizeof(buf));
|
||
|
snprintf(path, sizeof(path), "/sys/block/%s/device", device);
|
||
|
- if (readlink(path, buf, sizeof(buf) - 1) == -1)
|
||
|
+ if (realpath(path, buf) == NULL)
|
||
|
return -1;
|
||
|
|
||
|
/*
|
||
|
* The output has the following format:
|
||
|
- * ../../../0.0.4e13
|
||
|
+ * /sys/devices/css0/0.0.0119/0.0.3f19/block/dasda
|
||
|
+ * /sys/devices/css0/0.0.0000/0.0.0000/virtio0/block/vda
|
||
|
*/
|
||
|
- ptr = strrchr(buf, '/');
|
||
|
- if (!ptr)
|
||
|
- ERR_EXIT("Could not read \"%s\"", path);
|
||
|
- strncpy(busid, ptr + 1, 9);
|
||
|
+ if (sscanf(buf, "/sys/devices/css0/%*[0-9a-f.]/%[0-9a-f.]", busid) != 1)
|
||
|
+ return -1;
|
||
|
return 0;
|
||
|
}
|
||
|
|