]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
sd-device: drop support of udev database version 0
authorYu Watanabe <watanabe.yu+github@gmail.com>
Sun, 22 Feb 2026 19:32:05 +0000 (04:32 +0900)
committerZbigniew Jędrzejewski-Szmek <zbyszek@amutable.com>
Fri, 15 May 2026 11:47:45 +0000 (13:47 +0200)
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.

src/libsystemd/sd-device/device-internal.h
src/libsystemd/sd-device/device-private.c
src/libsystemd/sd-device/sd-device.c

index 16a57923502837bc175b0a9d68d83ff8c2972bd5..f207a1618f7dc5e337152ac7faa9b076e1527052 100644 (file)
@@ -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;
index 054c3545d006dc28c327c576b8a2d476a09e00f5..48dce7768949e23918ab1e8e9211c27de4b47ce8 100644 (file)
@@ -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);
         }
 
index ef67c649d1ebdf95d63d2e85c69d42bd8df1de15..ae44d0c86fd96dfa6f24409a5fba398ada3e1d5e 100644 (file)
@@ -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);