]> 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)
committerLuca Boccassi <luca.boccassi@gmail.com>
Fri, 27 Feb 2026 20:05:57 +0000 (20:05 +0000)
No functional change, preparation for the next commit.

(cherry picked from commit 1c867dc71af12bb7afb1981f83fea14eb4b98993)
(cherry picked from commit 40451b010751a136bb40e05652cc5cbb5bdd8190)
(cherry picked from commit d6a8d16801ed04b9de86574ac6bfa379104eec0f)

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

index 1c148b8573c2abe322252502abf45f5fed509ee3..68f9e6376dcda7c896967c2268998750fe588925 100644 (file)
@@ -676,6 +676,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 eab54203f0dff60664dca34138789fcccddc8a71..a5b866371278f22587ee74da885cb78a2155e80d 100644 (file)
@@ -47,6 +47,7 @@ int device_add_property(sd_device *device, const char *property, const char *val
 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 607071a8cf6c42cb52c7ee5d2ddb4675ecca9660..23bc9cedcbe4bc4a0b1a0b2e0dabe381b0f8efb7 100644 (file)
@@ -321,23 +321,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;
@@ -390,7 +373,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");