diff options
author | Jeremy Kerr <jk@ozlabs.org> | 2013-03-11 17:08:57 +0800 |
---|---|---|
committer | Jeremy Kerr <jk@ozlabs.org> | 2013-04-16 12:57:15 +0800 |
commit | 92806cf6bc15f680f75879288df12ea9a87e4608 (patch) | |
tree | 4a6650d8881dda3c6ee321d1e3350edc646c4baf /discover/event-parser.c | |
parent | 7b396a45d43cc464539cc25799ddda3a27339bd8 (diff) | |
download | talos-petitboot-92806cf6bc15f680f75879288df12ea9a87e4608.tar.gz talos-petitboot-92806cf6bc15f680f75879288df12ea9a87e4608.zip |
discover: Separate temporary and permanent device data
At present, we keep both permanent (eg links/n_links) and temporary
(event) data in struct discover_context.
This change makes discover_context a temporary structure, just used
during actual device discovery. Once discovery is complete, the
permanent data (discover_device) is "committed" to the device handler.
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
Diffstat (limited to 'discover/event-parser.c')
-rw-r--r-- | discover/event-parser.c | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/discover/event-parser.c b/discover/event-parser.c index c09c5ba..d7c0820 100644 --- a/discover/event-parser.c +++ b/discover/event-parser.c @@ -6,6 +6,7 @@ #include "talloc/talloc.h" #include "event.h" #include "parser-utils.h" +#include "device-handler.h" /** * parse_user_event - Parse a user event. @@ -13,12 +14,15 @@ * Understands params: name, image, args. */ -struct boot_option *parse_user_event(struct device *device, struct event *event) +int parse_user_event(struct discover_context *ctx, struct event *event) { struct boot_option *opt; + struct device *dev; const char *p; - opt = talloc_zero(device, struct boot_option); + dev = ctx->device->device; + + opt = talloc_zero(dev, struct boot_option); if (!opt) goto fail; @@ -30,8 +34,8 @@ struct boot_option *parse_user_event(struct device *device, struct event *event) goto fail; } - opt->id = talloc_asprintf(opt, "%s#%s", device->id, p); - opt->device_id = talloc_strdup(opt, device->id); + opt->id = talloc_asprintf(opt, "%s#%s", dev->id, p); + opt->device_id = talloc_strdup(opt, dev->id); opt->name = talloc_strdup(opt, p); p = event_get_param(event, "image"); @@ -52,11 +56,11 @@ struct boot_option *parse_user_event(struct device *device, struct event *event) opt->description = talloc_asprintf(opt, "%s %s", opt->boot_image_file, opt->boot_args); - device_add_boot_option(device, opt); + discover_context_add_boot_option(ctx, opt); - return opt; + return 0; fail: talloc_free(opt); - return NULL; + return -1; } |