udevadm-monitor.c revision 6482f6269c87d2249e52e889a63adbdd50f2d691
/*
* 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 <stdio.h>
#include <stddef.h>
#include <string.h>
#include <errno.h>
#include <signal.h>
#include <getopt.h>
#include <time.h>
#include "udev.h"
#include "udev-util.h"
#include "formats-util.h"
static bool udev_exit;
static void sig_handler(int signum) {
udev_exit = true;
}
if (prop) {
struct udev_list_entry *list_entry;
printf("%s=%s\n",
printf("\n");
}
}
static void help(void) {
printf("%s monitor [--property] [--kernel] [--udev] [--help]\n\n"
"Listen to kernel and udev events.\n\n"
" -h --help Show this help\n"
" --version Show package version\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"
}
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) {
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;
}
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;
}
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",
};