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;
22 struct boot_option *opt;
24 /* ignore bare values */
29 if (conf_param_in_list(ignored_names, name))
32 if (conf_set_global_option(conf, name, value))
35 /* opt must be associated with dc */
37 opt = talloc_zero(conf->dc->device, struct boot_option);
42 opt->id = talloc_asprintf(opt, "%s#%s", conf->dc->device->id, name);
43 opt->name = talloc_strdup(opt, name);
45 args = talloc_strdup(opt, "");
46 initrd = conf_get_global_option(conf, "initrd");
47 root = conf_get_global_option(conf, "root");
49 pos = strchr(value, ' ');
51 /* if there's no space, it's only a kernel image with no params */
58 char *cl_name, *cl_value;
60 pos = conf_get_pair_equal(conf, pos, &cl_name, &cl_value, ' ');
63 args = talloc_asprintf_append(args, "%s ", cl_value);
67 if (streq(cl_name, "initrd")) {
72 if (streq(cl_name, "root")) {
77 args = talloc_asprintf_append(args, "%s=%s ", cl_name,
82 opt->boot_image_file = resolve_path(opt, value, conf->dc->device_path);
85 opt->boot_args = talloc_asprintf(opt, "root=%s %s", root, args);
88 opt->boot_args = args;
91 opt->initrd_file = resolve_path(opt, initrd,
92 conf->dc->device_path);
94 opt->description = talloc_asprintf(opt, "%s initrd=%s %s",
95 value, initrd, opt->boot_args);
97 opt->description = talloc_asprintf(opt, "%s %s", value,
100 conf_strip_str(opt->boot_args);
101 conf_strip_str(opt->description);
103 device_add_boot_option(conf->dc->device, opt);
106 static struct conf_global_option kboot_global_options[] = {
107 { .name = "initrd" },
113 static const char *const kboot_conf_files[] = {
125 static const char *const kboot_ignored_names[] = {
133 static int kboot_parse(struct discover_context *dc)
135 struct conf_context *conf;
138 conf = talloc_zero(dc, struct conf_context);
144 conf->global_options = kboot_global_options,
145 conf_init_global_options(conf);
146 conf->conf_files = kboot_conf_files,
147 conf->get_pair = conf_get_pair_equal;
148 conf->process_pair = kboot_process_pair;
149 conf->parser_info = (void *)kboot_ignored_names,
151 rc = conf_parse(conf);
157 define_parser(kboot, kboot_parse);