]> git.ozlabs.org Git - petitboot/commitdiff
discover: Always associate resources with a boot option
authorJeremy Kerr <jk@ozlabs.org>
Mon, 13 May 2013 01:16:00 +0000 (09:16 +0800)
committerJeremy Kerr <jk@ozlabs.org>
Wed, 15 May 2013 06:38:04 +0000 (14:38 +0800)
We should always be tallocing resources to a boot option context;
anything else (for example, the discover context) may have a different
lifetime.

In order to enforce this, we change the void *ctx argument to the
context_create functions to a struct discover_boot_option.

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

index 4064a3ee30db832f12116c68d27e780ef16510aa..4b4c2f7b49b9404ab67ecdd0e5fbb7ba4456a580 100644 (file)
@@ -84,7 +84,7 @@ static void kboot_process_pair(struct conf_context *conf, const char *name,
        }
 
 out_add:
        }
 
 out_add:
-       d_opt->boot_image = create_devpath_resource(opt,
+       d_opt->boot_image = create_devpath_resource(d_opt,
                                conf->dc->device, value);
 
        if (root) {
                                conf->dc->device, value);
 
        if (root) {
@@ -94,7 +94,7 @@ out_add:
                opt->boot_args = args;
 
        if (initrd) {
                opt->boot_args = args;
 
        if (initrd) {
-               d_opt->initrd = create_devpath_resource(opt,
+               d_opt->initrd = create_devpath_resource(d_opt,
                                conf->dc->device, initrd);
 
                opt->description = talloc_asprintf(opt, "%s initrd=%s %s",
                                conf->dc->device, initrd);
 
                opt->description = talloc_asprintf(opt, "%s initrd=%s %s",
index 964c1a4d40f78b68ff922980a86c930e699cc3db..b31a215b39be8b345e46abe97fcb1c2ae16387de 100644 (file)
@@ -41,7 +41,7 @@ static void resolve_devpath_against_device(struct resource *res,
        res->resolved = true;
 }
 
        res->resolved = true;
 }
 
-struct resource *create_devpath_resource(void *ctx,
+struct resource *create_devpath_resource(struct discover_boot_option *opt,
        struct discover_device *orig_device,
        const char *devpath)
 {
        struct discover_device *orig_device,
        const char *devpath)
 {
@@ -50,7 +50,7 @@ struct resource *create_devpath_resource(void *ctx,
        struct resource *res;
        struct pb_url *url;
 
        struct resource *res;
        struct pb_url *url;
 
-       res = talloc(ctx, struct resource);
+       res = talloc(opt, struct resource);
 
        pos = strchr(devpath, ':');
 
 
        pos = strchr(devpath, ':');
 
@@ -112,11 +112,12 @@ bool resolve_devpath_resource(struct device_handler *handler,
        return true;
 }
 
        return true;
 }
 
-struct resource *create_url_resource(void *ctx, struct pb_url *url)
+struct resource *create_url_resource(struct discover_boot_option *opt,
+               struct pb_url *url)
 {
        struct resource *res;
 
 {
        struct resource *res;
 
-       res = talloc(ctx, struct resource);
+       res = talloc(opt, struct resource);
        res->url = url;
        res->resolved = true;
 
        res->url = url;
        res->resolved = true;
 
index 7794ee5bbd2e402f9e418acbae070f1ed05a5b5e..3ef13a5160d81dd2b25c7c456ff1a006803d52d1 100644 (file)
@@ -3,6 +3,7 @@
 
 #include <stdbool.h>
 
 
 #include <stdbool.h>
 
+struct discover_boot_option;
 struct discover_device;
 struct device_handler;
 struct pb_url;
 struct discover_device;
 struct device_handler;
 struct pb_url;
@@ -36,11 +37,12 @@ struct resource {
  * callback.
  */
 
  * callback.
  */
 
-struct resource *create_devpath_resource(void *ctx,
+struct resource *create_devpath_resource(struct discover_boot_option *opt,
                struct discover_device *orig_device,
                const char *devpath);
 
                struct discover_device *orig_device,
                const char *devpath);
 
-struct resource *create_url_resource(void *ctx, struct pb_url *url);
+struct resource *create_url_resource(struct discover_boot_option *opt,
+               struct pb_url *url);
 
 bool resolve_devpath_resource(struct device_handler *dev,
                struct resource *res);
 
 bool resolve_devpath_resource(struct device_handler *dev,
                struct resource *res);
index 9399cc7f5f0ce796cb3d67f46a25ff9ef2c63446..3696abff9d7c6e9489bbce490a578b25416647ae 100644 (file)
@@ -52,6 +52,7 @@ static void yaboot_finish(struct conf_context *conf)
 }
 
 static struct resource *create_yaboot_devpath_resource(
 }
 
 static struct resource *create_yaboot_devpath_resource(
+               struct discover_boot_option *opt,
                struct conf_context *conf,
                const char *path, char **desc_str)
 {
                struct conf_context *conf,
                const char *path, char **desc_str)
 {
@@ -69,7 +70,7 @@ static struct resource *create_yaboot_devpath_resource(
                devpath = talloc_strdup(conf, path);
        }
 
                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;
 
        if (desc_str)
                *desc_str = devpath;
@@ -124,8 +125,8 @@ static void yaboot_process_pair(struct conf_context *conf, const char *name,
                opt->option->boot_args = talloc_strdup(opt->option, "");
 
                /* Then start the new image. */
                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;
 
 
                state->opt = opt;
 
@@ -154,16 +155,16 @@ static void yaboot_process_pair(struct conf_context *conf, const char *name,
                state->opt = opt;
 
                if (*value == '/') {
                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;
 
                                        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);
 
                                        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,
                                        conf, suse_fp->initrd, &tmp);
 
                        state->desc_initrd = talloc_asprintf(opt,
@@ -182,7 +183,7 @@ static void yaboot_process_pair(struct conf_context *conf, const char *name,
        /* initrd */
 
        if (streq(name, "initrd")) {
        /* 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;
                                value, &state->desc_image);
 
                return;