X-Git-Url: http://git.ozlabs.org/?a=blobdiff_plain;f=discover%2Fdevice-handler.c;h=29c237131a4a267c25c11ce28e3f55d1b7c3ec95;hb=a79f81caba3886b5f49ebb578f0c71a42a74adfa;hp=c7e0227f242529d0673c22655c4064a5daf8e930;hpb=89ccc8e6dc81bc1d613454b9944c2f3324d43e2a;p=petitboot diff --git a/discover/device-handler.c b/discover/device-handler.c index c7e0227..29c2371 100644 --- a/discover/device-handler.c +++ b/discover/device-handler.c @@ -8,13 +8,13 @@ #include #include +#include #include #include "device-handler.h" #include "discover-server.h" #include "parser.h" #include "udev.h" -#include "log.h" #include "paths.h" #define MOUNT_BIN "/bin/mount" @@ -35,30 +35,11 @@ struct mount_map { char *mount_point; }; - -static struct boot_option options[] = { - { - .id = "1.1", - .name = "meep one", - .description = "meep description one", - .icon_file = "meep.one.png", - .boot_args = "root=/dev/sda1", - }, -}; - -static struct device device = { - .id = "1", - .name = "meep", - .description = "meep description", - .icon_file = "meep.png", -}; - int device_handler_get_current_devices(struct device_handler *handler, - struct device **devices) - + const struct device **devices) { - *devices = &device; - return 1; + *devices = handler->devices; + return handler->n_devices; } static int mkdir_recursive(const char *dir) @@ -226,8 +207,11 @@ static int mount_device(struct discover_context *ctx) goto out_rmdir; } - if (!WIFEXITED(status) || WEXITSTATUS(status) != 0) + if (!WIFEXITED(status) || WEXITSTATUS(status) != 0) { + pb_log("%s: mount failed (%d): %s\n", __func__, + WEXITSTATUS(status), ctx->event->device); goto out_rmdir; + } setup_device_links(ctx); return 0; @@ -282,7 +266,6 @@ static struct discover_context *find_context(struct device_handler *handler, return NULL; } - static int destroy_context(void *arg) { struct discover_context *ctx = arg; @@ -319,7 +302,6 @@ static int handle_add_event(struct device_handler *handler, rc = mount_device(ctx); if (rc) { - pb_log("mount_device failed for %s\n", event->device); talloc_free(ctx); return 0; } @@ -377,7 +359,6 @@ int device_handler_event(struct device_handler *handler, struct device_handler *device_handler_init(struct discover_server *server) { struct device_handler *handler; - int i; handler = talloc(NULL, struct device_handler); handler->devices = NULL; @@ -389,12 +370,6 @@ struct device_handler *device_handler_init(struct discover_server *server) /* set up our mount point base */ mkdir_recursive(mount_base()); - /* setup out test objects */ - list_init(&device.boot_options); - - for (i = 0; i < sizeof(options) / sizeof(options[0]); i++) - list_add(&device.boot_options, &options[i].list); - parser_init(); return handler; @@ -404,4 +379,3 @@ void device_handler_destroy(struct device_handler *handler) { talloc_free(handler); } -