X-Git-Url: http://git.ozlabs.org/?p=petitboot;a=blobdiff_plain;f=discover%2Fdevice-handler.c;h=352a477d16230c49b4a14c6201bf3d7ab03de649;hp=8bac86673b89abdc598991fa6c77eb19a9c58962;hb=edcfca78ac49793e295ac97328942321f39e3996;hpb=70fb2ec0af31c1d78c8655ef13f682d597921390 diff --git a/discover/device-handler.c b/discover/device-handler.c index 8bac866..352a477 100644 --- a/discover/device-handler.c +++ b/discover/device-handler.c @@ -19,6 +19,7 @@ #include "device-handler.h" #include "discover-server.h" +#include "user-event.h" #include "platform.h" #include "event.h" #include "parser.h" @@ -26,11 +27,17 @@ #include "paths.h" #include "sysinfo.h" #include "boot.h" +#include "udev.h" +#include "network.h" struct device_handler { struct discover_server *server; int dry_run; + struct pb_udev *udev; + struct network *network; + struct user_event *user_event; + struct discover_device **devices; unsigned int n_devices; @@ -49,6 +56,8 @@ struct device_handler { static int mount_device(struct discover_device *dev); static int umount_device(struct discover_device *dev); +static int device_handler_init_sources(struct device_handler *handler); + void discover_context_add_boot_option(struct discover_context *ctx, struct discover_boot_option *boot_option) { @@ -260,6 +269,7 @@ struct device_handler *device_handler_init(struct discover_server *server, struct waitset *waitset, int dry_run) { struct device_handler *handler; + int rc; handler = talloc_zero(NULL, struct device_handler); handler->server = server; @@ -274,6 +284,12 @@ struct device_handler *device_handler_init(struct discover_server *server, parser_init(); + rc = device_handler_init_sources(handler); + if (rc) { + talloc_free(handler); + return NULL; + } + return handler; } @@ -750,6 +766,26 @@ void device_handler_update_config(struct device_handler *handler, } #ifndef PETITBOOT_TEST + +static int device_handler_init_sources(struct device_handler *handler) +{ + /* init our device sources: udev, network and user events */ + handler->udev = udev_init(handler, handler->waitset); + if (!handler->udev) + return -1; + + handler->network = network_init(handler, handler->waitset, + handler->dry_run); + if (!handler->network) + return -1; + + handler->user_event = user_event_init(handler, handler->waitset); + if (!handler->user_event) + return -1; + + return 0; +} + static bool check_existing_mount(struct discover_device *dev) { struct stat devstat, mntstat; @@ -911,6 +947,12 @@ void device_release_write(struct discover_device *dev, bool release) #else +static int device_handler_init_sources( + struct device_handler *handler __attribute__((unused))) +{ + return 0; +} + static int umount_device(struct discover_device *dev __attribute__((unused))) { return 0;