From: Yu Watanabe Date: Sun, 22 Feb 2026 19:32:05 +0000 (+0900) Subject: sd-device: drop support of udev database version 0 X-Git-Tag: v261-rc1~144^2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1fdcf3ee40946ddb0ab0f60f56390faca9d11eda;p=thirdparty%2Fsystemd.git sd-device: drop support of udev database version 0 The udev database versioning has been introduced in v247, which is released on 2020-11-26. Let's drop the support of old udev database. --- diff --git a/src/libsystemd/sd-device/device-internal.h b/src/libsystemd/sd-device/device-internal.h index 16a57923502..f207a1618f7 100644 --- a/src/libsystemd/sd-device/device-internal.h +++ b/src/libsystemd/sd-device/device-internal.h @@ -6,6 +6,7 @@ #include "sd-forward.h" #include "iterator.h" +#define OLDEST_UDEV_DATABASE_VERSION 1 #define LATEST_UDEV_DATABASE_VERSION 1 struct sd_device { @@ -51,7 +52,7 @@ 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; diff --git a/src/libsystemd/sd-device/device-private.c b/src/libsystemd/sd-device/device-private.c index 054c3545d00..48dce776894 100644 --- a/src/libsystemd/sd-device/device-private.c +++ b/src/libsystemd/sd-device/device-private.c @@ -912,7 +912,7 @@ int device_update_db(sd_device *device) { 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); } diff --git a/src/libsystemd/sd-device/sd-device.c b/src/libsystemd/sd-device/sd-device.c index ef67c649d1e..ae44d0c86fd 100644 --- a/src/libsystemd/sd-device/sd-device.c +++ b/src/libsystemd/sd-device/sd-device.c @@ -47,6 +47,7 @@ int device_new_aux(sd_device **ret) { .devuid = UID_INVALID, .devgid = GID_INVALID, .action = _SD_DEVICE_ACTION_INVALID, + .database_version = OLDEST_UDEV_DATABASE_VERSION, }; *ret = device; @@ -1966,26 +1967,11 @@ _public_ const char* sd_device_get_tag_next(sd_device *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; @@ -2000,9 +1986,6 @@ _public_ const char* sd_device_get_current_tag_next(sd_device *device) { 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) @@ -2273,9 +2256,6 @@ _public_ int sd_device_has_current_tag(sd_device *device, const char *tag) { 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);