zipl/src: Fix problems when image is not on target DASD

This patch fixes a bug in disk_get_info()
Steps to reproduce: Prepare a DASD disk for IPL, specifying an
image ("-i IMAGE_NAME") located on SCSI (dm) and a target directory
("-t /mnt") located on DASD. Don't specify "-a" option.

Actual result: "Run /lib/s390-tools//zipl_helper.device-mapper /mnt
Error: Could not retrieve device-mapper information for device
'dasda1'"
Expected result: "Run /lib/s390-tools//zipl_helper.device-mapper 253:4
Error: Could not add image file 'IMAGE_NAME': File is not on target
device"

The problem is in incorrect calculation by disk_get_info()
parameters for @device associated with the image file. Specifically,
@target->bootmap_dir is passed to the script, which is wrong.

Fixup: Get rid of bogus branching in disk_get_info() in case when
target parameters are evaluated in "source_script" mode. Always pass
major and minor of the @device (whose parameters to be calculated)
to the helper script.

Signed-off-by: Eduard Shishkin <edward6@linux.ibm.com>
Reviewed-by: Stefan Haberland <sth@linux.ibm.com>
Signed-off-by: Steffen Eiden <seiden@linux.ibm.com>
This commit is contained in:
Eduard Shishkin
2024-04-13 11:57:36 +02:00
committed by Steffen Eiden
parent 7da5a6b9ed
commit cfaccc5fad

View File

@@ -246,15 +246,9 @@ disk_get_info(const char* device, struct job_target_data* target,
(!stat(script_file, &script_stats))) {
data->source = source_script;
/* Run targetbase script */
if (target->bootmap_dir == NULL) {
/* happens in case of partition dump */
misc_asprintf(&ppn_cmd, "%s %d:%d",
script_file, major(stats.st_rdev),
minor(stats.st_rdev));
} else {
misc_asprintf(&ppn_cmd, "%s %s",
script_file, target->bootmap_dir);
}
misc_asprintf(&ppn_cmd, "%s %d:%d",
script_file, major(stats.st_rdev),
minor(stats.st_rdev));
printf("Run %s\n", ppn_cmd);
fh = popen(ppn_cmd, "r");
if (fh == NULL) {