summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--discover/grub2/grub2.h14
-rw-r--r--discover/grub2/parser.y4
-rw-r--r--discover/grub2/script.c7
3 files changed, 15 insertions, 10 deletions
diff --git a/discover/grub2/grub2.h b/discover/grub2/grub2.h
index 149e1e1..fca0fa2 100644
--- a/discover/grub2/grub2.h
+++ b/discover/grub2/grub2.h
@@ -79,10 +79,11 @@ struct grub2_command {
};
struct grub2_script {
- struct grub2_statements *statements;
- struct list environment;
- struct list commands;
- struct list symtab;
+ struct grub2_statements *statements;
+ struct list environment;
+ struct list commands;
+ struct list symtab;
+ struct discover_context *ctx;
};
struct grub2_parser {
@@ -135,7 +136,8 @@ int statement_if_execute(struct grub2_script *script,
int statement_menuentry_execute(struct grub2_script *script,
struct grub2_statement *statement);
-struct grub2_script *create_script(void *ctx);
+struct grub2_script *create_script(struct grub2_parser *parser,
+ struct discover_context *ctx);
const char *script_env_get(struct grub2_script *script, const char *name);
@@ -159,7 +161,7 @@ bool resolve_grub2_resource(struct device_handler *handler,
struct resource *res);
/* external parser api */
-struct grub2_parser *grub2_parser_create(void *ctx);
+struct grub2_parser *grub2_parser_create(struct discover_context *ctx);
void grub2_parser_parse(struct grub2_parser *parser, char *buf, int len);
#endif /* GRUB2_H */
diff --git a/discover/grub2/parser.y b/discover/grub2/parser.y
index f49cecd..2b229b8 100644
--- a/discover/grub2/parser.y
+++ b/discover/grub2/parser.y
@@ -221,13 +221,13 @@ void word_append(struct grub2_word *w1, struct grub2_word *w2)
w1->last = w2;
}
-struct grub2_parser *grub2_parser_create(void *ctx)
+struct grub2_parser *grub2_parser_create(struct discover_context *ctx)
{
struct grub2_parser *parser;
parser = talloc(ctx, struct grub2_parser);
yylex_init_extra(parser, &parser->scanner);
- parser->script = create_script(parser);
+ parser->script = create_script(parser, ctx);
return parser;
}
diff --git a/discover/grub2/script.c b/discover/grub2/script.c
index 9cc0cfb..5b38156 100644
--- a/discover/grub2/script.c
+++ b/discover/grub2/script.c
@@ -300,13 +300,16 @@ void script_execute(struct grub2_script *script)
statements_execute(script, script->statements);
}
-struct grub2_script *create_script(void *ctx)
+struct grub2_script *create_script(struct grub2_parser *parser,
+ struct discover_context *ctx)
{
struct grub2_script *script;
- script = talloc(ctx, struct grub2_script);
+ script = talloc(parser, struct grub2_script);
init_env(script);
+ script->ctx = ctx;
+
list_init(&script->commands);
register_builtins(script);
OpenPOWER on IntegriCloud