From 1b50985db4e85030de3567792aedc13aa26e0fea Mon Sep 17 00:00:00 2001 From: Jeremy Kerr Date: Mon, 13 May 2013 09:16:00 +0800 Subject: discover: Always associate resources with a boot option 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 --- discover/kboot-parser.c | 4 ++-- discover/resource.c | 9 +++++---- discover/resource.h | 6 ++++-- discover/yaboot-parser.c | 15 ++++++++------- 4 files changed, 19 insertions(+), 15 deletions(-) (limited to 'discover') diff --git a/discover/kboot-parser.c b/discover/kboot-parser.c index 4064a3e..4b4c2f7 100644 --- a/discover/kboot-parser.c +++ b/discover/kboot-parser.c @@ -84,7 +84,7 @@ static void kboot_process_pair(struct conf_context *conf, const char *name, } 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) { @@ -94,7 +94,7 @@ out_add: 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", diff --git a/discover/resource.c b/discover/resource.c index 964c1a4..b31a215 100644 --- a/discover/resource.c +++ b/discover/resource.c @@ -41,7 +41,7 @@ static void resolve_devpath_against_device(struct resource *res, 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) { @@ -50,7 +50,7 @@ struct resource *create_devpath_resource(void *ctx, struct resource *res; struct pb_url *url; - res = talloc(ctx, struct resource); + res = talloc(opt, struct resource); pos = strchr(devpath, ':'); @@ -112,11 +112,12 @@ bool resolve_devpath_resource(struct device_handler *handler, 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; - res = talloc(ctx, struct resource); + res = talloc(opt, struct resource); res->url = url; res->resolved = true; diff --git a/discover/resource.h b/discover/resource.h index 7794ee5..3ef13a5 100644 --- a/discover/resource.h +++ b/discover/resource.h @@ -3,6 +3,7 @@ #include +struct discover_boot_option; struct discover_device; struct device_handler; struct pb_url; @@ -36,11 +37,12 @@ struct resource { * 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 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); diff --git a/discover/yaboot-parser.c b/discover/yaboot-parser.c index 9399cc7..3696abf 100644 --- a/discover/yaboot-parser.c +++ b/discover/yaboot-parser.c @@ -52,6 +52,7 @@ static void yaboot_finish(struct conf_context *conf) } static struct resource *create_yaboot_devpath_resource( + struct discover_boot_option *opt, 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); } - 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; @@ -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->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; @@ -154,16 +155,16 @@ static void yaboot_process_pair(struct conf_context *conf, const char *name, 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, @@ -182,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; -- cgit v1.2.1