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);
99 char* args_sigfile_default = talloc_asprintf(d_opt,
100 "%s.cmdline.sig", value);
101 d_opt->args_sig_file = create_devpath_resource(d_opt,
102 conf->dc->device, args_sigfile_default);
103 talloc_free(args_sigfile_default);
106 opt->boot_args = talloc_asprintf(opt, "root=%s %s", root, args);
109 opt->boot_args = args;
111 opt->description = talloc_asprintf(opt, "%s %s", value,
115 d_opt->initrd = create_devpath_resource(d_opt,
116 conf->dc->device, initrd);
117 opt->description = talloc_asprintf_append(opt->description,
118 " initrd=%s", initrd);
122 d_opt->dtb = create_devpath_resource(d_opt,
123 conf->dc->device, dtb);
124 opt->description = talloc_asprintf_append(opt->description,
128 conf_strip_str(opt->boot_args);
129 conf_strip_str(opt->description);
131 discover_context_add_boot_option(conf->dc, d_opt);
134 static struct conf_global_option kboot_global_options[] = {
136 { .name = "initrd" },
142 static const char *const kboot_conf_files[] = {
154 static const char *const kboot_ignored_names[] = {
162 static int kboot_parse(struct discover_context *dc)
164 struct conf_context *conf;
165 const char * const *filename;
169 /* Support block device boot only at present */
173 conf = talloc_zero(dc, struct conf_context);
179 conf->global_options = kboot_global_options,
180 conf_init_global_options(conf);
181 conf->get_pair = conf_get_pair_equal;
182 conf->process_pair = kboot_process_pair;
183 conf->parser_info = (void *)kboot_ignored_names;
185 for (filename = kboot_conf_files; *filename; filename++) {
186 rc = parser_request_file(dc, dc->device, *filename, &buf, &len);
190 conf_parse_buf(conf, buf, len);
198 static struct parser kboot_parser = {
200 .parse = kboot_parse,
201 .resolve_resource = resolve_devpath_resource,
204 register_parser(kboot_parser);