From 28ffeafb766904581c7fe014f2da6206d5f49a40 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BF=A0=E5=87=8C?= Date: Tue, 24 Sep 2024 15:44:21 +0800 Subject: [PATCH] core, udev: remove old device on move event --- ...udev-remove-old-device-on-move-event.patch | 68 +++++++++++++++++++ systemd.spec | 6 +- 2 files changed, 73 insertions(+), 1 deletion(-) create mode 100644 10029-core-udev-remove-old-device-on-move-event.patch diff --git a/10029-core-udev-remove-old-device-on-move-event.patch b/10029-core-udev-remove-old-device-on-move-event.patch new file mode 100644 index 0000000..40481d4 --- /dev/null +++ b/10029-core-udev-remove-old-device-on-move-event.patch @@ -0,0 +1,68 @@ +From ec336943fad7cf191d2168a2e683a5985abb2fa8 Mon Sep 17 00:00:00 2001 +From: rpm-build +Date: Tue, 24 Sep 2024 06:37:25 +0000 +Subject: [PATCH] core, udev: remove old device on move event + +https://github.com/systemd/systemd/pull/16968/ +--- + src/core/device.c | 30 ++++++++++++++++++++++++++++++ + 1 file changed, 30 insertions(+) + +diff --git a/src/core/device.c b/src/core/device.c +index 71b7c1e..dcb47c2 100644 +--- a/src/core/device.c ++++ b/src/core/device.c +@@ -18,6 +18,9 @@ + #include "udev-util.h" + #include "unit-name.h" + #include "unit.h" ++#include "device-util.h" ++#include "sd-device.h" ++#include "libudev-device-internal.h" + + static const UnitActiveState state_translation_table[_DEVICE_STATE_MAX] = { + [DEVICE_DEAD] = UNIT_INACTIVE, +@@ -902,6 +905,29 @@ static void device_propagate_reload_by_sysfs(Manager *m, const char *sysfs) { + } + } + ++static int device_remove_old(Manager *m, sd_device *dev) { ++ _cleanup_free_ char *syspath_old = NULL, *e = NULL; ++ const char *devpath_old; ++ int r; ++ ++ r = sd_device_get_property_value(dev, "DEVPATH_OLD", &devpath_old); ++ if (r < 0) { ++ log_device_debug_errno(dev, r, "Failed to get DEVPATH_OLD= property on 'move' uevent, ignoring: %m"); ++ return 0; ++ } ++ ++ syspath_old = path_join(NULL, "/sys", devpath_old); ++ if (!syspath_old) ++ return log_oom(); ++ ++ r = unit_name_from_path(syspath_old, ".device", &e); ++ if (r < 0) ++ return log_device_error_errno(dev, r, "Failed to generate unit name from old device path: %m"); ++ ++ device_update_found_by_sysfs(m, syspath_old, 0, DEVICE_FOUND_UDEV|DEVICE_FOUND_MOUNT|DEVICE_FOUND_SWAP); ++ return 0; ++} ++ + static int device_dispatch_io(sd_event_source *source, int fd, uint32_t revents, void *userdata) { + _cleanup_(udev_device_unrefp) struct udev_device *dev = NULL; + Manager *m = userdata; +@@ -939,6 +965,10 @@ static int device_dispatch_io(sd_event_source *source, int fd, uint32_t revents, + return 0; + } + ++ if (streq(action, "move")) { ++ (void) device_remove_old(m, dev->device); ++ } ++ + if (streq(action, "change")) + device_propagate_reload_by_sysfs(m, sysfs); + +-- +2.43.5 + diff --git a/systemd.spec b/systemd.spec index 3360a88..ea72e8f 100644 --- a/systemd.spec +++ b/systemd.spec @@ -1,4 +1,4 @@ -%define anolis_release .0.1 +%define anolis_release .0.2 #global gitcommit 10e465b5321bd53c1fc59ffab27e724535c6bc0f %{?gitcommit:%global gitcommitshort %(c=%{gitcommit}; echo ${c:0:7})} @@ -1095,6 +1095,7 @@ Patch10025: 10025-fileio-teach-read_full_file_full-to-read-from-offse.patch Patch10026: 10026-cryptsetup-port-cryptsetup-s-main-key-file-logic-ov.patch Patch10027: 10027-fix-compilation-without-utmp.patch Patch10028: 10028-cgroup-drastically-simplify-caching-of-cgroups-membe.patch +Patch10029: 10029-core-udev-remove-old-device-on-move-event.patch Patch20001: 20001-hwdb-parse_hwdb_dot_py.patch # Patch20002: 20002-cgroup-do-not-refresh-cgroup-devices-config-when-dae.patch @@ -1832,6 +1833,9 @@ fi %files tests -f .file-list-tests %changelog +* Tue Sep 24 2024 Zhongling He - 239-82.0.2 +- core, udev: remove old device on move event + * Wed Aug 28 2024 Yuanhong Peng - 239-82.0.1 - core: fix a null reference case in load_from_path() - sysctl: Don't pass null directive argument to '%s' -- Gitee