8 #include "talloc/talloc.h"
9 #include "types/types.h"
10 #include "parser-conf.h"
11 #include "parser-utils.h"
14 static void kboot_process_pair(struct conf_context *conf, const char *name,
17 const char *const *ignored_names = conf->parser_info;
23 struct boot_option *opt;
25 /* ignore bare values */
30 if (conf_param_in_list(ignored_names, name))
33 if (conf_set_global_option(conf, name, value))
36 /* opt must be associated with dc */
38 dev = conf->dc->device->device;
39 opt = talloc_zero(dev, struct boot_option);
44 opt->id = talloc_asprintf(opt, "%s#%s", dev->id, name);
45 opt->name = talloc_strdup(opt, name);
47 args = talloc_strdup(opt, "");
48 initrd = conf_get_global_option(conf, "initrd");
49 root = conf_get_global_option(conf, "root");
51 pos = strchr(value, ' ');
53 /* if there's no space, it's only a kernel image with no params */
60 char *cl_name, *cl_value;
62 pos = conf_get_pair_equal(conf, pos, &cl_name, &cl_value, ' ');
65 args = talloc_asprintf_append(args, "%s ", cl_value);
69 if (streq(cl_name, "initrd")) {
74 if (streq(cl_name, "root")) {
79 args = talloc_asprintf_append(args, "%s=%s ", cl_name,
84 opt->boot_image_file = resolve_path(opt, value,
85 conf->dc->device->device_path);
88 opt->boot_args = talloc_asprintf(opt, "root=%s %s", root, args);
91 opt->boot_args = args;
94 opt->initrd_file = resolve_path(opt, initrd,
95 conf->dc->device->device_path);
97 opt->description = talloc_asprintf(opt, "%s initrd=%s %s",
98 value, initrd, opt->boot_args);
100 opt->description = talloc_asprintf(opt, "%s %s", value,
103 conf_strip_str(opt->boot_args);
104 conf_strip_str(opt->description);
106 discover_context_add_boot_option(conf->dc, opt);
109 static struct conf_global_option kboot_global_options[] = {
110 { .name = "initrd" },
116 static const char *const kboot_conf_files[] = {
128 static const char *const kboot_ignored_names[] = {
136 static int kboot_parse(struct discover_context *dc)
138 struct conf_context *conf;
141 conf = talloc_zero(dc, struct conf_context);
147 conf->global_options = kboot_global_options,
148 conf_init_global_options(conf);
149 conf->conf_files = kboot_conf_files,
150 conf->get_pair = conf_get_pair_equal;
151 conf->process_pair = kboot_process_pair;
152 conf->parser_info = (void *)kboot_ignored_names,
154 rc = conf_parse(conf);
160 define_parser(kboot, kboot_parse);