From d7b816ff58baed404b5406a7c25e390804ff1a76 Mon Sep 17 00:00:00 2001 From: Stefan Haberland Date: Fri, 24 Apr 2020 16:02:26 +0200 Subject: [PATCH] zipl: fix BLS error message MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fix that a misleading BLS error message is printed in any case for missing files. The scan_check code in zipl already does proper error handling for missing file. Remove the duplicated error handling from scan_check_bls and just use the function to update the file with the target path if needed. To indicate the intention of this function also rename it. Fixes: #84 Signed-off-by: Stefan Haberland Reviewed-by: Tuan Hoang Signed-off-by: Jan Höppner --- zipl/include/scan.h | 2 +- zipl/src/job.c | 8 ++------ zipl/src/scan.c | 25 +++++++++++-------------- 3 files changed, 14 insertions(+), 21 deletions(-) diff --git a/zipl/include/scan.h b/zipl/include/scan.h index f39e96ef..e5e49abc 100644 --- a/zipl/include/scan.h +++ b/zipl/include/scan.h @@ -126,7 +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); +void scan_update_bls_path(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, diff --git a/zipl/src/job.c b/zipl/src/job.c index 2c9cef83..c3d30a08 100644 --- a/zipl/src/job.c +++ b/zipl/src/job.c @@ -1874,12 +1874,8 @@ 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; - } + /* maybe we need to update bls search path with target path */ + scan_update_bls_path(scan); /* Get job from config file data */ if (cmdline->menu != NULL) rc = get_menu_job(scan, cmdline->menu, job); diff --git a/zipl/src/scan.c b/zipl/src/scan.c index a34edf62..064709f4 100644 --- a/zipl/src/scan.c +++ b/zipl/src/scan.c @@ -1567,16 +1567,17 @@ scan_check(struct scan_token* scan) /* * 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. + * update scan list if the file exists. + * In case neither path works the scan_check code will correctly handle missing + * files */ -int -scan_check_bls(struct scan_token *scan) +void scan_update_bls_path(struct scan_token *scan) { - int i, rc; char *target_value = NULL; char *img_value = NULL; char *file = NULL; char *tmp, *value; + int i; /* * In the BLS case, each BLS section heading inherits a keyword * assignment target= from zipl.conf, and they are all the same. @@ -1590,7 +1591,7 @@ scan_check_bls(struct scan_token *scan) } } if (!target_value) - return -1; + return; for (i = 0 ; scan[i].id != scan_id_empty; i++) { if (scan[i].id != scan_id_keyword_assignment) continue; @@ -1608,16 +1609,12 @@ scan_check_bls(struct scan_token *scan) } else { file = value; } - rc = misc_check_readable_file(file); - if (rc) { + if (misc_check_readable_file(file)) { misc_asprintf(&img_value, "%s%s", target_value, file); - rc = misc_check_readable_file(img_value); - if (rc) { - error_reason( - "File '%s' not accessible", file); - return rc; - } + if (misc_check_readable_file(img_value)) + continue; + /* * when file has stripped the load address part, * do generate a prefixed value @@ -1633,7 +1630,7 @@ scan_check_bls(struct scan_token *scan) } } } - return 0; + return; } static int