sd-device: move copy_all_tags() from udev
No functional change, preparation for the next commit.
This commit is contained in:
@@ -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);
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
+1
-18
@@ -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");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user