1 #if defined(HAVE_CONFIG_H)
10 #include "talloc/talloc.h"
11 #include "types/types.h"
12 #include "parser-conf.h"
13 #include "parser-utils.h"
16 static void kboot_process_pair(struct conf_context *conf, const char *name,
19 const char *const *ignored_names = conf->parser_info;
20 struct discover_boot_option *d_opt;
21 struct boot_option *opt;
28 /* ignore bare values */
33 if (conf_param_in_list(ignored_names, name))
36 if (conf_set_global_option(conf, name, value))
39 /* opt must be associated with dc */
41 d_opt = talloc_zero(conf->dc, struct discover_boot_option);
42 d_opt->device = conf->dc->device;
43 opt = talloc_zero(d_opt, struct boot_option);
48 opt->id = talloc_asprintf(opt, "%s#%s", conf->dc->device->device->id,
50 opt->name = talloc_strdup(opt, name);
53 args = talloc_strdup(opt, "");
54 initrd = conf_get_global_option(conf, "initrd");
55 root = conf_get_global_option(conf, "root");
56 dtb = conf_get_global_option(conf, "dtb");
58 pos = strchr(value, ' ');
60 /* if there's no space, it's only a kernel image with no params */
67 char *cl_name, *cl_value;
69 pos = conf_get_pair_equal(conf, pos, &cl_name, &cl_value, ' ');
72 args = talloc_asprintf_append(args, "%s ", cl_value);
76 if (streq(cl_name, "initrd")) {
81 if (streq(cl_name, "root")) {
86 if (streq(cl_name, "dtb")) {
91 args = talloc_asprintf_append(args, "%s=%s ", cl_name,
96 d_opt->boot_image = create_devpath_resource(d_opt,
97 conf->dc->device, value);
100 opt->boot_args = talloc_asprintf(opt, "root=%s %s", root, args);
103 opt->boot_args = args;
105 opt->description = talloc_asprintf(opt, "%s %s", value,
109 d_opt->initrd = create_devpath_resource(d_opt,
110 conf->dc->device, initrd);
111 opt->description = talloc_asprintf_append(opt->description,
112 " initrd=%s", initrd);
116 d_opt->dtb = create_devpath_resource(d_opt,
117 conf->dc->device, dtb);
118 opt->description = talloc_asprintf_append(opt->description,
122 conf_strip_str(opt->boot_args);
123 conf_strip_str(opt->description);
125 discover_context_add_boot_option(conf->dc, d_opt);
128 static struct conf_global_option kboot_global_options[] = {
130 { .name = "initrd" },
136 static const char *const kboot_conf_files[] = {
148 static const char *const kboot_ignored_names[] = {
156 static int kboot_parse(struct discover_context *dc)
158 struct conf_context *conf;
159 const char * const *filename;
163 /* Support block device boot only at present */
167 conf = talloc_zero(dc, struct conf_context);
173 conf->global_options = kboot_global_options,
174 conf_init_global_options(conf);
175 conf->get_pair = conf_get_pair_equal;
176 conf->process_pair = kboot_process_pair;
177 conf->parser_info = (void *)kboot_ignored_names;
179 for (filename = kboot_conf_files; *filename; filename++) {
180 rc = parser_request_file(dc, dc->device, *filename, &buf, &len);
184 conf_parse_buf(conf, buf, len);
192 static struct parser kboot_parser = {
194 .parse = kboot_parse,
195 .resolve_resource = resolve_devpath_resource,
198 register_parser(kboot_parser);