summaryrefslogtreecommitdiffstats
path: root/discover/device-handler.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/device-handler.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/device-handler.c')
-rw-r--r--discover/device-handler.c58
1 files changed, 58 insertions, 0 deletions
diff --git a/discover/device-handler.c b/discover/device-handler.c
index 908409c..c72390b 100644
--- a/discover/device-handler.c
+++ b/discover/device-handler.c
@@ -335,6 +335,52 @@ static int handle_remove_udev_event(struct device_handler *handler,
return 0;
}
+static int handle_add_user_event(struct device_handler *handler,
+ struct event *event)
+{
+ struct device *device;
+
+ assert(event->device);
+
+ device = talloc_zero(handler, struct device);
+
+ if (!device)
+ goto fail;
+
+ device->id = talloc_strdup(device, event->device);
+ list_init(&device->boot_options);
+
+ parse_user_event(device, event);
+
+ discover_server_notify_add(handler->server, device);
+
+ /* add device to handler device array */
+ device_handler_add(handler, device);
+
+ return 0;
+
+fail:
+ talloc_free(device);
+ return 0;
+}
+
+static int handle_remove_user_event(struct device_handler *handler,
+ struct event *event)
+{
+ struct device *device = device_handler_find(handler, event->device);
+
+ if (!device)
+ return 0;
+
+ discover_server_notify_remove(handler->server, device);
+
+ /* remove device from handler device array */
+ device_handler_remove(handler, device);
+
+ talloc_free(device);
+ return 0;
+}
+
int device_handler_event(struct device_handler *handler,
struct event *event)
{
@@ -356,6 +402,18 @@ int device_handler_event(struct device_handler *handler,
}
break;
case EVENT_TYPE_USER:
+ switch (event->action) {
+ case EVENT_ACTION_ADD:
+ rc = handle_add_user_event(handler, event);
+ break;
+ case EVENT_ACTION_REMOVE:
+ rc = handle_remove_user_event(handler, event);
+ break;
+ default:
+ pb_log("%s unknown action: %d\n", __func__,
+ event->action);
+ break;
+ }
break;
default:
pb_log("%s unknown type: %d\n", __func__, event->type);
OpenPOWER on IntegriCloud