X-Git-Url: http://git.ozlabs.org/?p=petitboot;a=blobdiff_plain;f=discover%2Fgrub2-parser.c;h=cb9635e64122d766a4fc086e89b52fd13f25fac1;hp=4a1acf5da371113562005a07fa763a2033138240;hb=29e6551ec43ce5ed6a51414f9f8c8c4207a804b0;hpb=45e92aa32a80fdbbf5ad3ad64e34b1ac872018ef;ds=sidebyside diff --git a/discover/grub2-parser.c b/discover/grub2-parser.c index 4a1acf5..cb9635e 100644 --- a/discover/grub2-parser.c +++ b/discover/grub2-parser.c @@ -72,12 +72,7 @@ static void grub2_finish(struct conf_context *conf) discover_context_add_boot_option(conf->dc, state->opt); - state->opt = discover_boot_option_create(conf->dc, conf->dc->device); - opt = state->opt->option; - opt->boot_args = talloc_strdup(opt, ""); - - talloc_free(state->desc_image); - state->desc_image = NULL; + state->opt = NULL; } static void grub2_process_pair(struct conf_context *conf, const char *name, @@ -93,9 +88,13 @@ static void grub2_process_pair(struct conf_context *conf, const char *name, if (streq(name, "menuentry")) { char *sep; - grub2_finish(conf); + /* complete any existing option... */ + if (state->opt) + grub2_finish(conf); - /* Then start the new image. */ + /* ... then start the new one */ + opt = discover_boot_option_create(conf->dc, conf->dc->device); + opt->option->boot_args = talloc_strdup(opt->option, ""); sep = strchr(value, '\''); @@ -105,6 +104,9 @@ static void grub2_process_pair(struct conf_context *conf, const char *name, opt->option->id = talloc_asprintf(opt->option, "%s#%s", dev->id, value); opt->option->name = talloc_strdup(opt->option, value); + opt->option->boot_args = talloc_strdup(opt, ""); + + state->opt = opt; return; } @@ -142,12 +144,14 @@ static const char *const grub2_conf_files[] = { "/grub.cfg", "/menu.lst", "/grub/grub.cfg", + "/grub2/grub.cfg", "/grub/menu.lst", "/boot/grub/grub.cfg", "/boot/grub/menu.lst", "/GRUB.CFG", "/MENU.LST", "/GRUB/GRUB.CFG", + "/GRUB2/GRUB.CFG", "/GRUB/MENU.LST", "/BOOT/GRUB/GRUB.CFG", "/BOOT/GRUB/MENU.LST", @@ -180,11 +184,6 @@ static int grub2_parse(struct discover_context *dc, char *buf, int len) state->known_names = grub2_known_names; - /* opt is persistent, so must be associated with device */ - - state->opt = discover_boot_option_create(dc, dc->device); - state->opt->option->boot_args = talloc_strdup(state->opt->option, ""); - conf_parse_buf(conf, buf, len); talloc_free(conf); @@ -192,9 +191,11 @@ static int grub2_parse(struct discover_context *dc, char *buf, int len) } static struct parser grub2_parser = { - .name = "grub2", - .parse = grub2_parse, - .filenames = grub2_conf_files, + .name = "grub2", + .method = CONF_METHOD_LOCAL_FILE, + .parse = grub2_parse, + .filenames = grub2_conf_files, + .resolve_resource = resolve_devpath_resource, }; register_parser(grub2_parser);