udevadm-monitor.c revision d5a89d7dc17a5ba5cf4fc71f82963c5c94a31c3d
/*
* 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"
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");
}
}
{
int option;
bool prop = false;
bool print_kernel = false;
bool print_udev = false;
struct udev_list subsystem_match_list;
struct udev_list tag_match_list;
int fd_ep = -1;
int rc = 0;
{}
};
for (;;) {
if (option == -1)
break;
switch (option) {
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':
printf("Usage: udevadm monitor [--property] [--kernel] [--udev] [--help]\n"
" --property print the event properties\n"
" --kernel print kernel uevents\n"
" --udev print udev events\n"
" --subsystem-match=<subsystem[/devtype]> filter events by subsystem\n"
" --tag-match=<tag> filter events by tag\n"
" --help\n\n");
goto out;
default:
rc = 1;
goto out;
}
}
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\n");
goto out;
}
printf("monitor will print the received events for:\n");
if (print_udev) {
struct udev_list_entry *entry;
if (udev_monitor == NULL) {
rc = 1;
goto out;
}
}
}
if (udev_monitor_enable_receiving(udev_monitor) < 0) {
rc = 2;
goto out;
}
log_error("fail to add fd to epoll: %m\n");
goto out;
}
printf("UDEV - the event which udev sends out after rule processing\n");
}
if (print_kernel) {
struct udev_list_entry *entry;
if (kernel_monitor == NULL) {
rc = 3;
goto out;
}
}
if (udev_monitor_enable_receiving(kernel_monitor) < 0) {
rc = 4;
goto out;
}
log_error("fail to add fd to epoll: %m\n");
goto out;
}
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;
}
}
}
out:
if (fd_ep >= 0)
return rc;
}
const struct udevadm_cmd udevadm_monitor = {
.name = "monitor",
.cmd = adm_monitor,
.help = "listen to kernel and udev events",
};