mirror of
https://github.com/systemd/systemd-stable.git
synced 2024-12-24 21:34:08 +03:00
sd-device: add API to query from when a udev database entry is
We already store a CLOCK_MONOTONIC timestamp for each device appearance, let' make this queriable. This is useful to determine whether a udev device database entry is from a current appearance of the device or a previous one, by comparing it with appropriately taken timestamps.
This commit is contained in:
parent
75dc190d39
commit
8626b43be4
@ -756,4 +756,5 @@ LIBSYSTEMD_249 {
|
||||
global:
|
||||
sd_device_monitor_filter_add_match_sysattr;
|
||||
sd_device_monitor_filter_add_match_parent;
|
||||
sd_device_get_usec_initialized;
|
||||
} LIBSYSTEMD_248;
|
||||
|
@ -1428,6 +1428,27 @@ _public_ int sd_device_get_is_initialized(sd_device *device) {
|
||||
return device->is_initialized;
|
||||
}
|
||||
|
||||
_public_ int sd_device_get_usec_initialized(sd_device *device, uint64_t *ret) {
|
||||
int r;
|
||||
|
||||
assert_return(device, -EINVAL);
|
||||
|
||||
r = device_read_db(device);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
if (!device->is_initialized)
|
||||
return -EBUSY;
|
||||
|
||||
if (device->usec_initialized == 0)
|
||||
return -ENODATA;
|
||||
|
||||
if (ret)
|
||||
*ret = device->usec_initialized;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
_public_ int sd_device_get_usec_since_initialized(sd_device *device, uint64_t *usec) {
|
||||
usec_t now_ts;
|
||||
int r;
|
||||
|
@ -79,6 +79,7 @@ int sd_device_get_action(sd_device *device, sd_device_action_t *ret);
|
||||
int sd_device_get_seqnum(sd_device *device, uint64_t *ret);
|
||||
|
||||
int sd_device_get_is_initialized(sd_device *device);
|
||||
int sd_device_get_usec_initialized(sd_device *device, uint64_t *usec);
|
||||
int sd_device_get_usec_since_initialized(sd_device *device, uint64_t *usec);
|
||||
|
||||
const char *sd_device_get_tag_first(sd_device *device);
|
||||
|
Loading…
Reference in New Issue
Block a user