mirror of
https://github.com/ibm-s390-linux/s390-tools.git
synced 2026-08-05 02:14:52 +00:00
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:
committed by
Jan Höppner
parent
c230b5385a
commit
3989e1b741
@@ -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))
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user