X-Git-Url: http://git.ozlabs.org/?p=petitboot;a=blobdiff_plain;f=devices.c;h=e4d6913875b6025f7f6a22ec685e861cb766c744;hp=28cb3a38e3828f328a8ee7434eb073ffb970379a;hb=678dbd282f917c68c4fd6badfc14fcf464796f5d;hpb=db8001f511f8e8d928aa82113431067f968f4966 diff --git a/devices.c b/devices.c index 28cb3a3..e4d6913 100644 --- a/devices.c +++ b/devices.c @@ -1,4 +1,5 @@ #include +#include #include #include #include @@ -12,7 +13,7 @@ #include "petitboot-paths.h" #include "devices/message.h" -#define PBOOT_DEFAULT_ICON "usbpen.png" +#define PBOOT_DEFAULT_ICON "tux.png" static const char *default_icon = artwork_pathname(PBOOT_DEFAULT_ICON); @@ -152,21 +153,22 @@ out: static int read_option(int fd, struct device_context *dev_ctx) { - struct boot_option opt; + struct boot_option *opt = malloc(sizeof(*opt)); twin_pixmap_t *icon; int index = -1; - if (!read_strings(fd, opt)) + if (!opt) return TWIN_FALSE; - LOG("got option: '%s'\n", opt.name); - icon = get_icon(opt.icon_file); + if (!read_strings(fd, (*opt))) + return TWIN_FALSE; - if (icon) - index = pboot_add_option(dev_ctx->device_idx, opt.name, - opt.description, icon); + LOG("got option: '%s'\n", opt->name); + icon = get_icon(opt->icon_file); - free_strings(opt); + if (icon) + index = pboot_add_option(dev_ctx->device_idx, opt->name, + opt->description, icon, opt); return index != -1; } @@ -236,7 +238,7 @@ static twin_bool_t pboot_proc_server_sock(int sock, twin_file_op_t ops, return TWIN_TRUE; } -int pboot_start_device_discovery(void) +int pboot_start_device_discovery(int udev_trigger) { int sock; struct sockaddr_un addr; @@ -267,6 +269,36 @@ int pboot_start_device_discovery(void) twin_set_file(pboot_proc_server_sock, sock, TWIN_READ, &_ctx); + if (udev_trigger) { + int rc = system("udevtrigger"); + if (rc) + LOG("udevtrigger failed, rc %d\n", rc); + } + return TWIN_TRUE; } +void pboot_exec_option(void *data) +{ + struct boot_option *opt = data; + char *kexec_opts[10]; + int nr_opts = 2; + + kexec_opts[0] = "/sbin/kexec"; + kexec_opts[1] = "-f"; + if (opt->initrd_file) { + kexec_opts[nr_opts] = malloc(10 + strlen(opt->initrd_file)); + sprintf(kexec_opts[nr_opts], "--initrd=%s", opt->initrd_file); + nr_opts++; + } + if (opt->boot_args) { + kexec_opts[nr_opts] = malloc(10 + strlen(opt->boot_args)); + sprintf(kexec_opts[nr_opts], "--command-line=%s", + opt->boot_args); + nr_opts++; + } + + kexec_opts[nr_opts++] = opt->boot_image_file; + kexec_opts[nr_opts] = NULL; + execv(kexec_opts[0], kexec_opts); +}