1 #if defined(HAVE_CONFIG_H)
11 #include "talloc/talloc.h"
12 #include "types/types.h"
13 #include "parser-conf.h"
14 #include "parser-utils.h"
17 static void kboot_process_pair(struct conf_context *conf, const char *name,
20 const char *const *ignored_names = conf->parser_info;
21 struct discover_boot_option *d_opt;
22 struct boot_option *opt;
29 /* ignore bare values */
34 if (conf_param_in_list(ignored_names, name))
37 if (conf_set_global_option(conf, name, value))
40 /* opt must be associated with dc */
42 d_opt = talloc_zero(conf->dc, struct discover_boot_option);
43 d_opt->device = conf->dc->device;
44 opt = talloc_zero(d_opt, struct boot_option);
49 opt->id = talloc_asprintf(opt, "%s#%s", conf->dc->device->device->id,
51 opt->name = talloc_strdup(opt, name);
54 args = talloc_strdup(opt, "");
55 initrd = conf_get_global_option(conf, "initrd");
56 root = conf_get_global_option(conf, "root");
57 dtb = conf_get_global_option(conf, "dtb");
59 pos = strchr(value, ' ');
61 /* if there's no space, it's only a kernel image with no params */
68 char *cl_name, *cl_value;
70 pos = conf_get_pair_equal(conf, pos, &cl_name, &cl_value, ' ');
73 args = talloc_asprintf_append(args, "%s ", cl_value);
77 if (streq(cl_name, "initrd")) {
82 if (streq(cl_name, "root")) {
87 if (streq(cl_name, "dtb")) {
92 args = talloc_asprintf_append(args, "%s=%s ", cl_name,
97 d_opt->boot_image = create_devpath_resource(d_opt,
98 conf->dc->device, value);
100 char* args_sigfile_default = talloc_asprintf(d_opt,
101 "%s.cmdline.sig", value);
102 d_opt->args_sig_file = create_devpath_resource(d_opt,
103 conf->dc->device, args_sigfile_default);
104 talloc_free(args_sigfile_default);
107 opt->boot_args = talloc_asprintf(opt, "root=%s %s", root, args);
110 opt->boot_args = args;
112 opt->description = talloc_asprintf(opt, "%s %s", value,
116 d_opt->initrd = create_devpath_resource(d_opt,
117 conf->dc->device, initrd);
118 opt->description = talloc_asprintf_append(opt->description,
119 " initrd=%s", initrd);
123 d_opt->dtb = create_devpath_resource(d_opt,
124 conf->dc->device, dtb);
125 opt->description = talloc_asprintf_append(opt->description,
129 conf_strip_str(opt->boot_args);
130 conf_strip_str(opt->description);
132 discover_context_add_boot_option(conf->dc, d_opt);
135 static struct conf_global_option kboot_global_options[] = {
137 { .name = "initrd" },
143 static const char *const kboot_conf_files[] = {
155 static const char *const kboot_ignored_names[] = {
163 static int kboot_parse(struct discover_context *dc)
165 struct conf_context *conf;
166 const char * const *filename;
170 /* Support block device boot only at present */
174 conf = talloc_zero(dc, struct conf_context);
180 conf->global_options = kboot_global_options,
181 conf_init_global_options(conf);
182 conf->get_pair = conf_get_pair_equal;
183 conf->process_pair = kboot_process_pair;
184 conf->parser_info = (void *)kboot_ignored_names;
186 for (filename = kboot_conf_files; *filename; filename++) {
187 rc = parser_request_file(dc, dc->device, *filename, &buf, &len);
191 conf_parse_buf(conf, buf, len);
192 device_handler_status_dev_info(dc->handler, dc->device,
193 _("Parsed kboot configuration from %s"),
202 static struct parser kboot_parser = {
204 .parse = kboot_parse,
205 .resolve_resource = resolve_devpath_resource,
208 register_parser(kboot_parser);