]> git.ozlabs.org Git - petitboot/blobdiff - discover/yaboot-parser.c
discover: Send options to client in order
[petitboot] / discover / yaboot-parser.c
index 816e0c4a91f941b542791bd31f74184dcdca5288..3696abff9d7c6e9489bbce490a578b25416647ae 100644 (file)
@@ -48,15 +48,11 @@ static void yaboot_finish(struct conf_context *conf)
        conf_strip_str(opt->boot_args);
        conf_strip_str(opt->description);
 
-       /* opt is persistent, so must be associated with device */
-
        discover_context_add_boot_option(conf->dc, state->opt);
-
-       state->opt = discover_boot_option_create(conf->dc, conf->dc->device);
-       state->opt->option->boot_args = talloc_strdup(state->opt->option, "");
 }
 
 static struct resource *create_yaboot_devpath_resource(
+               struct discover_boot_option *opt,
                struct conf_context *conf,
                const char *path, char **desc_str)
 {
@@ -74,7 +70,7 @@ static struct resource *create_yaboot_devpath_resource(
                devpath = talloc_strdup(conf, path);
        }
 
-       res = create_devpath_resource(conf->dc, conf->dc->device, devpath);
+       res = create_devpath_resource(opt, conf->dc->device, devpath);
 
        if (desc_str)
                *desc_str = devpath;
@@ -122,12 +118,17 @@ static void yaboot_process_pair(struct conf_context *conf, const char *name,
        if (streq(name, "image")) {
 
                /* First finish any previous image. */
-               if (opt->boot_image)
+               if (opt)
                        yaboot_finish(conf);
 
+               opt = discover_boot_option_create(conf->dc, conf->dc->device);
+               opt->option->boot_args = talloc_strdup(opt->option, "");
+
                /* Then start the new image. */
-               opt->boot_image = create_yaboot_devpath_resource(conf,
-                               value, &state->desc_image);
+               opt->boot_image = create_yaboot_devpath_resource(opt,
+                               conf, value, &state->desc_image);
+
+               state->opt = opt;
 
                return;
        }
@@ -143,23 +144,27 @@ static void yaboot_process_pair(struct conf_context *conf, const char *name,
 
        if (suse_fp) {
                /* First finish any previous image. */
-
-               if (opt->boot_image)
+               if (opt)
                        yaboot_finish(conf);
 
                /* Then start the new image. */
 
+               opt = discover_boot_option_create(conf->dc, conf->dc->device);
+               opt->option->boot_args = talloc_strdup(opt->option, "");
+
+               state->opt = opt;
+
                if (*value == '/') {
-                       opt->boot_image = create_yaboot_devpath_resource(
+                       opt->boot_image = create_yaboot_devpath_resource(opt,
                                        conf, value, &state->desc_image);
                } else {
                        char *tmp;
 
-                       opt->boot_image = create_yaboot_devpath_resource(
+                       opt->boot_image = create_yaboot_devpath_resource(opt,
                                        conf, suse_fp->image,
                                        &state->desc_image);
 
-                       opt->initrd = create_yaboot_devpath_resource(
+                       opt->initrd = create_yaboot_devpath_resource(opt,
                                        conf, suse_fp->initrd, &tmp);
 
                        state->desc_initrd = talloc_asprintf(opt,
@@ -178,7 +183,7 @@ static void yaboot_process_pair(struct conf_context *conf, const char *name,
        /* initrd */
 
        if (streq(name, "initrd")) {
-               opt->initrd = create_yaboot_devpath_resource(conf,
+               opt->initrd = create_yaboot_devpath_resource(opt, conf,
                                value, &state->desc_image);
 
                return;
@@ -302,10 +307,7 @@ static int yaboot_parse(struct discover_context *dc, char *buf, int len)
 
        state->known_names = yaboot_known_names;
 
-       /* opt is persistent, so must be associated with device */
-
-       state->opt = discover_boot_option_create(conf->dc, conf->dc->device);
-       state->opt->option->boot_args = talloc_strdup(state->opt->option, "");
+       state->opt = NULL;
 
        conf_parse_buf(conf, buf, len);
 
@@ -314,10 +316,11 @@ static int yaboot_parse(struct discover_context *dc, char *buf, int len)
 }
 
 static struct parser yaboot_parser = {
-       .name           = "yaboot",
-       .method         = CONF_METHOD_LOCAL_FILE,
-       .parse          = yaboot_parse,
-       .filenames      = yaboot_conf_files,
+       .name                   = "yaboot",
+       .method                 = CONF_METHOD_LOCAL_FILE,
+       .parse                  = yaboot_parse,
+       .filenames              = yaboot_conf_files,
+       .resolve_resource       = resolve_devpath_resource,
 };
 
 register_parser(yaboot_parser);