sd-device: do not try to remove previous tag indexes
The removed code in device_tag_index() in fact does nothing, as sd_device.all_tags is never cleared. Moreover, not only the code is meaningless, but it is theoretically/logically wrong, as the symlinks in /run/udev/tags/ should be 'sticky', hence we should even not try to remove them.
This commit is contained in:
@@ -769,15 +769,9 @@ static int device_tag(sd_device *device, const char *tag, bool add) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int device_tag_index(sd_device *device, sd_device *device_old, bool add) {
|
||||
int device_tag_index(sd_device *device, bool add) {
|
||||
int r = 0;
|
||||
|
||||
if (add && device_old)
|
||||
/* delete possible left-over tags */
|
||||
FOREACH_DEVICE_TAG(device_old, tag)
|
||||
if (!sd_device_has_tag(device, tag))
|
||||
RET_GATHER(r, device_tag(device_old, tag, false));
|
||||
|
||||
FOREACH_DEVICE_TAG(device, tag)
|
||||
RET_GATHER(r, device_tag(device, tag, add));
|
||||
|
||||
|
||||
@@ -59,7 +59,7 @@ int device_get_properties_strv(sd_device *device, char ***ret);
|
||||
|
||||
int device_clone_with_db(sd_device *device, sd_device **ret);
|
||||
|
||||
int device_tag_index(sd_device *device, sd_device *device_old, bool add);
|
||||
int device_tag_index(sd_device *device, bool add);
|
||||
bool device_should_have_db(sd_device *device);
|
||||
int device_has_db(sd_device *device);
|
||||
int device_update_db(sd_device *device);
|
||||
|
||||
@@ -63,7 +63,7 @@ int device_broadcast_on_error(sd_device *dev, sd_device_monitor *monitor) {
|
||||
|
||||
/* delete state from disk */
|
||||
(void) device_delete_db(dev);
|
||||
(void) device_tag_index(dev, /* device_old= */ NULL, /* add= */ false);
|
||||
(void) device_tag_index(dev, /* add= */ false);
|
||||
|
||||
r = device_monitor_send(monitor, /* destination= */ NULL, dev);
|
||||
if (r < 0) {
|
||||
|
||||
@@ -310,7 +310,7 @@ static int event_execute_rules_on_remove(UdevEvent *event, UdevRules *rules) {
|
||||
log_device_debug_errno(dev, r, "Failed to read database under /run/udev/data/: %m");
|
||||
|
||||
if (EVENT_MODE_DESTRUCTIVE(event)) {
|
||||
r = device_tag_index(dev, NULL, false);
|
||||
r = device_tag_index(dev, /* add= */ false);
|
||||
if (r < 0)
|
||||
log_device_debug_errno(dev, r, "Failed to remove corresponding tag files under /run/udev/tag/, ignoring: %m");
|
||||
|
||||
@@ -416,7 +416,7 @@ int udev_event_execute_rules(UdevEvent *event, UdevRules *rules) {
|
||||
|
||||
if (EVENT_MODE_DESTRUCTIVE(event)) {
|
||||
/* (re)write database file */
|
||||
r = device_tag_index(dev, event->dev_db_clone, true);
|
||||
r = device_tag_index(dev, /* add= */ true);
|
||||
if (r < 0)
|
||||
return log_device_debug_errno(dev, r, "Failed to update tags under /run/udev/tag/: %m");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user