summaryrefslogtreecommitdiff
path: root/src/systemd/sd-device.h
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2018-12-13 17:55:14 +0100
committerLennart Poettering <lennart@poettering.net>2020-09-01 17:40:12 +0200
commite77b146f825ef1bb63c297cc713962b94422d2c6 (patch)
tree1bec641d532da62e231831d93b2ef7966720cea5 /src/systemd/sd-device.h
parent73484ecff90f2cc235d827c0e955999bffe64dd0 (diff)
downloadsystemd-e77b146f825ef1bb63c297cc713962b94422d2c6.tar.gz
udev: make tags "sticky"
This tries to address the "bind"/"unbind" uevent kernel API breakage, by changing the semantics of device tags. Previously, tags would be applied on uevents (and the database entries they result in) only depending on the immediate context. This means that if one uevent causes the tag to be set and the next to be unset, this would immediately effect what apps would see and the database entries would contain each time. This is problematic however, as tags are a filtering concept, and if tags vanish then clients won't hence notice when a device stops being relevant to them since not only the tags disappear but immediately also the uevents for it are filtered including the one necessary for the app to notice that the device lost its tag and hence relevance. With this change tags become "sticky". If a tag is applied is once applied to a device it will stay in place forever, until the device is removed. Tags can never be removed again. This means that an app watching a specific set of devices by filtering for a tag is guaranteed to not only see the events where the tag is set but also all follow-up events where the tags might be removed again. This change of behaviour is unfortunate, but is required due to the kernel introducing new "bind" and "unbind" uevents that generally have the effect that tags and properties disappear and apps hence don't notice when a device looses relevance to it. "bind"/"unbind" events were introduced in kernel 4.12, and are now used in more and more subsystems. The introduction broke userspace widely, and this commit is an attempt to provide a way for apps to deal with it. While tags are now "sticky" a new automatic device property CURRENT_TAGS is introduced (matching the existing TAGS property) that always reflects the precise set of tags applied on the most recent events. Thus, when subscribing to devices through tags, all devices that ever had the tag put on them will be be seen, and by CURRENT_TAGS it may be checked whether the device right at the moment matches the tag requirements. See: #7587 #7018 #8221
Diffstat (limited to 'src/systemd/sd-device.h')
-rw-r--r--src/systemd/sd-device.h3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/systemd/sd-device.h b/src/systemd/sd-device.h
index 3c5c88c56b..d720ce50da 100644
--- a/src/systemd/sd-device.h
+++ b/src/systemd/sd-device.h
@@ -64,6 +64,8 @@ int sd_device_get_usec_since_initialized(sd_device *device, uint64_t *usec);
const char *sd_device_get_tag_first(sd_device *device);
const char *sd_device_get_tag_next(sd_device *device);
+const char *sd_device_get_current_tag_first(sd_device *device);
+const char *sd_device_get_current_tag_next(sd_device *device);
const char *sd_device_get_devlink_first(sd_device *device);
const char *sd_device_get_devlink_next(sd_device *device);
const char *sd_device_get_property_first(sd_device *device, const char **value);
@@ -72,6 +74,7 @@ const char *sd_device_get_sysattr_first(sd_device *device);
const char *sd_device_get_sysattr_next(sd_device *device);
int sd_device_has_tag(sd_device *device, const char *tag);
+int sd_device_has_current_tag(sd_device *device, const char *tag);
int sd_device_get_property_value(sd_device *device, const char *key, const char **value);
int sd_device_get_sysattr_value(sd_device *device, const char *sysattr, const char **_value);