summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEamon Walsh <ewalsh@tycho.nsa.gov>2011-05-23 15:13:31 -0400
committerEamon Walsh <ewalsh@tycho.nsa.gov>2011-05-23 15:13:31 -0400
commitafe308ad0b2696365364988947bbe8870d6ff9a2 (patch)
treedc97e7760fdcc472c396493adf47fba947ca164b
parent8e737310a7835d1375201d8ab7245e9afa2f2c02 (diff)
Remove util/ and its contents.
-rw-r--r--util/.gitignore5
-rw-r--r--util/Makefile11
-rw-r--r--util/commdump.pl17
-rw-r--r--util/evdump.c264
-rw-r--r--util/gnttest.c58
-rw-r--r--util/pipe2.c84
-rw-r--r--util/xsdump.c45
7 files changed, 0 insertions, 484 deletions
diff --git a/util/.gitignore b/util/.gitignore
deleted file mode 100644
index abd841a..0000000
--- a/util/.gitignore
+++ /dev/null
@@ -1,5 +0,0 @@
-evdump
-gnttest
-pipe2
-xsdump
-!Makefile
diff --git a/util/Makefile b/util/Makefile
deleted file mode 100644
index 4429a43..0000000
--- a/util/Makefile
+++ /dev/null
@@ -1,11 +0,0 @@
-TARGETS = pipe2 gnttest evdump xsdump
-
-CFLAGS = -Wall -I../src
-LDLIBS := -lxenctrl -lxenstore -ludev
-
-.PHONY: all clean
-
-all: $(TARGETS)
-
-clean:
- $(RM) $(TARGETS) *.o
diff --git a/util/commdump.pl b/util/commdump.pl
deleted file mode 100644
index 97ba199..0000000
--- a/util/commdump.pl
+++ /dev/null
@@ -1,17 +0,0 @@
-#!/usr/bin/perl
-
-use warnings;
-use strict;
-
-my $ret;
-my $buf;
-
-while (1) {
- $ret = sysread(STDIN, $buf, 24);
- last if $ret == 0;
- die if $ret != 24;
-
- my @a = unpack("L6", $buf);
-
- printf("%d %x: %d %d %d %d\n", @a);
-}
diff --git a/util/evdump.c b/util/evdump.c
deleted file mode 100644
index 6cad2bf..0000000
--- a/util/evdump.c
+++ /dev/null
@@ -1,264 +0,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <string.h>
-#include <signal.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <sys/mman.h>
-#include <sys/select.h>
-#include <fcntl.h>
-#include <errno.h>
-#include <libudev.h>
-#include <linux/input.h>
-#include "sys-queue.h"
-
-#define MAX_DEVICES 16
-#define DEVICE_PATH_LEN 32
-#define DEVICE_NAME_LEN 64
-#define DEVICE_LEN (DEVICE_PATH_LEN + DEVICE_NAME_LEN)
-#define DEVICE_STEM "/dev/input/event"
-
-struct device {
- int fd;
- char *name;
- char *path;
- TAILQ_ENTRY(device) next;
-};
-
-TAILQ_HEAD(device_list, device);
-
-static struct device_list dl = TAILQ_HEAD_INITIALIZER(dl);
-static struct udev_monitor *udev_monitor;
-static fd_set fds;
-static int maxfd;
-
-static void
-input_event(void *closure)
-{
- struct device *d = closure;
- struct input_event levt[64];
- int i, readlen;
-
- readlen = read(d->fd, levt, sizeof(levt));
- if (readlen <= 0)
- return;
-
- for (i =0; i < readlen / sizeof(*levt); i++) {
- switch (levt[i].type) {
- case EV_SYN:
- switch(levt[i].code) {
- case SYN_REPORT:
- break;
- default:
- printf("SYN: %d\n", levt[i].code);
- }
- break;
- case EV_KEY:
- fprintf(stderr, "Received keypress: %d %s\n", levt[i].code, levt[i].value ? "down" : "up");
- break;
- case EV_REL:
- fprintf(stderr, "Received relative motion\n");
- break;
- case EV_ABS:
- fprintf(stderr, "Received absolute motion\n");
- break;
- case EV_MSC:
- break;
- default:
- printf("%d\n", levt[i].type);
- }
- }
-}
-
-static int
-open_device(const char *path)
-{
- struct device *d;
- int fd = -1;
- char *name = "(unknown)";
- unsigned int bits;
-
- d = calloc(DEVICE_LEN + sizeof(struct device), 1);
- if (!d)
- goto err;
-
- fd = open(path, O_RDWR);
- if (fd < 0)
- goto err;
-
- d->fd = fd;
- d->path = (char *)(d + 1);
- d->name = (char *)(d + 1) + DEVICE_PATH_LEN;
- strncpy(d->path, path, DEVICE_PATH_LEN - 1);
-
- if (ioctl(fd, EVIOCGRAB, 1) < 0)
- goto err;
-
- if (ioctl(fd, EVIOCGNAME(DEVICE_NAME_LEN - 1), d->name) < 0)
- goto err;
- name = d->name;
-
- if (ioctl(fd, EVIOCGBIT(0, 4), &bits) < 0)
- goto err;
-
- TAILQ_INSERT_TAIL(&dl, d, next);
- maxfd = (fd > maxfd) ? fd : maxfd;
- fprintf(stderr, "Opened device '%s' on %s\n", name, path);
- return 0;
-err:
- fprintf(stderr, "Warning: failed to open device '%s' on %s\n", name, path);
- free(d);
- if (fd >= 0) {
- ioctl(fd, EVIOCGRAB, 0);
- close(fd);
- }
- return -1;
-}
-
-static void
-close_device(struct device *d)
-{
- ioctl(d->fd, EVIOCGRAB, 0);
- close(d->fd);
- TAILQ_REMOVE(&dl, d, next);
- free(d);
-}
-
-static void
-device_added(struct udev_device *udev_device)
-{
- const char *path, *key, *value, *class;
- struct udev_list_entry *set, *entry;
-
- path = udev_device_get_devnode(udev_device);
- if (!path)
- return;
-
- if (strncmp(path, DEVICE_STEM, strlen(DEVICE_STEM)))
- return;
-
- class = udev_device_get_property_value(udev_device, "ID_CLASS");
- if (class && (!strcmp(class, "kbd") || !strcmp(class, "mouse"))) {
- open_device(path);
- return;
- }
-
- set = udev_device_get_properties_list_entry(udev_device);
- udev_list_entry_foreach(entry, set) {
- key = udev_list_entry_get_name(entry);
- if (!key)
- continue;
- value = udev_list_entry_get_value(entry);
- if (!strcmp(key, "ID_INPUT_KEY")) {
- open_device(path);
- } else if (!strcmp(key, "ID_INPUT_MOUSE")) {
- open_device(path);
- } else if (!strcmp(key, "ID_INPUT_JOYSTICK")) {
- ;
- } else if (!strcmp(key, "ID_INPUT_TABLET")) {
- ;
- } else if (!strcmp(key, "ID_INPUT_TOUCHPAD")) {
- open_device(path);
- } else if (!strcmp(key, "ID_INPUT_TOUCHSCREEN")) {
- ;
- }
- }
-}
-
-static void
-device_removed(struct udev_device *udev_device)
-{
- const char *path;
- struct device *d;
-
- path = udev_device_get_devnode(udev_device);
- if (!path)
- return;
-
- if (strncmp(path, DEVICE_STEM, strlen(DEVICE_STEM)))
- return;
-
- TAILQ_FOREACH(d, &dl, next)
- if (!strcmp(d->path, path)) {
- close_device(d);
- return;
- }
-
- fprintf(stderr, "Warning: failed to close device %s\n", path);
-}
-
-static void
-udev_event(void)
-{
- struct udev_device *udev_device;
- const char *action;
-
- udev_device = udev_monitor_receive_device(udev_monitor);
- if (udev_device) {
- action = udev_device_get_action(udev_device);
- if (action) {
- if (!strcmp(action, "add"))
- device_added(udev_device);
- else if (!strcmp(action, "remove"))
- device_removed(udev_device);
- }
- udev_device_unref(udev_device);
- }
-}
-
-int
-main(int argc, char *argv[])
-{
- struct udev *udev;
- struct udev_enumerate *enumerate;
- struct udev_list_entry *devices, *device;
- struct device *d;
- int fd, rc;
-
- if (!(udev = udev_new()))
- goto err;
- if (!(udev_monitor = udev_monitor_new_from_netlink(udev, "udev")))
- goto err;
- if (udev_monitor_enable_receiving(udev_monitor))
- goto err;
-
- if (!(enumerate = udev_enumerate_new(udev)))
- goto err;
- udev_enumerate_scan_devices(enumerate);
- devices = udev_enumerate_get_list_entry(enumerate);
- udev_list_entry_foreach(device, devices) {
- const char *syspath = udev_list_entry_get_name(device);
- struct udev_device *udev_device = udev_device_new_from_syspath(udev, syspath);
- device_added(udev_device);
- udev_device_unref(udev_device);
- }
- udev_enumerate_unref(enumerate);
-
- fd = udev_monitor_get_fd(udev_monitor);
- maxfd = (fd > maxfd) ? fd : maxfd;
-
- while (1) {
- FD_ZERO(&fds);
- FD_SET(fd, &fds);
- TAILQ_FOREACH(d, &dl, next)
- FD_SET(d->fd, &fds);
-
- rc = select(maxfd + 1, &fds, NULL, NULL, NULL);
- if (rc < 0) {
- perror("select");
- exit(1);
- }
- if (FD_ISSET(fd, &fds))
- udev_event();
- TAILQ_FOREACH(d, &dl, next)
- if (FD_ISSET(d->fd, &fds))
- input_event(d);
- }
-
- return 0;
-err:
- fprintf(stderr, "Failed to set up udev.\n");
- return -1;
-}
diff --git a/util/gnttest.c b/util/gnttest.c
deleted file mode 100644
index b8dea2f..0000000
--- a/util/gnttest.c
+++ /dev/null
@@ -1,58 +0,0 @@
-#include <stdarg.h>
-#include <stdlib.h>
-#include <sys/types.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include <stdbool.h>
-#include <sys/mman.h>
-#include <errno.h>
-#include <stdio.h>
-#include <string.h>
-#include <time.h>
-
-#include <xs.h>
-#include <xenctrl.h>
-#include <xen/event_channel.h>
-#include <xen/io/xenbus.h>
-#include <xen/io/fbif.h>
-#include <xen/io/kbdif.h>
-#include <xen/io/protocols.h>
-
-static void
-bail(const char *msg)
-{
- fprintf(stderr, "%s\n", msg);
- exit(1);
-}
-
-int
-main(int argc, char **argv)
-{
- xc_interface *xc;
- xc_gnttab *gntdev;
- int dom;
- grant_ref_t ref;
- unsigned char *page;
-
- if (argc != 3)
- bail("Usage: gnttest <domid> <grant-ref>");
-
- dom = atoi(argv[1]);
- ref = atoi(argv[2]);
-
- xc = xc_interface_open(0,0,0);
- if (!xc)
- bail("Failed to open xc");
-
- gntdev = xc_gnttab_open(NULL, 0);
- if (gntdev < 0)
- bail("Failed to open gntdev");
-
- page = xc_gnttab_map_grant_ref(gntdev, dom, ref, PROT_READ);
- write(1, page, 4096);
-
- xc_gnttab_munmap(gntdev, page, 1);
- xc_gnttab_close(gntdev);
- xc_interface_close(xc);
- return 0;
-}
diff --git a/util/pipe2.c b/util/pipe2.c
deleted file mode 100644
index 26d145d..0000000
--- a/util/pipe2.c
+++ /dev/null
@@ -1,84 +0,0 @@
-#include <sys/types.h>
-#include <sys/wait.h>
-#include <unistd.h>
-#include <fcntl.h>
-#include <stdio.h>
-#include <stdlib.h>
-
-static void
-bail(const char *msg)
-{
- fprintf(stderr, "%s\n", msg);
- exit(1);
-}
-
-int
-main(int argc, char *const argv[], char *const envp[])
-{
- int p1[2], p2[2];
- char *a1[4], *a2[4];
- char prog[] = "/usr/lib64/xen/bin/xenconsole";
- pid_t pid, c1, c2;
- int status;
-
- if (argc != 3)
- bail("Usage: pipe2 <guest1> <guest2>");
-
- a1[0] = prog;
- //a1[1] = "console";
- a1[1] = argv[1];
- a1[2] = NULL;
-
- a2[0] = prog;
- //a2[1] = "console";
- a2[1] = argv[2];
- a2[2] = NULL;
-
- if (pipe(p1) < 0)
- bail("pipe() call failed!");
- if (pipe(p2) < 0)
- bail("pipe() call failed!");
-
- c1 = fork();
- if (c1 == 0) {
- close(0);
- close(1);
- close(2);
- close(p1[1]);
- close(p2[0]);
-
- dup2(p1[0], 0);
- dup2(p2[1], 1);
- dup2(p2[1], 2);
-
- close(p2[1]);
- close(p1[0]);
-
- execve(prog, a1, envp);
- }
-
- c2 = fork();
- if (c2 == 0) {
- close(0);
- close(1);
- close(2);
- close(p2[1]);
- close(p1[0]);
-
- dup2(p2[0], 0);
- dup2(p1[1], 1);
- dup2(p1[1], 2);
-
- close(p1[1]);
- close(p2[0]);
-
- execve(prog, a2, envp);
- }
-
- pid = waitpid(-1, &status, 0);
- fprintf(stderr, "%d exit %d\n", pid, status);
- pid = waitpid(-1, &status, 0);
- fprintf(stderr, "%d exit %d\n", pid, status);
-
- return 0;
-}
diff --git a/util/xsdump.c b/util/xsdump.c
deleted file mode 100644
index 0ea4266..0000000
--- a/util/xsdump.c
+++ /dev/null
@@ -1,45 +0,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include <stdarg.h>
-#include <string.h>
-#include <unistd.h>
-#include <fcntl.h>
-#include <inttypes.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <sys/mman.h>
-#include <sys/signal.h>
-
-#include <xs.h>
-#include <xenctrl.h>
-#include <xen/grant_table.h>
-
-int main(int argc, char **argv)
-{
- struct xs_handle *xenstore;
- char **vec;
- intptr_t type, ops, ptr;
- unsigned int dom, count;
-
- xenstore = xs_daemon_open();
- if (!xenstore) {
- printf("can't connect to xenstored\n");
- return 1;
- }
-
- xs_watch(xenstore, "@introduceDomain", "");
- xs_watch(xenstore, "@releaseDomain", "");
- xs_watch(xenstore, "/", "");
-
- while (1) {
- vec = xs_read_watch(xenstore, &count);
- if (vec == NULL)
- continue;
-
- printf("%s\n", vec[XS_WATCH_PATH]);
- free(vec);
- }
-
- xs_daemon_close(xenstore);
- return 0;
-}