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 /test/parser/parser-test.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 'test/parser/parser-test.c')
-rw-r--r-- | test/parser/parser-test.c | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/test/parser/parser-test.c b/test/parser/parser-test.c index 75533e3..d8ec75b 100644 --- a/test/parser/parser-test.c +++ b/test/parser/parser-test.c @@ -17,10 +17,15 @@ static FILE *testf; -void device_add_boot_option(struct device *device, +struct device *discover_context_device(struct discover_context *ctx) +{ + return ctx->device->device; +} + +void discover_context_add_boot_option(struct discover_context *ctx, struct boot_option *boot_option) { - fprintf(testf, "%s: %s\n", __func__, device->id); + fprintf(testf, "%s: %s\n", __func__, ctx->device->device->id); fprintf(testf, " id '%s'\n", boot_option->id); fprintf(testf, " name '%s'\n", boot_option->name); fprintf(testf, " descr '%s'\n", boot_option->description); @@ -62,9 +67,11 @@ int main(int argc, char **argv) ctx = talloc_zero(NULL, struct discover_context); - ctx->device_path = talloc_asprintf(ctx, "%s/%s", argv[1], argv[2]); - ctx->device = talloc_zero(ctx, struct device); - ctx->device->id = talloc_strdup(ctx->device, argv[2]); + ctx->device = talloc_zero(ctx, struct discover_device); + ctx->device->device = talloc_zero(ctx->device, struct device); + ctx->device->device_path = talloc_asprintf(ctx, "%s/%s", + argv[1], argv[2]); + ctx->device->device->id = talloc_strdup(ctx->device->device, argv[2]); iterate_parsers(ctx); |