]> err.no Git - systemd/commitdiff
export USEC_INITIALIZED= and take timestamp on message receive time
authorKay Sievers <kay.sievers@vrfy.org>
Wed, 17 Aug 2011 19:05:18 +0000 (21:05 +0200)
committerKay Sievers <kay.sievers@vrfy.org>
Wed, 17 Aug 2011 19:05:18 +0000 (21:05 +0200)
libudev/libudev-device.c
udev/udev-event.c
udev/udevd.c

index 273e5cb59c97e8eb4482e2e43f57162aced55640..064ffad9bf3c2efadfa19c3bbdbce45a504dec79 100644 (file)
@@ -437,6 +437,8 @@ void udev_device_add_property_from_string_parse(struct udev_device *udev_device,
                                udev_device_add_tag(udev_device, tag);
                        }
                }
+       } else if (strncmp(property, "USEC_INITIALIZED=", 19) == 0) {
+               udev_device_set_usec_initialized(udev_device, strtoull(&property[19], NULL, 10));
        } else if (strncmp(property, "DRIVER=", 7) == 0) {
                udev_device_set_driver(udev_device, &property[7]);
        } else if (strncmp(property, "ACTION=", 7) == 0) {
@@ -1322,7 +1324,11 @@ unsigned long long udev_device_get_usec_initialized(struct udev_device *udev_dev
 
 void udev_device_set_usec_initialized(struct udev_device *udev_device, unsigned long long usec_initialized)
 {
+       char num[32];
+
        udev_device->usec_initialized = usec_initialized;
+       snprintf(num, sizeof(num), "%llu", usec_initialized);
+       udev_device_add_property(udev_device, "USEC_INITIALIZED", num);
 }
 
 /**
index 391fce81c3214806539e5692e316b4c19f142190..3c1a3e7aa77a184734a2a7d7901612aab1590afd 100644 (file)
@@ -1040,7 +1040,7 @@ int udev_event_execute_rules(struct udev_event *event, struct udev_rules *rules,
                /* preserve old, or get new initialization timestamp */
                if (event->dev_db != NULL && udev_device_get_usec_initialized(event->dev_db) > 0)
                        udev_device_set_usec_initialized(event->dev, udev_device_get_usec_initialized(event->dev_db));
-               else
+               else if (udev_device_get_usec_initialized(event->dev) == 0)
                        udev_device_set_usec_initialized(event->dev, now_usec());
 
                /* (re)write database file */
index f1a31e7afbb4c767e250cf6f0dd120bf33a28c58..325ad034c2b2bc05554824acde20beadd39f7fca 100644 (file)
@@ -1655,6 +1655,7 @@ int main(int argc, char *argv[])
 
                        dev = udev_monitor_receive_device(monitor);
                        if (dev != NULL)
+                               udev_device_set_usec_initialized(dev, now_usec());
                                if (event_queue_insert(dev) < 0)
                                        udev_device_unref(dev);
                }