1
1
mirror of https://github.com/systemd/systemd-stable.git synced 2024-10-31 07:51:08 +03:00

test-libudev: update monitor source

This commit is contained in:
Kay Sievers 2009-04-18 13:23:10 +02:00
parent 55d8f5e208
commit f1986e09fc

View File

@ -217,13 +217,13 @@ static int test_enumerate_print_list(struct udev_enumerate *enumerate)
return count; return count;
} }
static int test_monitor(struct udev *udev, const char *socket_path) static int test_monitor(struct udev *udev)
{ {
struct udev_monitor *udev_monitor; struct udev_monitor *udev_monitor;
fd_set readfds; fd_set readfds;
int fd; int fd;
udev_monitor = udev_monitor_new_from_socket(udev, socket_path); udev_monitor = udev_monitor_new_from_netlink(udev, "udev");
if (udev_monitor == NULL) { if (udev_monitor == NULL) {
printf("no socket\n"); printf("no socket\n");
return -1; return -1;
@ -243,7 +243,7 @@ static int test_monitor(struct udev *udev, const char *socket_path)
FD_SET(STDIN_FILENO, &readfds); FD_SET(STDIN_FILENO, &readfds);
FD_SET(fd, &readfds); FD_SET(fd, &readfds);
printf("waiting for events on %s, press ENTER to exit\n", socket_path); printf("waiting for events from udev, press ENTER to exit\n");
fdcount = select(fd+1, &readfds, NULL, NULL, NULL); fdcount = select(fd+1, &readfds, NULL, NULL, NULL);
printf("select fd count: %i\n", fdcount); printf("select fd count: %i\n", fdcount);
@ -377,7 +377,6 @@ int main(int argc, char *argv[])
static const struct option options[] = { static const struct option options[] = {
{ "syspath", required_argument, NULL, 'p' }, { "syspath", required_argument, NULL, 'p' },
{ "subsystem", required_argument, NULL, 's' }, { "subsystem", required_argument, NULL, 's' },
{ "socket", required_argument, NULL, 'S' },
{ "debug", no_argument, NULL, 'd' }, { "debug", no_argument, NULL, 'd' },
{ "help", no_argument, NULL, 'h' }, { "help", no_argument, NULL, 'h' },
{ "version", no_argument, NULL, 'V' }, { "version", no_argument, NULL, 'V' },
@ -385,7 +384,6 @@ int main(int argc, char *argv[])
}; };
const char *syspath = "/devices/virtual/mem/null"; const char *syspath = "/devices/virtual/mem/null";
const char *subsystem = NULL; const char *subsystem = NULL;
const char *socket = "@/org/kernel/udev/monitor";
char path[1024]; char path[1024];
const char *str; const char *str;
@ -412,15 +410,12 @@ int main(int argc, char *argv[])
case 's': case 's':
subsystem = optarg; subsystem = optarg;
break; break;
case 'S':
socket = optarg;
break;
case 'd': case 'd':
if (udev_get_log_priority(udev) < LOG_INFO) if (udev_get_log_priority(udev) < LOG_INFO)
udev_set_log_priority(udev, LOG_INFO); udev_set_log_priority(udev, LOG_INFO);
break; break;
case 'h': case 'h':
printf("--debug --syspath= --subsystem= --socket= --help\n"); printf("--debug --syspath= --subsystem= --help\n");
goto out; goto out;
case 'V': case 'V':
printf("%s\n", VERSION); printf("%s\n", VERSION);
@ -450,7 +445,7 @@ int main(int argc, char *argv[])
test_queue(udev); test_queue(udev);
test_monitor(udev, socket); test_monitor(udev);
out: out:
udev_unref(udev); udev_unref(udev);
return 0; return 0;