zipl: add check_common_ipl_data()

There are two places where we check whether the initrd and kernel image
is readably. Add one helper function that checks this. This is also a
preparation for the extended command line handling, so that we have to
add that code in only one location.

Signed-off-by: Sven Schnelle <svens@linux.ibm.com>
Reviewed-by: Stefan Haberland <sth@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
This commit is contained in:
Sven Schnelle
2021-11-08 09:58:42 +01:00
committed by Jan Höppner
parent 832268ecb0
commit 3ee625d74f

View File

@@ -761,26 +761,37 @@ static void error_text_section(const char *text, const char *section, const char
}
static int
check_common_ipl_data(struct job_common_ipl_data *common, const char *section)
{
int rc;
if (common->image != NULL) {
rc = misc_check_readable_file(common->image);
if (rc) {
error_text_section("Image file", section, common->image);
return rc;
}
}
if (common->ramdisk != NULL) {
rc = misc_check_readable_file(common->ramdisk);
if (rc) {
error_text_section("Ramdisk file", section, common->ramdisk);
return rc;
}
}
return 0;
}
static int
check_job_ipl_data(struct job_ipl_data *ipl, char *name,
struct job_envblk_data *envblk)
{
int rc;
if (ipl->common.image != NULL) {
rc = misc_check_readable_file(ipl->common.image);
if (rc) {
error_text_section("Image file", name, ipl->common.image);
return rc;
}
}
if (ipl->common.ramdisk != NULL) {
rc = misc_check_readable_file(ipl->common.ramdisk);
if (rc) {
error_text_section("Ramdisk file", name, ipl->common.ramdisk);
return rc;
}
}
rc = check_common_ipl_data(&ipl->common, name);
if (rc)
return rc;
return finalize_ipl_address_data(ipl, name, envblk);
}
@@ -889,20 +900,9 @@ check_job_ipl_tape_data(struct job_ipl_tape_data *ipl, char* name)
return rc;
}
}
if (ipl->common.image != NULL) {
rc = misc_check_readable_file(ipl->common.image);
if (rc) {
error_text_section("Image file", name, ipl->common.image);
return rc;
}
}
if (ipl->common.ramdisk != NULL) {
rc = misc_check_readable_file(ipl->common.ramdisk);
if (rc) {
error_text_section("Ramdisk file", name, ipl->common.ramdisk);
return rc;
}
}
rc = check_common_ipl_data(&ipl->common, name);
if (rc)
return rc;
return finalize_common_address_data(&ipl->common, name);
}