X-Git-Url: http://git.ozlabs.org/?p=petitboot;a=blobdiff_plain;f=discover%2Fdevice-handler.c;h=9033c4fdfb8d3162417ed332e415b6446d33df8e;hp=43bcd9f760249444d86eae8587bfb8725d8987b6;hb=d67d5beceef94686818ce264b2ca93f82b66e8f4;hpb=089d0a6eb769d531129a7cd1061493a1a24b4bef diff --git a/discover/device-handler.c b/discover/device-handler.c index 43bcd9f..9033c4f 100644 --- a/discover/device-handler.c +++ b/discover/device-handler.c @@ -1,4 +1,3 @@ - #include #include #include @@ -24,6 +23,7 @@ #include "parser.h" #include "resource.h" #include "paths.h" +#include "sysinfo.h" #include "boot.h" struct device_handler { @@ -368,7 +368,7 @@ static int default_option_priority(struct discover_boot_option *opt) { const struct config *config; struct boot_priority *prio; - int i; + unsigned int i; config = config_get(); @@ -524,10 +524,8 @@ struct discover_context *device_handler_discover_context_create( { struct discover_context *ctx; - ctx = talloc(handler, struct discover_context); + ctx = talloc_zero(handler, struct discover_context); ctx->device = device; - ctx->conf_url = NULL; - ctx->test_data = NULL; list_init(&ctx->boot_options); return ctx; @@ -591,7 +589,7 @@ void device_handler_add_device(struct device_handler *handler, * array, but has only just been initialised by the hotplug source. */ int device_handler_discover(struct device_handler *handler, - struct discover_device *dev, enum conf_method method) + struct discover_device *dev) { struct discover_context *ctx; int rc; @@ -605,8 +603,12 @@ int device_handler_discover(struct device_handler *handler, if (rc) goto out; + /* add this device to our system info */ + system_info_register_blockdev(dev->device->id, dev->uuid, + dev->mount_path); + /* run the parsers. This will populate the ctx's boot_option list. */ - iterate_parsers(ctx, method); + iterate_parsers(ctx); /* add discovered stuff to the handler */ device_handler_discover_context_commit(handler, ctx); @@ -617,18 +619,17 @@ out: return 0; } -/* incoming conf event */ -int device_handler_conf(struct device_handler *handler, - struct discover_device *dev, struct pb_url *url, - enum conf_method method) +/* Incoming dhcp event */ +int device_handler_dhcp(struct device_handler *handler, + struct discover_device *dev, struct event *event) { struct discover_context *ctx; /* create our context */ ctx = device_handler_discover_context_create(handler, dev); - ctx->conf_url = url; + ctx->event = event; - iterate_parsers(ctx, method); + iterate_parsers(ctx); device_handler_discover_context_commit(handler, ctx); @@ -637,6 +638,25 @@ int device_handler_conf(struct device_handler *handler, return 0; } +/* incoming conf event */ +int device_handler_conf(struct device_handler *handler, + struct discover_device *dev, struct pb_url *url) +{ + struct discover_context *ctx; + + /* create our context */ + ctx = device_handler_discover_context_create(handler, dev); + ctx->conf_url = url; + + iterate_parsers(ctx); + + device_handler_discover_context_commit(handler, ctx); + + talloc_free(ctx); + + return 0; +} + static struct discover_boot_option *find_boot_option_by_id( struct device_handler *handler, const char *id) { @@ -701,6 +721,13 @@ void device_handler_cancel_default(struct device_handler *handler) discover_server_notify_boot_status(handler->server, &status); } +void device_handler_update_config(struct device_handler *handler, + struct config *config) +{ + config_set(config); + discover_server_notify_config(handler->server, config); +} + #ifndef PETITBOOT_TEST static bool check_existing_mount(struct discover_device *dev) {