X-Git-Url: http://git.ozlabs.org/?p=petitboot;a=blobdiff_plain;f=discover%2Fyaboot-parser.c;h=b06248f535f35eb0c05b3e2bf2437a1516cafbdf;hp=22792d4a63b4007bcfc46c400ab88cf8b2adbbc4;hb=336f4eb17fb50526ea9fda82262356581e1b9ae0;hpb=503d1454f222e2b0c6f8dd433a9e91870a17f460 diff --git a/discover/yaboot-parser.c b/discover/yaboot-parser.c index 22792d4..b06248f 100644 --- a/discover/yaboot-parser.c +++ b/discover/yaboot-parser.c @@ -1,9 +1,12 @@ -#define _GNU_SOURCE +#if defined(HAVE_CONFIG_H) +#include "config.h" +#endif #include #include #include #include +#include #include "log/log.h" #include "talloc/talloc.h" @@ -14,7 +17,6 @@ struct yaboot_state { int globals_done; - const char *const *known_names; /* current option data */ struct discover_boot_option *opt; @@ -102,7 +104,8 @@ static void yaboot_finish(struct conf_context *conf) const char *default_label; struct boot_option *opt; - assert(state->opt); + if (!state->opt) + return; opt = state->opt->option; assert(opt); @@ -112,6 +115,13 @@ static void yaboot_finish(struct conf_context *conf) /* populate the boot option from state data */ state->opt->boot_image = create_yaboot_devpath_resource(state, conf, state->boot_image); + + char* args_sigfile_default = talloc_asprintf(opt, + "%s.cmdline.sig", state->boot_image); + state->opt->args_sig_file = create_yaboot_devpath_resource(state, + conf, args_sigfile_default); + talloc_free(args_sigfile_default); + if (state->initrd) { state->opt->initrd = create_yaboot_devpath_resource(state, conf, state->initrd); @@ -162,6 +172,7 @@ static void yaboot_finish(struct conf_context *conf) state->opt->option->is_default = true; discover_context_add_boot_option(conf->dc, state->opt); + state->opt = NULL; } static void yaboot_process_pair(struct conf_context *conf, const char *name, @@ -191,14 +202,10 @@ static void yaboot_process_pair(struct conf_context *conf, const char *name, if (!state->globals_done && conf_set_global_option(conf, name, value)) return; - if (!conf_param_in_list(state->known_names, name)) - return; - - state->globals_done = 1; - /* image */ - if (streq(name, "image")) { + /* an image section finishes our global defintions */ + state->globals_done = 1; /* First finish any previous image. */ if (opt) @@ -242,7 +249,7 @@ static void yaboot_process_pair(struct conf_context *conf, const char *name, /* all other processing requires an image */ if (!opt) { - pb_log("%s: unknown name: %s\n", __func__, name); + pb_debug("%s: unknown name: %s\n", __func__, name); return; } @@ -308,7 +315,7 @@ static void yaboot_process_pair(struct conf_context *conf, const char *name, return; } - pb_log("%s: unknown name: %s\n", __func__, name); + pb_debug("%s: unknown name: %s\n", __func__, name); } static struct conf_global_option yaboot_global_options[] = { @@ -327,44 +334,37 @@ static struct conf_global_option yaboot_global_options[] = { static const char *const yaboot_conf_files[] = { "/yaboot.conf", "/yaboot.cnf", + "/etc/lilo.conf", + "/etc/silo.conf", "/etc/yaboot.conf", "/etc/yaboot.cnf", "/suseboot/yaboot.cnf", "/YABOOT.CONF", "/YABOOT.CNF", + "/ETC/LILO.CONF", + "/ETC/SILO.CONF", "/ETC/YABOOT.CONF", "/ETC/YABOOT.CNF", "/SUSEBOOT/YABOOT.CNF", NULL }; -static const char *yaboot_known_names[] = { - "append", - "image", - "image[64bit]", /* SUSE extension */ - "image[32bit]", /* SUSE extension */ - "initrd", - "initrd-size", - "label", - "literal", - "ramdisk", - "read-only", - "read-write", - "root", - "device", - "partition", - NULL -}; - -static int yaboot_parse(struct discover_context *dc, char *buf, int len) +static int yaboot_parse(struct discover_context *dc) { - struct conf_context *conf; + const char * const *filename; struct yaboot_state *state; + struct conf_context *conf; + int len, rc; + char *buf; + + /* Support block device boot only at present */ + if (dc->event) + return -1; conf = talloc_zero(dc, struct conf_context); if (!conf) - return 0; + return -1; conf->dc = dc; conf->global_options = yaboot_global_options, @@ -374,21 +374,27 @@ static int yaboot_parse(struct discover_context *dc, char *buf, int len) conf->finish = yaboot_finish; conf->parser_info = state = talloc_zero(conf, struct yaboot_state); - state->known_names = yaboot_known_names; - state->opt = NULL; - conf_parse_buf(conf, buf, len); + for (filename = yaboot_conf_files; *filename; filename++) { + rc = parser_request_file(dc, dc->device, *filename, &buf, &len); + if (rc) + continue; + + conf_parse_buf(conf, buf, len); + device_handler_status_dev_info(dc->handler, dc->device, + _("Parsed yaboot configuration from %s"), + *filename); + talloc_free(buf); + } talloc_free(conf); - return 1; + return 0; } static struct parser yaboot_parser = { .name = "yaboot", - .method = CONF_METHOD_LOCAL_FILE, .parse = yaboot_parse, - .filenames = yaboot_conf_files, .resolve_resource = resolve_devpath_resource, };