From ce5eab024583af5a4725503bad6ed2aee452b1aa Mon Sep 17 00:00:00 2001 From: Jeremy Kerr Date: Fri, 2 Jan 2009 16:34:18 +0900 Subject: Hook up parsers to device discovery Iterate the parsers from the device handler on an add event. Initial change to just the kboot parser. Signed-off-by: Jeremy Kerr --- discover/device-handler.c | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) (limited to 'discover/device-handler.c') diff --git a/discover/device-handler.c b/discover/device-handler.c index 1f8938f..593b8e0 100644 --- a/discover/device-handler.c +++ b/discover/device-handler.c @@ -11,6 +11,8 @@ #include #include "device-handler.h" +#include "discover-server.h" +#include "parser.h" #include "udev.h" #include "log.h" #include "paths.h" @@ -28,18 +30,6 @@ struct device_handler { struct list contexts; }; -struct discover_context { - char *id; - char *device_path; - char *mount_path; - struct udev_event *event; - struct device *device; - char **links; - int n_links; - - struct list_item list; -}; - struct mount_map { char *device_path; char *mount_point; @@ -335,9 +325,18 @@ static int handle_add_event(struct device_handler *handler, } list_add(&handler->contexts, &ctx->list); - talloc_set_destructor(ctx, destroy_context); + /* set up the top-level device */ + ctx->device = talloc_zero(ctx, struct device); + ctx->device->id = talloc_strdup(ctx->device, ctx->id); + list_init(&ctx->device->boot_options); + + /* run the parsers */ + iterate_parsers(ctx); + + discover_server_notify_add(handler->server, ctx->device); + return 0; } @@ -350,6 +349,8 @@ static int handle_remove_event(struct device_handler *handler, if (!ctx) return 0; + discover_server_notify_remove(handler->server, ctx->device); + talloc_free(ctx); return 0; @@ -381,6 +382,7 @@ struct device_handler *device_handler_init(struct discover_server *server) handler = talloc(NULL, struct device_handler); handler->devices = NULL; handler->n_devices = 0; + handler->server = server; list_init(&handler->contexts); -- cgit v1.2.1