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

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

Actual result: Installation succeeded (resulting in unbootable setup!)
Expected result: "Error: Could not add image file 'IMAGE_NAME':
File is not on target device".

The problem is in incorrect evaluation of device number (dev_t) of
the device, where the image file is located, by the function
add_component_file_range(). To evaluate it, disk_get_info() is called
with the structure job_target_data (passed as the second argument)
previously completed by disk_get_info() called earlier to evaluate
parameters of the specified target device (SCSI dm) by the function
prepare_build_program_table_file(). Since the targetbase is already
set in the passed job_target_data (by the first call), in the second
call the source type is evaluated as "source_user", so the number of
the device where the image is located is calculated by the base SCSI
disk, which is incorrect.

Fixup: Rework disk_get_info(): introduce a dedicated function to
evaluate source type not depending on the job_target_data content.
Implement the core procedure as a switch by the evaluated source
type.

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-24 11:47:40 +02:00
committed by Steffen Eiden
parent 08232d29b9
commit 76aaf3d4a8
6 changed files with 352 additions and 214 deletions
+5 -4
View File
@@ -1406,7 +1406,8 @@ check_dump_device(struct job_data *job, const struct disk_info *info,
int rc, part_ext;
/* Check for supported disk and driver types */
if ((info->source == source_auto) && (info->type == disk_type_diag)) {
if (job->target.source == source_auto &&
info->type == disk_type_diag) {
error_reason("Unsupported disk type (%s)",
disk_get_type_name(info->type));
return -1;
@@ -1474,7 +1475,7 @@ static int prepare_build_program_table_device(struct job_data *job,
if (verbose) {
printf("Target device information\n");
disk_print_info(bis->info);
disk_print_info(bis->info, job->target.source);
}
if (misc_temp_dev(bis->info->device, 1, &bis->device))
return -1;
@@ -1563,7 +1564,7 @@ static int prepare_build_program_table_file(struct job_data *job,
if (disk_get_info_from_file(bis->filename, &job->target, &bis->info))
return -1;
/* Check for supported disk and driver types */
if (bis->info->source == source_auto &&
if (job->target.source == source_auto &&
bis->info->type == disk_type_diag) {
error_reason("Unsupported disk type (%s)",
disk_get_type_name(bis->info->type));
@@ -1573,7 +1574,7 @@ static int prepare_build_program_table_file(struct job_data *job,
return -1;
if (verbose) {
printf("Target device information\n");
disk_print_info(bis->info);
disk_print_info(bis->info, job->target.source);
}
if (misc_temp_dev(bis->info->device, 1, &bis->device))
return -1;