udevadm-monitor.c revision 9f6445e34a57c270f013c9416c123e56261553dd
/*
* Copyright (C) 2004-2010 Kay Sievers <kay@vrfy.org>
*
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <stddef.h>
#include <string.h>
#include <fcntl.h>
#include <errno.h>
#include <signal.h>
#include <getopt.h>
#include <time.h>
#include "udev.h"
#include "udev-util.h"
static bool udev_exit;
static void sig_handler(int signum)
{
udev_exit = true;
}
{
printf("%-6s[%llu.%06u] %-8s %s (%s)\n",
if (prop) {
struct udev_list_entry *list_entry;
printf("%s=%s\n",
printf("\n");
}
}
static void help(void) {
printf("Usage: udevadm monitor [--property] [--kernel] [--udev] [--help]\n"
" -p,--property print the event properties\n"
" -k,--kernel print kernel uevents\n"
" -u,--udev print udev events\n"
" -s,--subsystem-match=SUBSYSTEM[/DEVTYPE] filter events by subsystem\n"
" -t,--tag-match=TAG filter events by tag\n"
" -h,--help\n\n");
}
{
bool prop = false;
bool print_kernel = false;
bool print_udev = false;
int c;
{}
};
switch (c) {
case 'p':
case 'e':
prop = true;
break;
case 'k':
print_kernel = true;
break;
case 'u':
print_udev = true;
break;
case 's':
{
char subsys[UTIL_NAME_SIZE];
char *devtype;
devtype[0] = '\0';
devtype++;
}
break;
}
case 't':
break;
case 'h':
help();
return 0;
default:
return 1;
}
if (!print_kernel && !print_udev) {
print_kernel = true;
print_udev = true;
}
/* set signal handlers */
sigemptyset(&mask);
if (fd_ep < 0) {
log_error("error creating epoll fd: %m");
return 1;
}
printf("monitor will print the received events for:\n");
if (print_udev) {
struct udev_list_entry *entry;
if (udev_monitor == NULL) {
return 1;
}
}
}
if (udev_monitor_enable_receiving(udev_monitor) < 0) {
return 2;
}
log_error("fail to add fd to epoll: %m");
return 2;
}
printf("UDEV - the event which udev sends out after rule processing\n");
}
if (print_kernel) {
struct udev_list_entry *entry;
if (kernel_monitor == NULL) {
return 3;
}
}
if (udev_monitor_enable_receiving(kernel_monitor) < 0) {
return 4;
}
log_error("fail to add fd to epoll: %m");
return 5;
}
printf("KERNEL - the kernel uevent\n");
}
printf("\n");
while (!udev_exit) {
int fdcount;
int i;
if (fdcount < 0) {
continue;
}
for (i = 0; i < fdcount; i++) {
struct udev_device *device;
continue;
struct udev_device *device;
continue;
}
}
}
return 0;
}
const struct udevadm_cmd udevadm_monitor = {
.name = "monitor",
.cmd = adm_monitor,
.help = "listen to kernel and udev events",
};