diff options
author | Yu Watanabe <watanabe.yu+github@gmail.com> | 2022-10-28 09:06:02 +0900 |
---|---|---|
committer | Yu Watanabe <watanabe.yu+github@gmail.com> | 2023-01-19 17:58:05 +0900 |
commit | 1193448cb68e5a90cab027e16a093bbd367e9494 (patch) | |
tree | 2bbfb8692eadc7f55a1eb641f0aa73bd60c6ebf7 /src/udev | |
parent | dfbd824a0b780310d7f865a6ea0d60434d924683 (diff) | |
download | systemd-1193448cb68e5a90cab027e16a093bbd367e9494.tar.gz |
udevadm-trigger: also check with the original syspath if device is renamed
For older kernels that synthetic UUID is not supported, we need to also
check the original device name, as udevd broadcasts uevent with new
sysname.
Fixes #25115.
Diffstat (limited to 'src/udev')
-rw-r--r-- | src/udev/udevadm-trigger.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/src/udev/udevadm-trigger.c b/src/udev/udevadm-trigger.c index 3909fa237c..40ee5085a0 100644 --- a/src/udev/udevadm-trigger.c +++ b/src/udev/udevadm-trigger.c @@ -177,6 +177,32 @@ static int device_monitor_handler(sd_device_monitor *m, sd_device *dev, void *us saved = set_remove(settle_path_or_ids, syspath); if (!saved) { + const char *old_sysname; + + /* When the device is renamed, the new name is broadcast, and the old name is saved + * in INTERFACE_OLD. */ + + if (sd_device_get_property_value(dev, "INTERFACE_OLD", &old_sysname) >= 0) { + _cleanup_free_ char *dir = NULL, *old_syspath = NULL; + + r = path_extract_directory(syspath, &dir); + if (r < 0) { + log_device_debug_errno(dev, r, + "Failed to extract directory from '%s', ignoring: %m", + syspath); + return 0; + } + + old_syspath = path_join(dir, old_sysname); + if (!old_syspath) { + log_oom_debug(); + return 0; + } + + saved = set_remove(settle_path_or_ids, old_syspath); + } + } + if (!saved) { log_device_debug(dev, "Got uevent for unexpected device, ignoring."); return 0; } |