chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
update TODO
[elogind.git]
/
udev
/
udevadm-monitor.c
diff --git
a/udev/udevadm-monitor.c
b/udev/udevadm-monitor.c
index 0852fe301b5686ef69c6f145da20e89d2ec9c3cb..64913dbd55cbfa9acd9067b48b25d04d7b06d957 100644
(file)
--- a/
udev/udevadm-monitor.c
+++ b/
udev/udevadm-monitor.c
@@
-24,6
+24,7
@@
#include <errno.h>
#include <signal.h>
#include <getopt.h>
#include <errno.h>
#include <signal.h>
#include <getopt.h>
+#include <time.h>
#include <sys/time.h>
#include <sys/socket.h>
#include <sys/un.h>
#include <sys/time.h>
#include <sys/socket.h>
#include <sys/un.h>
@@
-43,13
+44,12
@@
static void sig_handler(int signum)
static void print_device(struct udev_device *device, const char *source, int prop)
{
static void print_device(struct udev_device *device, const char *source, int prop)
{
- struct timeval tv;
- struct timezone tz;
+ struct timespec ts;
-
gettimeofday(&tv, &tz
);
+
clock_gettime(CLOCK_MONOTONIC, &ts
);
printf("%-6s[%llu.%06u] %-8s %s (%s)\n",
source,
printf("%-6s[%llu.%06u] %-8s %s (%s)\n",
source,
- (unsigned long long) t
v.tv_sec, (unsigned int) tv.tv_usec
,
+ (unsigned long long) t
s.tv_sec, (unsigned int) ts.tv_nsec/1000
,
udev_device_get_action(device),
udev_device_get_devpath(device),
udev_device_get_subsystem(device));
udev_device_get_action(device),
udev_device_get_devpath(device),
udev_device_get_subsystem(device));
@@
-64,7
+64,7
@@
static void print_device(struct udev_device *device, const char *source, int pro
}
}
}
}
-
int udev
adm_monitor(struct udev *udev, int argc, char *argv[])
+
static int
adm_monitor(struct udev *udev, int argc, char *argv[])
{
struct sigaction act;
sigset_t mask;
{
struct sigaction act;
sigset_t mask;
@@
-72,8
+72,8
@@
int udevadm_monitor(struct udev *udev, int argc, char *argv[])
bool prop = false;
bool print_kernel = false;
bool print_udev = false;
bool prop = false;
bool print_kernel = false;
bool print_udev = false;
- struct udev_list
_node
subsystem_match_list;
- struct udev_list
_node
tag_match_list;
+ struct udev_list subsystem_match_list;
+ struct udev_list tag_match_list;
struct udev_monitor *udev_monitor = NULL;
struct udev_monitor *kernel_monitor = NULL;
int fd_ep = -1;
struct udev_monitor *udev_monitor = NULL;
struct udev_monitor *kernel_monitor = NULL;
int fd_ep = -1;
@@
-92,8
+92,8
@@
int udevadm_monitor(struct udev *udev, int argc, char *argv[])
{}
};
{}
};
- udev_list_init(
&subsystem_match_list
);
- udev_list_init(
&tag_match_list
);
+ udev_list_init(
udev, &subsystem_match_list, true
);
+ udev_list_init(
udev, &tag_match_list, true
);
for (;;) {
option = getopt_long(argc, argv, "pekus:t:h", options, NULL);
for (;;) {
option = getopt_long(argc, argv, "pekus:t:h", options, NULL);
@@
-122,11
+122,11
@@
int udevadm_monitor(struct udev *udev, int argc, char *argv[])
devtype[0] = '\0';
devtype++;
}
devtype[0] = '\0';
devtype++;
}
- udev_list_entry_add(
udev, &subsystem_match_list, subsys, devtype, 0
);
+ udev_list_entry_add(
&subsystem_match_list, subsys, devtype
);
break;
}
case 't':
break;
}
case 't':
- udev_list_entry_add(
udev, &tag_match_list, optarg, NULL, 0
);
+ udev_list_entry_add(
&tag_match_list, optarg, NULL
);
break;
case 'h':
printf("Usage: udevadm monitor [--property] [--kernel] [--udev] [--help]\n"
break;
case 'h':
printf("Usage: udevadm monitor [--property] [--kernel] [--udev] [--help]\n"
@@
-285,7
+285,13
@@
out:
close(fd_ep);
udev_monitor_unref(udev_monitor);
udev_monitor_unref(kernel_monitor);
close(fd_ep);
udev_monitor_unref(udev_monitor);
udev_monitor_unref(kernel_monitor);
- udev_list_cleanup
_entries(udev,
&subsystem_match_list);
- udev_list_cleanup
_entries(udev,
&tag_match_list);
+ udev_list_cleanup
(
&subsystem_match_list);
+ udev_list_cleanup
(
&tag_match_list);
return rc;
}
return rc;
}
+
+const struct udevadm_cmd udevadm_monitor = {
+ .name = "monitor",
+ .cmd = adm_monitor,
+ .help = "listen to kernel and udev events",
+};