diff options
author | Jeremy Kerr <jk@ozlabs.org> | 2013-05-08 13:11:50 +0800 |
---|---|---|
committer | Jeremy Kerr <jk@ozlabs.org> | 2013-05-08 13:17:56 +0800 |
commit | bb19338a08bd4449c38d596e66b92028c5855b0d (patch) | |
tree | 87c661112754a5ac47fcd72b5d0150751708cdb0 /discover | |
parent | d70b3460fbbcc9acb4a80e1e6fe51d564ae607aa (diff) | |
download | talos-petitboot-bb19338a08bd4449c38d596e66b92028c5855b0d.tar.gz talos-petitboot-bb19338a08bd4449c38d596e66b92028c5855b0d.zip |
discover/grub2: Rework config state
Rather than creating boot options pre-emptively, in two paths, just do
it once when we see the menuentry option.
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
Diffstat (limited to 'discover')
-rw-r--r-- | discover/grub2-parser.c | 23 |
1 files changed, 10 insertions, 13 deletions
diff --git a/discover/grub2-parser.c b/discover/grub2-parser.c index 97b9653..bb47d6c 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; } @@ -180,11 +182,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); |