X-Git-Url: https://git.ozlabs.org/?a=blobdiff_plain;f=discover%2Fgrub2-parser.c;h=3c756c1b0f5230f120253d0d62568870459af349;hb=397dc244bfdc2a57fc3e8fd191b0ef60c8a4b66b;hp=df1b755715d776acf93b37e8095afcdddcdeba22;hpb=ee86a0bd989511319adf3467b41b5b2e1f486aa6;p=petitboot diff --git a/discover/grub2-parser.c b/discover/grub2-parser.c index df1b755..3c756c1 100644 --- a/discover/grub2-parser.c +++ b/discover/grub2-parser.c @@ -41,11 +41,11 @@ struct grub2_state { static void grub2_finish(struct conf_context *conf) { + struct device *dev = conf->dc->device->device; struct grub2_state *state = conf->parser_info; if (!state->desc_image) { - pb_log("%s: %s: no image found\n", __func__, - conf->dc->device->id); + pb_log("%s: %s: no image found\n", __func__, dev->id); return; } @@ -66,8 +66,9 @@ static void grub2_finish(struct conf_context *conf) /* opt is persistent, so must be associated with device */ - device_add_boot_option(conf->dc->device, state->opt); - state->opt = talloc_zero(conf->dc->device, struct boot_option); + discover_context_add_boot_option(conf->dc, state->opt); + + state->opt = talloc_zero(conf->dc, struct boot_option); state->opt->boot_args = talloc_strdup(state->opt, ""); talloc_free(state->desc_image); @@ -77,6 +78,7 @@ static void grub2_finish(struct conf_context *conf) static void grub2_process_pair(struct conf_context *conf, const char *name, char *value) { + struct device *dev = conf->dc->device->device; struct grub2_state *state = conf->parser_info; if (!name || !conf_param_in_list(state->known_names, name)) @@ -95,7 +97,7 @@ static void grub2_process_pair(struct conf_context *conf, const char *name, *sep = 0; state->opt->id = talloc_asprintf(state->opt, "%s#%s", - conf->dc->device->id, value); + dev->id, value); state->opt->name = talloc_strdup(state->opt, value); return; @@ -110,7 +112,7 @@ static void grub2_process_pair(struct conf_context *conf, const char *name, *sep = 0; state->opt->boot_image_file = resolve_path(state->opt, - value, conf->dc->device_path); + value, conf->dc->device->device_path); state->desc_image = talloc_strdup(state->opt, value); if (sep) @@ -122,7 +124,7 @@ static void grub2_process_pair(struct conf_context *conf, const char *name, if (streq(name, "initrd")) { state->opt->initrd_file = resolve_path(state->opt, - value, conf->dc->device_path); + value, conf->dc->device->device_path); state->desc_initrd = talloc_asprintf(state, "initrd=%s", value); return; @@ -154,11 +156,10 @@ static const char *grub2_known_names[] = { NULL }; -static int grub2_parse(struct discover_context *dc) +static int grub2_parse(struct discover_context *dc, char *buf, int len) { struct conf_context *conf; struct grub2_state *state; - int rc; conf = talloc_zero(dc, struct conf_context); @@ -167,7 +168,6 @@ static int grub2_parse(struct discover_context *dc) conf->dc = dc; conf_init_global_options(conf); - conf->conf_files = grub2_conf_files, conf->get_pair = conf_get_pair_space; conf->process_pair = grub2_process_pair; conf->finish = grub2_finish; @@ -180,10 +180,14 @@ static int grub2_parse(struct discover_context *dc) state->opt = talloc_zero(conf->dc->device, struct boot_option); state->opt->boot_args = talloc_strdup(state->opt, ""); - rc = conf_parse(conf); + conf_parse_buf(conf, buf, len); talloc_free(conf); - return rc; + return 1; } -define_parser(grub2, grub2_parse); +struct parser __grub2_parser = { + .name = "grub2", + .parse = grub2_parse, + .filenames = grub2_conf_files, +};