X-Git-Url: http://git.ozlabs.org/?a=blobdiff_plain;ds=sidebyside;f=discover%2Fyaboot-parser.c;h=9399cc7f5f0ce796cb3d67f46a25ff9ef2c63446;hb=7c8683fa009115f8a3b08b7a7666b64ebcbbc1bc;hp=0a66e8d588241d69b66a9fc3d1119edce7f3c38a;hpb=5be946cda7b8e2271ade6188ca3f5dc068826619;p=petitboot diff --git a/discover/yaboot-parser.c b/discover/yaboot-parser.c index 0a66e8d..9399cc7 100644 --- a/discover/yaboot-parser.c +++ b/discover/yaboot-parser.c @@ -48,12 +48,7 @@ static void yaboot_finish(struct conf_context *conf) conf_strip_str(opt->boot_args); conf_strip_str(opt->description); - /* opt is persistent, so must be associated with device */ - discover_context_add_boot_option(conf->dc, state->opt); - - state->opt = discover_boot_option_create(conf->dc, conf->dc->device); - state->opt->option->boot_args = talloc_strdup(state->opt->option, ""); } static struct resource *create_yaboot_devpath_resource( @@ -122,13 +117,18 @@ static void yaboot_process_pair(struct conf_context *conf, const char *name, if (streq(name, "image")) { /* First finish any previous image. */ - if (opt->boot_image) + if (opt) yaboot_finish(conf); + opt = discover_boot_option_create(conf->dc, conf->dc->device); + opt->option->boot_args = talloc_strdup(opt->option, ""); + /* Then start the new image. */ opt->boot_image = create_yaboot_devpath_resource(conf, value, &state->desc_image); + state->opt = opt; + return; } @@ -143,12 +143,16 @@ static void yaboot_process_pair(struct conf_context *conf, const char *name, if (suse_fp) { /* First finish any previous image. */ - - if (opt->boot_image) + if (opt) yaboot_finish(conf); /* Then start the new image. */ + opt = discover_boot_option_create(conf->dc, conf->dc->device); + opt->option->boot_args = talloc_strdup(opt->option, ""); + + state->opt = opt; + if (*value == '/') { opt->boot_image = create_yaboot_devpath_resource( conf, value, &state->desc_image); @@ -302,10 +306,7 @@ static int yaboot_parse(struct discover_context *dc, char *buf, int len) state->known_names = yaboot_known_names; - /* opt is persistent, so must be associated with device */ - - state->opt = discover_boot_option_create(conf->dc, conf->dc->device); - state->opt->option->boot_args = talloc_strdup(state->opt->option, ""); + state->opt = NULL; conf_parse_buf(conf, buf, len); @@ -313,8 +314,12 @@ static int yaboot_parse(struct discover_context *dc, char *buf, int len) return 1; } -struct parser __yaboot_parser = { - .name = "yaboot", - .parse = yaboot_parse, - .filenames = yaboot_conf_files, +static struct parser yaboot_parser = { + .name = "yaboot", + .method = CONF_METHOD_LOCAL_FILE, + .parse = yaboot_parse, + .filenames = yaboot_conf_files, + .resolve_resource = resolve_devpath_resource, }; + +register_parser(yaboot_parser);