if (r < 0)
return log_device_debug_errno(device, r, "sd-device: Failed to add tag '%s': %m", word);
}
+ } else if (streq(key, "UDEV_DATABASE_VERSION")) {
+ r = safe_atou(value, &device->database_version);
+ if (r < 0)
+ return log_device_debug_errno(device, r, "sd-device: Failed to parse udev database version '%s': %m", value);
} else {
r = device_add_property_internal(device, key, value);
if (r < 0)
if (!device->properties_buf_outdated)
return 0;
+ /* append udev database version */
+ buf_nulstr = newdup(char, "UDEV_DATABASE_VERSION=" STRINGIFY(LATEST_UDEV_DATABASE_VERSION) "\0",
+ STRLEN("UDEV_DATABASE_VERSION=" STRINGIFY(LATEST_UDEV_DATABASE_VERSION)) + 2);
+ if (!buf_nulstr)
+ return -ENOMEM;
+
+ nulstr_len += STRLEN("UDEV_DATABASE_VERSION=" STRINGIFY(LATEST_UDEV_DATABASE_VERSION)) + 1;
+ num++;
+
FOREACH_DEVICE_PROPERTY(device, prop, val) {
size_t len = 0;
assert_se(set_contains(device->devlinks, devlink));
}
+ /* For issue #23799 */
+ assert_se(device_add_tag(device, "tag1", false) >= 0);
+ assert_se(device_add_tag(device, "tag2", false) >= 0);
+ assert_se(device_add_tag(device, "current-tag1", true) >= 0);
+ assert_se(device_add_tag(device, "current-tag2", true) >= 0);
+
/* These properties are necessary for device_new_from_nulstr(). See device_verify(). */
assert_se(device_add_property_internal(device, "SEQNUM", "1") >= 0);
assert_se(device_add_property_internal(device, "ACTION", "change") >= 0);
assert_se(nulstr_copy = newdup(char, nulstr, len));
assert_se(device_new_from_nulstr(&from_nulstr, nulstr_copy, len) >= 0);
+ assert_se(sd_device_has_tag(from_nulstr, "tag1") == 1);
+ assert_se(sd_device_has_tag(from_nulstr, "tag2") == 1);
+ assert_se(sd_device_has_tag(from_nulstr, "current-tag1") == 1);
+ assert_se(sd_device_has_tag(from_nulstr, "current-tag2") == 1);
+ assert_se(sd_device_has_current_tag(from_nulstr, "tag1") == 0);
+ assert_se(sd_device_has_current_tag(from_nulstr, "tag2") == 0);
+ assert_se(sd_device_has_current_tag(from_nulstr, "current-tag1") == 1);
+ assert_se(sd_device_has_current_tag(from_nulstr, "current-tag2") == 1);
+
NULSTR_FOREACH(devlink, devlinks) {
log_device_info(from_nulstr, "checking devlink: %s", devlink);
assert_se(set_contains(from_nulstr->devlinks, devlink));