test-libudev.c revision 601185b43da638b1c74153deae01dbd518680889
/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
/***
This file is part of systemd.
Copyright 2008-2012 Kay Sievers <kay@vrfy.org>
under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.
systemd is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
#include <stdio.h>
#include <stdarg.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#include <string.h>
#include <getopt.h>
#include <syslog.h>
#include <fcntl.h>
#include "libudev.h"
#include "udev-util.h"
#include "util.h"
#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
_printf_(6,0)
}
const char *str;
int count;
struct udev_list_entry *list_entry;
count = 0;
count++;
}
if (count > 0)
count = 0;
printf("property: '%s=%s'\n",
count++;
}
if (count > 0)
printf("\n");
}
printf("no device found\n");
return -1;
}
return 0;
}
struct udev_device *device_parent;
return -1;
printf("looking at parents\n");
do {
} while (device_parent != NULL);
printf("looking at parents again\n");
do {
} while (device_parent != NULL);
return 0;
}
struct udev_device *device;
return -1;
return 0;
}
struct udev_device *device;
printf("looking up device: 'block':'sda'\n");
return -1;
printf("looking up device: 'subsystem':'pci'\n");
return -1;
printf("looking up device: 'drivers':'scsi:sd'\n");
return -1;
printf("looking up device: 'module':'printk'\n");
return -1;
return 0;
}
struct udev_list_entry *list_entry;
int count = 0;
struct udev_device *device;
printf("device: '%s' (%s)\n",
count++;
}
}
return count;
}
int fd_ep;
int fd_udev = -1;
if (fd_ep < 0) {
printf("error creating epoll fd: %m\n");
goto out;
}
if (udev_monitor == NULL) {
printf("no socket\n");
goto out;
}
printf("filter failed\n");
goto out;
}
if (udev_monitor_enable_receiving(udev_monitor) < 0) {
printf("bind failed\n");
goto out;
}
printf("fail to add fd to epoll: %m\n");
goto out;
}
printf("fail to add fd to epoll: %m\n");
goto out;
}
for (;;) {
int fdcount;
struct udev_device *device;
int i;
printf("waiting for events from udev, press ENTER to exit\n");
for (i = 0; i < fdcount; i++) {
printf("no device from socket\n");
continue;
}
printf("exiting loop\n");
goto out;
}
}
}
out:
if (fd_ep >= 0)
return 0;
}
struct udev_queue *udev_queue;
if (udev_queue == NULL)
return -1;
printf("queue is empty\n");
return 0;
}
struct udev_enumerate *udev_enumerate;
if (udev_enumerate == NULL)
return -1;
printf("enumerate 'net' + duplicated scan + null + zero\n");
if (udev_enumerate == NULL)
return -1;
printf("enumerate 'block'\n");
if (udev_enumerate == NULL)
return -1;
printf("enumerate 'not block'\n");
if (udev_enumerate == NULL)
return -1;
printf("enumerate 'pci, mem, vc'\n");
if (udev_enumerate == NULL)
return -1;
printf("enumerate 'subsystem'\n");
if (udev_enumerate == NULL)
return -1;
printf("enumerate 'property IF_FS_*=filesystem'\n");
if (udev_enumerate == NULL)
return -1;
return 0;
}
struct udev_list_entry *entry;
printf("\n");
}
{}
};
char path[1024];
int c;
printf("no context\n");
return 1;
}
switch (c) {
case 'p':
break;
case 's':
break;
case 'd':
break;
case 'h':
printf("--debug --syspath= --subsystem= --help\n");
goto out;
case 'V':
goto out;
case '?':
goto out;
default:
assert_not_reached("Unhandled option code.");
}
/* add sys path if needed */
}
out:
return 0;
}