summaryrefslogtreecommitdiffstats
path: root/discover/event-parser.c
diff options
context:
space:
mode:
authorGeoff Levand <geoffrey.levand@am.sony.com>2009-04-12 15:11:54 +0000
committerJeremy Kerr <jk@ozlabs.org>2009-06-30 15:29:22 +0800
commitfbb2f7a20e5ac7b6d9f578fdb3538fad4310c472 (patch)
tree5ae45fc83b13c1143439636d3661361a04eac2a7 /discover/event-parser.c
parentd7ce19907ff585e7fb6b950a40bd638d49c96a27 (diff)
downloadtalos-petitboot-fbb2f7a20e5ac7b6d9f578fdb3538fad4310c472.tar.gz
talos-petitboot-fbb2f7a20e5ac7b6d9f578fdb3538fad4310c472.zip
Add discover user event
Add a gereric event interface to pb-discover. Signed-off-by: Geoff Levand <geoffrey.levand@am.sony.com> Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
Diffstat (limited to 'discover/event-parser.c')
-rw-r--r--discover/event-parser.c55
1 files changed, 55 insertions, 0 deletions
diff --git a/discover/event-parser.c b/discover/event-parser.c
new file mode 100644
index 0000000..0cfda9a
--- /dev/null
+++ b/discover/event-parser.c
@@ -0,0 +1,55 @@
+#define _GNU_SOURCE
+
+#include <assert.h>
+
+#include "log/log.h"
+#include "talloc/talloc.h"
+#include "event.h"
+#include "parser-utils.h"
+
+int parse_user_event(struct device *device, struct event *event)
+{
+ struct boot_option *opt;
+ const char *p;
+
+ opt = talloc_zero(device, struct boot_option);
+
+ if (!opt)
+ goto fail;
+
+ p = event_get_param(event, "name");
+
+ if (!p) {
+ pb_log("%s: no name found\n", __func__);
+ goto fail;
+ }
+
+ opt->id = talloc_asprintf(opt, "%s#%s", device->id, p);
+ opt->name = talloc_strdup(opt, p);
+
+ p = event_get_param(event, "image");
+ assert(p);
+
+ if (!p) {
+ pb_log("%s: no image found\n", __func__);
+ goto fail;
+ }
+
+ opt->boot_image_file = talloc_strdup(opt, p);
+
+ p = event_get_param(event, "args");
+ assert(p);
+
+ opt->boot_args = talloc_strdup(opt, p);
+
+ opt->description = talloc_asprintf(opt, "%s %s", opt->boot_image_file,
+ opt->boot_args);
+
+ device_add_boot_option(device, opt);
+
+ return 0;
+
+fail:
+ talloc_free(opt);
+ return -1;
+}
OpenPOWER on IntegriCloud