discover/yaboot: Fix boot option state
authorJeremy Kerr <jk@ozlabs.org>
Fri, 10 May 2013 02:16:48 +0000 (10:16 +0800)
committerJeremy Kerr <jk@ozlabs.org>
Wed, 15 May 2013 06:36:53 +0000 (14:36 +0800)
We're only picking up every second boot option.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
discover/yaboot-parser.c

index 65252029952acfad51a4416567ed4698db621cc5..9399cc7f5f0ce796cb3d67f46a25ff9ef2c63446 100644 (file)
@@ -48,12 +48,7 @@ static void yaboot_finish(struct conf_context *conf)
        conf_strip_str(opt->boot_args);
        conf_strip_str(opt->description);
 
        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);
        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(
 }
 
 static struct resource *create_yaboot_devpath_resource(
@@ -122,13 +117,18 @@ static void yaboot_process_pair(struct conf_context *conf, const char *name,
        if (streq(name, "image")) {
 
                /* First finish any previous image. */
        if (streq(name, "image")) {
 
                /* First finish any previous image. */
-               if (opt->boot_image)
+               if (opt)
                        yaboot_finish(conf);
 
                        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);
 
                /* Then start the new image. */
                opt->boot_image = create_yaboot_devpath_resource(conf,
                                value, &state->desc_image);
 
+               state->opt = opt;
+
                return;
        }
 
                return;
        }
 
@@ -143,12 +143,16 @@ static void yaboot_process_pair(struct conf_context *conf, const char *name,
 
        if (suse_fp) {
                /* First finish any previous image. */
 
        if (suse_fp) {
                /* First finish any previous image. */
-
-               if (opt->boot_image)
+               if (opt)
                        yaboot_finish(conf);
 
                /* Then start the new image. */
 
                        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(
                                        conf, value, &state->desc_image);
                if (*value == '/') {
                        opt->boot_image = create_yaboot_devpath_resource(
                                        conf, value, &state->desc_image);
@@ -302,10 +306,7 @@ static int yaboot_parse(struct discover_context *dc, char *buf, int len)
 
        state->known_names = yaboot_known_names;
 
 
        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);
 
 
        conf_parse_buf(conf, buf, len);