diff options
author | Jeremy Kerr <jk@ozlabs.org> | 2008-12-15 15:22:34 +1100 |
---|---|---|
committer | Jeremy Kerr <jk@ozlabs.org> | 2008-12-15 15:22:34 +1100 |
commit | 32e6a41f33e5576716b351bd473a27939fe94fa1 (patch) | |
tree | 0d6b75ac0a02d2496416095405cb9498777c3beb /ui/test | |
parent | 000a92b4fa909c432732ac3ed8f28eeeaeac70ee (diff) | |
download | talos-petitboot-32e6a41f33e5576716b351bd473a27939fe94fa1.tar.gz talos-petitboot-32e6a41f33e5576716b351bd473a27939fe94fa1.zip |
Initial support for multiple UIs
Move the device discovery code from separate udev helpers to a single
process to listen on two sockets: one SOCK_DGRAM for incoming udev
events, and one SOCK_STREAM for UIs to connect.
Initial support for client/server infrastructure, still need to wire-up
the udev messages.
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
Diffstat (limited to 'ui/test')
-rw-r--r-- | ui/test/pb-test.c | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/ui/test/pb-test.c b/ui/test/pb-test.c new file mode 100644 index 0000000..a36e991 --- /dev/null +++ b/ui/test/pb-test.c @@ -0,0 +1,62 @@ + +#include <stdio.h> + +#include "ui/common/discover-client.h" +#include "ui/common/device.h" + +static int print_device_add(struct device *device) +{ + int i; + + printf("new device:\n"); + printf("\tid: %s\n", device->id); + printf("\tname: %s\n", device->name); + printf("\tdesc: %s\n", device->description); + printf("\ticon: %s\n", device->icon_file); + + printf("\t%d boot options:\n", device->n_options); + for (i = 0; i < device->n_options; i++) { + struct boot_option *opt = &device->options[i]; + printf("\t\tid: %s\n", opt->id); + printf("\t\tname: %s\n", opt->name); + printf("\t\tdesc: %s\n", opt->description); + printf("\t\ticon: %s\n", opt->icon_file); + printf("\t\tboot: %s\n", opt->boot_image_file); + printf("\t\tinit: %s\n", opt->initrd_file); + printf("\t\targs: %s\n", opt->boot_args); + } + + return 0; +} + +static void print_device_remove(const char *dev_id) +{ + printf("removed device:\n"); + printf("\tid: %s\n", dev_id); +} + +struct discover_client_ops client_ops = { + .add_device = print_device_add, + .remove_device = print_device_remove, +}; + +int main(void) +{ + struct discover_client *client; + + printf("pid: %d\n", getpid()); + + client = discover_client_init(&client_ops); + if (!client) + return -1; + + for (;;) { + int rc; + + rc = discover_client_process(client); + if (rc) + break; + } + + return 0; +} |