zipl/src: fix segfault on '--dry-run' for device-based dumps

This fixes a segfault when the option '--dry-run' is specified for
device-based dumps (for which the bootmap file is created on a RAW
device, not formatted with a file system).

The actual status is that the option '--dry-run' for device-based
dumps is not implemented. The implementation is evaluated as not
trivial: In contrast with filesystem-based dumps, it is not possible
to simply make do with rename/unlink of temporary created bootmap.

The fixup returns error on any not file system based dumps being
created with the option '--dry-run'.

Signed-off-by: Eduard Shishkin <edward6@linux.ibm.com>
Reviewed-by: Mikhail Zaslonko <zaslonko@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
This commit is contained in:
Eduard Shishkin
2024-09-17 14:37:03 +02:00
committed by Jan Höppner
parent c230b5385a
commit 3989e1b741
2 changed files with 16 additions and 23 deletions

View File

@@ -1442,30 +1442,18 @@ static int prepare_build_program_table_device(struct job_data *job,
if (bis->skip_prepare)
/* skip the preparation work */
return 0;
if (dry_run) {
error_text("Option '--dry-run' is not implemented for this type of dump");
return -1;
}
/* Get full path of bootmap file */
if (!dry_run) {
bis->filename = misc_strdup(job->data.dump.device);
if (!bis->filename)
return -1;
bis->fd = misc_open_exclusive(bis->filename);
if (bis->fd == -1) {
error_text("Could not open file '%s'", bis->filename);
return -1;
}
} else {
bis->filename = misc_make_path(job->target.bootmap_dir,
BOOTMAP_TEMPLATE_FILENAME);
if (!bis->filename)
return -1;
/* Create temporary bootmap file */
bis->fd = mkstemp(bis->filename);
if (bis->fd == -1) {
error_reason(strerror(errno));
error_text("Could not create file '%s':",
bis->filename);
return -1;
}
bis->tmp_filename_created = 1;
bis->filename = misc_strdup(job->data.dump.device);
if (!bis->filename)
return -1;
bis->fd = misc_open_exclusive(bis->filename);
if (bis->fd == -1) {
error_text("Could not open file '%s'", bis->filename);
return -1;
}
/* Retrieve target device information */
if (disk_get_info(bis->filename, &job->target, &bis->info))

View File

@@ -181,6 +181,11 @@ main(int argc, char* argv[])
if (!job_dump_is_ngdump(job) &&
(disk_is_tape(job->data.dump.device) ||
!disk_type_is_scsi(&ext_type))) {
if (dry_run) {
error_text("Option '--dry-run' is not implemented for this type of dump");
rc = -1;
break;
}
rc = install_dump(job->data.dump.device, &job->target,
job->data.dump.mem, job->data.dump.no_compress);
break;