]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
sd-device: move copy_all_tags() from udev
authorYu Watanabe <watanabe.yu+github@gmail.com>
Sun, 22 Feb 2026 20:26:46 +0000 (05:26 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Sun, 22 Feb 2026 20:46:42 +0000 (05:46 +0900)
No functional change, preparation for the next commit.

src/libsystemd/sd-device/device-private.c
src/libsystemd/sd-device/device-private.h
src/udev/udev-event.c

index 3cd3e96d1c812c6fe4b24ee2a8a34d5f0f1bc339..828697e6176527c8c05c78b54d8fb82921de591a 100644 (file)
@@ -693,6 +693,23 @@ int device_clone_with_db(sd_device *device, sd_device **ret) {
         return 0;
 }
 
+int device_copy_all_tags(sd_device *dest, sd_device *src) {
+        int r;
+
+        assert(dest);
+
+        if (!src)
+                return 0;
+
+        FOREACH_DEVICE_TAG(src, tag) {
+                r = device_add_tag(dest, tag, /* both= */ false);
+                if (r < 0)
+                        return r;
+        }
+
+        return 0;
+}
+
 void device_cleanup_tags(sd_device *device) {
         assert(device);
 
index 8f88b38c46cd04021646b0a99db1e21ca45dba1a..376a4a479cd868604b4c08c19cdd5b494abe4474 100644 (file)
@@ -45,6 +45,7 @@ int device_add_property(sd_device *device, const char *key, const char *value);
 int device_add_propertyf(sd_device *device, const char *key, const char *format, ...) _printf_(3, 4);
 int device_add_tag(sd_device *device, const char *tag, bool both);
 void device_remove_tag(sd_device *device, const char *tag);
+int device_copy_all_tags(sd_device *dest, sd_device *src);
 void device_cleanup_tags(sd_device *device);
 void device_cleanup_devlinks(sd_device *device);
 
index ad7b9fc7761da76a74173212d4c34cf9d30d9e2e..e09bdd0cfa9d9eae11b6b4d4625f746e411b0273 100644 (file)
@@ -329,23 +329,6 @@ static int event_execute_rules_on_remove(UdevEvent *event, UdevRules *rules) {
         return r;
 }
 
-static int copy_all_tags(sd_device *d, sd_device *s) {
-        int r;
-
-        assert(d);
-
-        if (!s)
-                return 0;
-
-        FOREACH_DEVICE_TAG(s, tag) {
-                r = device_add_tag(d, tag, false);
-                if (r < 0)
-                        return r;
-        }
-
-        return 0;
-}
-
 static int update_clone(UdevEvent *event) {
         sd_device *dev = ASSERT_PTR(ASSERT_PTR(event)->dev_db_clone);
         int r;
@@ -398,7 +381,7 @@ int udev_event_execute_rules(UdevEvent *event, UdevRules *rules) {
         if (r < 0)
                 return log_device_debug_errno(dev, r, "Failed to clone sd_device object: %m");
 
-        r = copy_all_tags(dev, event->dev_db_clone);
+        r = device_copy_all_tags(dev, event->dev_db_clone);
         if (r < 0)
                 log_device_warning_errno(dev, r, "Failed to copy all tags from old database entry, ignoring: %m");