diff options
author | Jeremy Kerr <jk@ozlabs.org> | 2013-09-16 16:02:09 +0800 |
---|---|---|
committer | Jeremy Kerr <jk@ozlabs.org> | 2013-09-24 13:14:59 +0800 |
commit | 5e1b3c27ab320eae17b9c9d75b4111c924860268 (patch) | |
tree | 18d769b628b128ab8ede1dae18d4f6377d6acd60 | |
parent | f465fcee178cfb5a5e076297ea7dd49102f7e8b9 (diff) | |
download | talos-petitboot-5e1b3c27ab320eae17b9c9d75b4111c924860268.tar.gz talos-petitboot-5e1b3c27ab320eae17b9c9d75b4111c924860268.zip |
discover/grub2: Add option state in menuentry processing
This will allow menuentry-specific commands to populate boot option
data.
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
-rw-r--r-- | discover/grub2/grub2.h | 1 | ||||
-rw-r--r-- | discover/grub2/script.c | 16 |
2 files changed, 17 insertions, 0 deletions
diff --git a/discover/grub2/grub2.h b/discover/grub2/grub2.h index fca0fa2..1ac9f88 100644 --- a/discover/grub2/grub2.h +++ b/discover/grub2/grub2.h @@ -84,6 +84,7 @@ struct grub2_script { struct list commands; struct list symtab; struct discover_context *ctx; + struct discover_boot_option *opt; }; struct grub2_parser { diff --git a/discover/grub2/script.c b/discover/grub2/script.c index 5b38156..8b008c4 100644 --- a/discover/grub2/script.c +++ b/discover/grub2/script.c @@ -2,6 +2,7 @@ #include <sys/types.h> #include <string.h> +#include <types/types.h> #include <talloc/talloc.h> #include "grub2.h" @@ -255,10 +256,24 @@ int statement_menuentry_execute(struct grub2_script *script, struct grub2_statement *statement) { struct grub2_statement_menuentry *st = to_stmt_menuentry(statement); + struct discover_boot_option *opt; process_expansions(script, st->argv); + + opt = discover_boot_option_create(script->ctx, script->ctx->device); + if (st->argv->argc > 0) { + opt->option->name = talloc_strdup(opt, st->argv->argv[0]); + } else { + opt->option->name = talloc_strdup(opt, "(unknown)"); + } + + script->opt = opt; + statements_execute(script, st->statements); + discover_context_add_boot_option(script->ctx, opt); + script->opt = NULL; + return 0; } @@ -309,6 +324,7 @@ struct grub2_script *create_script(struct grub2_parser *parser, init_env(script); script->ctx = ctx; + script->opt = NULL; list_init(&script->commands); register_builtins(script); |