return 0;
}
- /* Set ID_RENAMING boolean property here, and drop it in the corresponding move uevent later. */
+ /* Set ID_RENAMING boolean property here. It will be dropped when the corresponding move uevent is processed. */
r = device_add_property(dev, "ID_RENAMING", "1");
if (r < 0)
return log_device_warning_errno(dev, r, "Failed to add 'ID_RENAMING' property: %m");
return r;
}
-static int udev_event_on_move(sd_device *dev) {
- int r;
-
- /* Drop previously added property */
- r = device_add_property(dev, "ID_RENAMING", NULL);
- if (r < 0)
- return log_device_debug_errno(dev, r, "Failed to remove 'ID_RENAMING' property: %m");
-
- return 0;
-}
-
static int copy_all_tags(sd_device *d, sd_device *s) {
const char *tag;
int r;
if (r < 0)
log_device_warning_errno(dev, r, "Failed to copy all tags from old database entry, ignoring: %m");
- if (action == SD_DEVICE_MOVE) {
- r = udev_event_on_move(event->dev);
- if (r < 0)
- return r;
- }
+ /* Drop previously added property for safety to make IMPORT{db}="ID_RENAMING" not work. This is
+ * mostly for 'move' uevent, but let's do unconditionally. Why? If a network interface is renamed in
+ * initrd, then udevd may lose the 'move' uevent during switching root. Usually, we do not set the
+ * persistent flag for network interfaces, but user may set it. Just for safety. */
+ r = device_add_property(event->dev_db_clone, "ID_RENAMING", NULL);
+ if (r < 0)
+ return log_device_debug_errno(dev, r, "Failed to remove 'ID_RENAMING' property: %m");
DEVICE_TRACE_POINT(rules_start, dev);