#include "sd-forward.h"
#include "iterator.h"
+#define OLDEST_UDEV_DATABASE_VERSION 1
#define LATEST_UDEV_DATABASE_VERSION 1
struct sd_device {
/* The database version indicates the supported features by the udev database.
* This is saved and parsed in V field.
*
- * 0: None of the following features are supported (systemd version <= 246).
+ * 0: None of the following features are supported (systemd version <= 246), unsupported since v261.
* 1: The current tags (Q) and the database version (V) features are implemented (>= 247).
*/
unsigned database_version;
fprintf(f, "Q:%s\n", ct); /* Current tag */
/* Always write the latest database version here, instead of the value stored in
- * device->database_version, as which may be 0. */
+ * device->database_version. */
fputs("V:" STRINGIFY(LATEST_UDEV_DATABASE_VERSION) "\n", f);
}
.devuid = UID_INVALID,
.devgid = GID_INVALID,
.action = _SD_DEVICE_ACTION_INVALID,
+ .database_version = OLDEST_UDEV_DATABASE_VERSION,
};
*ret = device;
return v;
}
-static bool device_database_supports_current_tags(sd_device *device) {
- assert(device);
-
- (void) device_read_db(device);
-
- /* The current tags (saved in Q field) feature is implemented in database version 1.
- * If the database version is 0, then the tags (NOT current tags, saved in G field) are not
- * sticky. Thus, we can safely bypass the operations for the current tags (Q) to tags (G). */
-
- return device->database_version >= 1;
-}
-
_public_ const char* sd_device_get_current_tag_first(sd_device *device) {
void *v;
assert_return(device, NULL);
- if (!device_database_supports_current_tags(device))
- return sd_device_get_tag_first(device);
-
(void) device_read_db(device);
device->current_tags_iterator_generation = device->tags_generation;
assert_return(device, NULL);
- if (!device_database_supports_current_tags(device))
- return sd_device_get_tag_next(device);
-
(void) device_read_db(device);
if (device->current_tags_iterator_generation != device->tags_generation)
assert_return(device, -EINVAL);
assert_return(tag, -EINVAL);
- if (!device_database_supports_current_tags(device))
- return sd_device_has_tag(device, tag);
-
(void) device_read_db(device);
return set_contains(device->current_tags, tag);