8 #include "talloc/talloc.h"
9 #include "pb-protocol/pb-protocol.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 if (conf_param_in_list(ignored_names, name))
27 if (conf_set_global_option(conf, name, value))
30 /* opt must be associated with dc */
32 opt = talloc_zero(conf->dc->device, struct boot_option);
37 opt->id = talloc_asprintf(opt, "%s#%s", conf->dc->device->id, name);
38 opt->name = talloc_strdup(opt, name);
40 args = talloc_strdup(opt, "");
41 initrd = conf_get_global_option(conf, "initrd");
42 root = conf_get_global_option(conf, "root");
44 pos = strchr(value, ' ');
46 /* if there's no space, it's only a kernel image with no params */
53 char *cl_name, *cl_value;
55 pos = conf_get_param_pair(pos, &cl_name, &cl_value, ' ');
58 args = talloc_asprintf_append(args, "%s ", cl_value);
62 if (streq(cl_name, "initrd")) {
67 if (streq(cl_name, "root")) {
72 args = talloc_asprintf_append(args, "%s=%s ", cl_name,
77 opt->boot_image_file = resolve_path(opt, value, conf->dc->device_path);
80 opt->boot_args = talloc_asprintf(opt, "root=%s %s", root, args);
83 opt->boot_args = args;
86 opt->initrd_file = resolve_path(opt, initrd,
87 conf->dc->device_path);
89 opt->description = talloc_asprintf(opt, "%s initrd=%s %s",
90 value, initrd, opt->boot_args);
92 opt->description = talloc_asprintf(opt, "%s %s", value,
95 conf_strip_str(opt->boot_args);
96 conf_strip_str(opt->description);
98 device_add_boot_option(conf->dc->device, opt);
101 static struct conf_global_option kboot_global_options[] = {
102 { .name = "initrd" },
108 static const char *const kboot_conf_files[] = {
120 static const char *const kboot_ignored_names[] = {
128 static int kboot_parse(struct discover_context *dc)
130 struct conf_context *conf;
133 conf = talloc_zero(dc, struct conf_context);
139 conf->global_options = kboot_global_options,
140 conf_init_global_options(conf);
141 conf->conf_files = kboot_conf_files,
142 conf->process_pair = kboot_process_pair;
143 conf->parser_info = (void *)kboot_ignored_names,
145 rc = conf_parse(conf);
151 define_parser(kboot, 98, kboot_parse);