chiark / gitweb /
udevadm: monitor - use uptime to match the kernel's timestamp
authorKay Sievers <kay.sievers@vrfy.org>
Sun, 10 Jul 2011 23:03:14 +0000 (01:03 +0200)
committerKay Sievers <kay.sievers@vrfy.org>
Sun, 10 Jul 2011 23:03:14 +0000 (01:03 +0200)
TODO
udev/udevadm-monitor.c

diff --git a/TODO b/TODO
index 13a27799fad50064d4e3e6f85b8714b21ad1372a..01fb0e1fc704cc4eb2d18a44a984077d40894d36 100644 (file)
--- a/TODO
+++ b/TODO
@@ -2,8 +2,6 @@
 
  - test (now fixed) /dev/tape/ links
 
- - monitor: use clock MONOTONIC
-
  - remove RUN+="socket:"
 
  - libudev: return proper errno or set errno
index 0852fe301b5686ef69c6f145da20e89d2ec9c3cb..9b8bf4eccf50c31b84ef61a3903c014a083aa9e3 100644 (file)
@@ -24,6 +24,7 @@
 #include <errno.h>
 #include <signal.h>
 #include <getopt.h>
+#include <time.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)
 {
-       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,
-              (unsigned long long) tv.tv_sec, (unsigned int) tv.tv_usec,
+              (unsigned long long) ts.tv_sec, (unsigned int) ts.tv_nsec/1000,
               udev_device_get_action(device),
               udev_device_get_devpath(device),
               udev_device_get_subsystem(device));