mirror of
https://github.com/ibm-s390-linux/s390-tools.git
synced 2026-08-05 02:14:52 +00:00
zipl: add value of target= as search path for BLS case
In the BLS files, the 'linux' and 'initrd' fields are relative to the $BOOT directory. If $BOOT is a mount point of boot partition, 'linux' and 'initrd' fields are relative to boot partition. If not, the paths are relative to $BOOT directory of root partition. zipl always starts searching at / regardless of partitions and mount points. This commit extends the semantics of target= field in zipl.conf to make it as a second search path, besides /, for those 2 BLS fields. See issues #69 for more details. Fixes: https://github.com/ibm-s390-tools/s390-tools/issues/69 Closes: https://github.com/ibm-s390-tools/s390-tools/pull/74 Signed-off-by: Tuan Hoang <tmhoang@linux.ibm.com> Signed-off-by: Stefan Haberland <sth@linux.ibm.com> Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
This commit is contained in:
@@ -126,6 +126,7 @@ char* scan_keyword_name(enum scan_keyword_id id);
|
||||
int scan_check_defaultboot(struct scan_token* scan);
|
||||
struct scan_token* scan_build_automenu(struct scan_token* scan);
|
||||
int scan_check(struct scan_token* scan);
|
||||
int scan_check_bls(struct scan_token *scan);
|
||||
int scan_find_section(struct scan_token* scan, char* name, enum scan_id type,
|
||||
int offset);
|
||||
int scan_check_section_data(char* keyword[], int* line, char* name,
|
||||
|
||||
@@ -1853,6 +1853,12 @@ get_job_from_config_file(struct command_line* cmdline, struct job_data* job)
|
||||
scan_free(scan);
|
||||
return rc;
|
||||
}
|
||||
rc = scan_check_bls(scan);
|
||||
if (rc) {
|
||||
error_text("BLS parsing '%s'", blsdir);
|
||||
scan_free(scan);
|
||||
return rc;
|
||||
}
|
||||
/* Get job from config file data */
|
||||
if (cmdline->menu != NULL)
|
||||
rc = get_menu_job(scan, cmdline->menu, job);
|
||||
|
||||
@@ -1564,6 +1564,64 @@ scan_check(struct scan_token* scan)
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Check if kernel and initrd image paths provided by BLS files are readable.
|
||||
* If not, add value of 'scan_keyword_target' into search path and silently
|
||||
* update scan list.
|
||||
*/
|
||||
int
|
||||
scan_check_bls(struct scan_token *scan)
|
||||
{
|
||||
int i, rc;
|
||||
char *target_value = NULL;
|
||||
char *img_value = NULL;
|
||||
char *buffer = NULL;
|
||||
/*
|
||||
* In the BLS case, each BLS section heading inherits a keyword
|
||||
* assignment target= from zipl.conf, and they are all the same.
|
||||
*
|
||||
*/
|
||||
for (i = 0 ; scan[i].id != scan_id_empty; i++) {
|
||||
if (scan[i].id == scan_id_keyword_assignment &&
|
||||
scan[i].content.keyword.keyword == scan_keyword_target) {
|
||||
target_value = scan[i].content.keyword.value;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!target_value)
|
||||
return -1;
|
||||
for (i = 0 ; scan[i].id != scan_id_empty; i++) {
|
||||
if (scan[i].id != scan_id_keyword_assignment)
|
||||
continue;
|
||||
if (scan[i].content.keyword.keyword == scan_keyword_image ||
|
||||
scan[i].content.keyword.keyword == scan_keyword_ramdisk) {
|
||||
|
||||
rc = misc_check_readable_file(
|
||||
scan[i].content.keyword.value);
|
||||
if (rc) {
|
||||
misc_asprintf(&img_value, "%s%s",
|
||||
target_value,
|
||||
scan[i].content.keyword.value);
|
||||
rc = misc_check_readable_file(img_value);
|
||||
if (rc) {
|
||||
error_text(
|
||||
"Image file '%s' is not accessible",
|
||||
scan[i].content.keyword.value);
|
||||
return rc;
|
||||
}
|
||||
buffer = (char *)
|
||||
misc_malloc(strlen(img_value) + 1);
|
||||
if (buffer == NULL)
|
||||
return -1;
|
||||
memcpy(buffer, img_value, strlen(img_value));
|
||||
buffer[strlen(img_value)] = 0;
|
||||
free(scan[i].content.keyword.value);
|
||||
scan[i].content.keyword.value = buffer;
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
scan_get_defaultboot_type(char* keyword[], int line[], int section_line,
|
||||
|
||||
Reference in New Issue
Block a user