fix the old symbolic links are not deleted when the NVMe partition is renamed
This commit is contained in:
parent
0bcee895ed
commit
9224cad714
@ -0,0 +1,141 @@
|
||||
From 35e49f2856dc7e80cfc6c9af3dca4e3aad9b8cb5 Mon Sep 17 00:00:00 2001
|
||||
From: Yu Watanabe <watanabe.yu+github@gmail.com>
|
||||
Date: Wed, 5 Jul 2023 11:44:00 +0900
|
||||
Subject: [PATCH] sd-device: do not read uevent file in device_clone_with_db()
|
||||
|
||||
Follow-up for 381f6d4ba5551898e7ff19189485072b94879281.
|
||||
|
||||
When the function is called, the device may be already removed, and
|
||||
another device has the same syspath. Such situation can occur when a
|
||||
partition removed and another is created. In that case, the sysfs paths
|
||||
of the removed and newly created partitions can be same, but their
|
||||
devnums are different, and thus the database files corresponding to the
|
||||
devices are also different.
|
||||
|
||||
Fixes #27981.
|
||||
|
||||
Conflict:adapt context
|
||||
Reference:https://github.com/systemd/systemd/commit/35e49f2856dc7e80cfc6c9af3dca4e3aad9b8cb5
|
||||
|
||||
---
|
||||
src/libsystemd/sd-device/device-private.c | 78 +++++++++--------------
|
||||
1 file changed, 31 insertions(+), 47 deletions(-)
|
||||
|
||||
diff --git a/src/libsystemd/sd-device/device-private.c b/src/libsystemd/sd-device/device-private.c
|
||||
index 61f174a..d1600f6 100644
|
||||
--- a/src/libsystemd/sd-device/device-private.c
|
||||
+++ b/src/libsystemd/sd-device/device-private.c
|
||||
@@ -747,51 +747,56 @@ int device_rename(sd_device *device, const char *name) {
|
||||
return device_add_property_internal(device, "INTERFACE", name);
|
||||
}
|
||||
|
||||
-static int device_shallow_clone(sd_device *device, sd_device **ret) {
|
||||
+int device_clone_with_db(sd_device *device, sd_device **ret) {
|
||||
_cleanup_(sd_device_unrefp) sd_device *dest = NULL;
|
||||
- const char *val = NULL;
|
||||
+ const char *key, *val;
|
||||
int r;
|
||||
|
||||
assert(device);
|
||||
assert(ret);
|
||||
|
||||
+ /* The device may be already removed. Let's copy minimal set of information that was obtained through
|
||||
+ * netlink socket. */
|
||||
+
|
||||
r = device_new_aux(&dest);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
+ /* Seal device to prevent reading the uevent file, as the device may have been already removed. */
|
||||
+ dest->sealed = true;
|
||||
+
|
||||
+ /* Copy syspath, then also devname, sysname or sysnum can be obtained. */
|
||||
r = device_set_syspath(dest, device->syspath, false);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
- (void) sd_device_get_subsystem(device, &val);
|
||||
- r = device_set_subsystem(dest, val);
|
||||
- if (r < 0)
|
||||
- return r;
|
||||
- if (streq_ptr(val, "drivers")) {
|
||||
- r = free_and_strdup(&dest->driver_subsystem, device->driver_subsystem);
|
||||
+ /* Copy other information stored in database. Here, do not use FOREACH_DEVICE_PROPERTY() and
|
||||
+ * sd_device_get_property_value(), as they calls device_properties_prepare() ->
|
||||
+ * device_read_uevent_file(), but as commented in the above, the device may be already removed and
|
||||
+ * reading uevent file may fail. */
|
||||
+ ORDERED_HASHMAP_FOREACH_KEY(val, key, device->properties) {
|
||||
+ if (streq(key, "MINOR"))
|
||||
+ continue;
|
||||
+
|
||||
+ if (streq(key, "MAJOR")) {
|
||||
+ const char *minor = NULL;
|
||||
+
|
||||
+ minor = ordered_hashmap_get(device->properties, "MINOR");
|
||||
+ r = device_set_devnum(dest, val, minor);
|
||||
+ } else
|
||||
+ r = device_amend(dest, key, val);
|
||||
if (r < 0)
|
||||
return r;
|
||||
- }
|
||||
-
|
||||
- /* The device may be already removed. Let's copy minimal set of information to make
|
||||
- * device_get_device_id() work without uevent file. */
|
||||
|
||||
- if (sd_device_get_property_value(device, "IFINDEX", &val) >= 0) {
|
||||
- r = device_set_ifindex(dest, val);
|
||||
- if (r < 0)
|
||||
- return r;
|
||||
- }
|
||||
-
|
||||
- if (sd_device_get_property_value(device, "MAJOR", &val) >= 0) {
|
||||
- const char *minor = NULL;
|
||||
-
|
||||
- (void) sd_device_get_property_value(device, "MINOR", &minor);
|
||||
- r = device_set_devnum(dest, val, minor);
|
||||
- if (r < 0)
|
||||
- return r;
|
||||
+ if (streq(key, "SUBSYSTEM") && streq(val, "drivers")) {
|
||||
+ r = free_and_strdup(&dest->driver_subsystem, device->driver_subsystem);
|
||||
+ if (r < 0)
|
||||
+ return r;
|
||||
+ }
|
||||
}
|
||||
|
||||
- r = device_read_uevent_file(dest);
|
||||
+ /* Finally, read the udev database. */
|
||||
+ r = device_read_db_internal(dest, /* force = */ true);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
@@ -799,27 +804,6 @@ static int device_shallow_clone(sd_device *device, sd_device **ret) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
-int device_clone_with_db(sd_device *device, sd_device **ret) {
|
||||
- _cleanup_(sd_device_unrefp) sd_device *dest = NULL;
|
||||
- int r;
|
||||
-
|
||||
- assert(device);
|
||||
- assert(ret);
|
||||
-
|
||||
- r = device_shallow_clone(device, &dest);
|
||||
- if (r < 0)
|
||||
- return r;
|
||||
-
|
||||
- r = device_read_db(dest);
|
||||
- if (r < 0)
|
||||
- return r;
|
||||
-
|
||||
- dest->sealed = true;
|
||||
-
|
||||
- *ret = TAKE_PTR(dest);
|
||||
- return 0;
|
||||
-}
|
||||
-
|
||||
int device_new_from_synthetic_event(sd_device **new_device, const char *syspath, const char *action) {
|
||||
_cleanup_(sd_device_unrefp) sd_device *ret = NULL;
|
||||
int r;
|
||||
--
|
||||
2.39.1
|
||||
|
||||
94
backport-sd-device-drop-unused-device_copy_properties.patch
Normal file
94
backport-sd-device-drop-unused-device_copy_properties.patch
Normal file
@ -0,0 +1,94 @@
|
||||
From 53354d370ee3ea036f2d3602d268e42cdc968345 Mon Sep 17 00:00:00 2001
|
||||
From: Yu Watanabe <watanabe.yu+github@gmail.com>
|
||||
Date: Wed, 26 Oct 2022 05:05:30 +0900
|
||||
Subject: [PATCH] sd-device: drop unused device_copy_properties()
|
||||
|
||||
Conflict:adapt context
|
||||
Reference:https://github.com/systemd/systemd/commit/53354d370ee3ea036f2d3602d268e42cdc968345
|
||||
|
||||
---
|
||||
src/libsystemd/sd-device/device-private.c | 26 -------------------
|
||||
src/libsystemd/sd-device/device-private.h | 1 -
|
||||
.../sd-device/test-sd-device-monitor.c | 10 -------
|
||||
3 files changed, 37 deletions(-)
|
||||
|
||||
diff --git a/src/libsystemd/sd-device/device-private.c b/src/libsystemd/sd-device/device-private.c
|
||||
index f6041c7165..cfe4af0fcc 100644
|
||||
--- a/src/libsystemd/sd-device/device-private.c
|
||||
+++ b/src/libsystemd/sd-device/device-private.c
|
||||
@@ -737,32 +737,6 @@ int device_clone_with_db(sd_device *device, sd_device **ret) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
-int device_copy_properties(sd_device *device_dst, sd_device *device_src) {
|
||||
- const char *property, *value;
|
||||
- int r;
|
||||
-
|
||||
- assert(device_dst);
|
||||
- assert(device_src);
|
||||
-
|
||||
- r = device_properties_prepare(device_src);
|
||||
- if (r < 0)
|
||||
- return r;
|
||||
-
|
||||
- ORDERED_HASHMAP_FOREACH_KEY(value, property, device_src->properties_db) {
|
||||
- r = device_add_property_aux(device_dst, property, value, true);
|
||||
- if (r < 0)
|
||||
- return r;
|
||||
- }
|
||||
-
|
||||
- ORDERED_HASHMAP_FOREACH_KEY(value, property, device_src->properties) {
|
||||
- r = device_add_property_aux(device_dst, property, value, false);
|
||||
- if (r < 0)
|
||||
- return r;
|
||||
- }
|
||||
-
|
||||
- return 0;
|
||||
-}
|
||||
-
|
||||
void device_cleanup_tags(sd_device *device) {
|
||||
assert(device);
|
||||
|
||||
diff --git a/src/libsystemd/sd-device/device-private.h b/src/libsystemd/sd-device/device-private.h
|
||||
index 90da7f4317..6e96cc264a 100644
|
||||
--- a/src/libsystemd/sd-device/device-private.h
|
||||
+++ b/src/libsystemd/sd-device/device-private.h
|
||||
@@ -56,7 +56,6 @@ int device_get_properties_strv(sd_device *device, char ***ret);
|
||||
int device_rename(sd_device *device, const char *name);
|
||||
int device_shallow_clone(sd_device *device, sd_device **ret);
|
||||
int device_clone_with_db(sd_device *device, sd_device **ret);
|
||||
-int device_copy_properties(sd_device *device_dst, sd_device *device_src);
|
||||
int device_new_from_synthetic_event(sd_device **new_device, const char *syspath, const char *action);
|
||||
|
||||
int device_tag_index(sd_device *dev, sd_device *dev_old, bool add);
|
||||
diff --git a/src/libsystemd/sd-device/test-sd-device-monitor.c b/src/libsystemd/sd-device/test-sd-device-monitor.c
|
||||
index 66ca63600d..9e64ba01c6 100644
|
||||
--- a/src/libsystemd/sd-device/test-sd-device-monitor.c
|
||||
+++ b/src/libsystemd/sd-device/test-sd-device-monitor.c
|
||||
@@ -293,15 +293,6 @@ static void test_sd_device_monitor_filter_remove(sd_device *device) {
|
||||
assert_se(sd_event_loop(sd_device_monitor_get_event(monitor_client)) == 100);
|
||||
}
|
||||
|
||||
-static void test_device_copy_properties(sd_device *device) {
|
||||
- _cleanup_(sd_device_unrefp) sd_device *copy = NULL;
|
||||
-
|
||||
- assert_se(device_shallow_clone(device, ©) >= 0);
|
||||
- assert_se(device_copy_properties(copy, device) >= 0);
|
||||
-
|
||||
- test_send_receive_one(copy, false, false, false);
|
||||
-}
|
||||
-
|
||||
int main(int argc, char *argv[]) {
|
||||
_cleanup_(sd_device_unrefp) sd_device *loopback = NULL, *sda = NULL;
|
||||
int r;
|
||||
@@ -333,7 +324,6 @@ int main(int argc, char *argv[]) {
|
||||
test_tag_filter(loopback);
|
||||
test_sysattr_filter(loopback, "ifindex");
|
||||
test_sd_device_monitor_filter_remove(loopback);
|
||||
- test_device_copy_properties(loopback);
|
||||
|
||||
r = sd_device_new_from_subsystem_sysname(&sda, "block", "sda");
|
||||
if (r < 0) {
|
||||
--
|
||||
2.39.1
|
||||
|
||||
@ -0,0 +1,28 @@
|
||||
From 9c5d7151c14134fc45bf8dc2795fadccb5c3399c Mon Sep 17 00:00:00 2001
|
||||
From: Yu Watanabe <watanabe.yu+github@gmail.com>
|
||||
Date: Sun, 17 Apr 2022 16:09:11 +0900
|
||||
Subject: [PATCH] sd-device: fix possible use-of-uninitialized-value
|
||||
|
||||
Conflict:NA
|
||||
Reference:https://github.com/systemd/systemd/commit/9c5d7151c14134fc45bf8dc2795fadccb5c3399c
|
||||
|
||||
---
|
||||
src/libsystemd/sd-device/device-private.c | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/src/libsystemd/sd-device/device-private.c b/src/libsystemd/sd-device/device-private.c
|
||||
index 47b62e7421..42a5467b81 100644
|
||||
--- a/src/libsystemd/sd-device/device-private.c
|
||||
+++ b/src/libsystemd/sd-device/device-private.c
|
||||
@@ -793,7 +793,7 @@ int device_rename(sd_device *device, const char *name) {
|
||||
|
||||
int device_shallow_clone(sd_device *old_device, sd_device **new_device) {
|
||||
_cleanup_(sd_device_unrefp) sd_device *ret = NULL;
|
||||
- const char *val;
|
||||
+ const char *val = NULL;
|
||||
int r;
|
||||
|
||||
assert(old_device);
|
||||
--
|
||||
2.39.1
|
||||
|
||||
41
backport-sd-device-make-device_shallow_clone-static.patch
Normal file
41
backport-sd-device-make-device_shallow_clone-static.patch
Normal file
@ -0,0 +1,41 @@
|
||||
From 389954987adb22aca606a7db38d276cd0ec88787 Mon Sep 17 00:00:00 2001
|
||||
From: Yu Watanabe <watanabe.yu+github@gmail.com>
|
||||
Date: Wed, 26 Oct 2022 05:12:54 +0900
|
||||
Subject: [PATCH] sd-device: make device_shallow_clone() static
|
||||
|
||||
Conflict:adapt context
|
||||
Reference:https://github.com/systemd/systemd/commit/389954987adb22aca606a7db38d276cd0ec88787
|
||||
|
||||
---
|
||||
src/libsystemd/sd-device/device-private.c | 2 +-
|
||||
src/libsystemd/sd-device/device-private.h | 1 -
|
||||
2 files changed, 1 insertion(+), 2 deletions(-)
|
||||
|
||||
diff --git a/src/libsystemd/sd-device/device-private.c b/src/libsystemd/sd-device/device-private.c
|
||||
index cfe4af0fcc..bc7a838608 100644
|
||||
--- a/src/libsystemd/sd-device/device-private.c
|
||||
+++ b/src/libsystemd/sd-device/device-private.c
|
||||
@@ -664,7 +664,7 @@ int device_rename(sd_device *device, const char *name) {
|
||||
return device_add_property_internal(device, "INTERFACE", name);
|
||||
}
|
||||
|
||||
-int device_shallow_clone(sd_device *device, sd_device **ret) {
|
||||
+static int device_shallow_clone(sd_device *device, sd_device **ret) {
|
||||
_cleanup_(sd_device_unrefp) sd_device *dest = NULL;
|
||||
const char *val = NULL;
|
||||
int r;
|
||||
diff --git a/src/libsystemd/sd-device/device-private.h b/src/libsystemd/sd-device/device-private.h
|
||||
index 6e96cc264a..a59f130aff 100644
|
||||
--- a/src/libsystemd/sd-device/device-private.h
|
||||
+++ b/src/libsystemd/sd-device/device-private.h
|
||||
@@ -54,7 +54,6 @@ int device_get_properties_nulstr(sd_device *device, const char **ret_nulstr, siz
|
||||
int device_get_properties_strv(sd_device *device, char ***strv);
|
||||
|
||||
int device_rename(sd_device *device, const char *name);
|
||||
-int device_shallow_clone(sd_device *device, sd_device **ret);
|
||||
int device_clone_with_db(sd_device *device, sd_device **ret);
|
||||
int device_new_from_synthetic_event(sd_device **new_device, const char *syspath, const char *action);
|
||||
|
||||
--
|
||||
2.39.1
|
||||
|
||||
47
backport-sd-device-reduce-indentation.patch
Normal file
47
backport-sd-device-reduce-indentation.patch
Normal file
@ -0,0 +1,47 @@
|
||||
From f5a75f2027e53bdaf4deb7087fac73f8be6bf4f4 Mon Sep 17 00:00:00 2001
|
||||
From: Yu Watanabe <watanabe.yu+github@gmail.com>
|
||||
Date: Sun, 17 Apr 2022 13:11:08 +0900
|
||||
Subject: [PATCH] sd-device: reduce indentation
|
||||
|
||||
Conflict:NA
|
||||
Reference:https://github.com/systemd/systemd/commit/f5a75f2027e53bdaf4deb7087fac73f8be6bf4f4
|
||||
|
||||
---
|
||||
src/libsystemd/sd-device/device-private.c | 18 ++++++++----------
|
||||
1 file changed, 8 insertions(+), 10 deletions(-)
|
||||
|
||||
diff --git a/src/libsystemd/sd-device/device-private.c b/src/libsystemd/sd-device/device-private.c
|
||||
index 90dcd3a857..9bf39ecfab 100644
|
||||
--- a/src/libsystemd/sd-device/device-private.c
|
||||
+++ b/src/libsystemd/sd-device/device-private.c
|
||||
@@ -774,19 +774,17 @@ int device_rename(sd_device *device, const char *name) {
|
||||
return r;
|
||||
|
||||
r = sd_device_get_property_value(device, "INTERFACE", &interface);
|
||||
- if (r >= 0) {
|
||||
- /* like DEVPATH_OLD, INTERFACE_OLD is not saved to the db, but only stays around for the current event */
|
||||
- r = device_add_property_internal(device, "INTERFACE_OLD", interface);
|
||||
- if (r < 0)
|
||||
- return r;
|
||||
+ if (r == -ENOENT)
|
||||
+ return 0;
|
||||
+ if (r < 0)
|
||||
+ return r;
|
||||
|
||||
- r = device_add_property_internal(device, "INTERFACE", name);
|
||||
- if (r < 0)
|
||||
- return r;
|
||||
- } else if (r != -ENOENT)
|
||||
+ /* like DEVPATH_OLD, INTERFACE_OLD is not saved to the db, but only stays around for the current event */
|
||||
+ r = device_add_property_internal(device, "INTERFACE_OLD", interface);
|
||||
+ if (r < 0)
|
||||
return r;
|
||||
|
||||
- return 0;
|
||||
+ return device_add_property_internal(device, "INTERFACE", name);
|
||||
}
|
||||
|
||||
int device_shallow_clone(sd_device *old_device, sd_device **new_device) {
|
||||
--
|
||||
2.39.1
|
||||
|
||||
137
backport-sd-device-rename-arguments-and-variables.patch
Normal file
137
backport-sd-device-rename-arguments-and-variables.patch
Normal file
@ -0,0 +1,137 @@
|
||||
From 23d20adc05eda10ad0c89203cab36059dfc9da7c Mon Sep 17 00:00:00 2001
|
||||
From: Yu Watanabe <watanabe.yu+github@gmail.com>
|
||||
Date: Sun, 17 Apr 2022 16:09:57 +0900
|
||||
Subject: [PATCH] sd-device: rename arguments and variables
|
||||
|
||||
Conflict:adapt context
|
||||
Reference:https://github.com/systemd/systemd/commit/23d20adc05eda10ad0c89203cab36059dfc9da7c
|
||||
|
||||
---
|
||||
src/libsystemd/sd-device/device-private.c | 49 +++++++++++------------
|
||||
src/libsystemd/sd-device/device-private.h | 4 +-
|
||||
2 files changed, 26 insertions(+), 27 deletions(-)
|
||||
|
||||
diff --git a/src/libsystemd/sd-device/device-private.c b/src/libsystemd/sd-device/device-private.c
|
||||
index 42a5467b81..4a5a110364 100644
|
||||
--- a/src/libsystemd/sd-device/device-private.c
|
||||
+++ b/src/libsystemd/sd-device/device-private.c
|
||||
@@ -791,28 +791,28 @@ int device_rename(sd_device *device, const char *name) {
|
||||
return device_add_property_internal(device, "INTERFACE", name);
|
||||
}
|
||||
|
||||
-int device_shallow_clone(sd_device *old_device, sd_device **new_device) {
|
||||
- _cleanup_(sd_device_unrefp) sd_device *ret = NULL;
|
||||
+int device_shallow_clone(sd_device *device, sd_device **ret) {
|
||||
+ _cleanup_(sd_device_unrefp) sd_device *dest = NULL;
|
||||
const char *val = NULL;
|
||||
int r;
|
||||
|
||||
- assert(old_device);
|
||||
- assert(new_device);
|
||||
+ assert(device);
|
||||
+ assert(ret);
|
||||
|
||||
- r = device_new_aux(&ret);
|
||||
+ r = device_new_aux(&dest);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
- r = device_set_syspath(ret, old_device->syspath, false);
|
||||
+ r = device_set_syspath(dest, device->syspath, false);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
- (void) sd_device_get_subsystem(old_device, &val);
|
||||
- r = device_set_subsystem(ret, val);
|
||||
+ (void) sd_device_get_subsystem(device, &val);
|
||||
+ r = device_set_subsystem(dest, val);
|
||||
if (r < 0)
|
||||
return r;
|
||||
if (streq_ptr(val, "drivers")) {
|
||||
- r = free_and_strdup(&ret->driver_subsystem, old_device->driver_subsystem);
|
||||
+ r = free_and_strdup(&dest->driver_subsystem, device->driver_subsystem);
|
||||
if (r < 0)
|
||||
return r;
|
||||
}
|
||||
@@ -820,48 +820,47 @@ int device_shallow_clone(sd_device *old_device, sd_device **new_device) {
|
||||
/* The device may be already removed. Let's copy minimal set of information to make
|
||||
* device_get_device_id() work without uevent file. */
|
||||
|
||||
- if (sd_device_get_property_value(old_device, "IFINDEX", &val) >= 0) {
|
||||
- r = device_set_ifindex(ret, val);
|
||||
+ if (sd_device_get_property_value(device, "IFINDEX", &val) >= 0) {
|
||||
+ r = device_set_ifindex(dest, val);
|
||||
if (r < 0)
|
||||
return r;
|
||||
}
|
||||
|
||||
- if (sd_device_get_property_value(old_device, "MAJOR", &val) >= 0) {
|
||||
+ if (sd_device_get_property_value(device, "MAJOR", &val) >= 0) {
|
||||
const char *minor = NULL;
|
||||
|
||||
- (void) sd_device_get_property_value(old_device, "MINOR", &minor);
|
||||
- r = device_set_devnum(ret, val, minor);
|
||||
+ (void) sd_device_get_property_value(device, "MINOR", &minor);
|
||||
+ r = device_set_devnum(dest, val, minor);
|
||||
if (r < 0)
|
||||
return r;
|
||||
}
|
||||
|
||||
- r = device_read_uevent_file(ret);
|
||||
+ r = device_read_uevent_file(dest);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
- *new_device = TAKE_PTR(ret);
|
||||
+ *ret = TAKE_PTR(dest);
|
||||
return 0;
|
||||
}
|
||||
|
||||
-int device_clone_with_db(sd_device *old_device, sd_device **new_device) {
|
||||
- _cleanup_(sd_device_unrefp) sd_device *ret = NULL;
|
||||
+int device_clone_with_db(sd_device *device, sd_device **ret) {
|
||||
+ _cleanup_(sd_device_unrefp) sd_device *dest = NULL;
|
||||
int r;
|
||||
|
||||
- assert(old_device);
|
||||
- assert(new_device);
|
||||
+ assert(device);
|
||||
+ assert(ret);
|
||||
|
||||
- r = device_shallow_clone(old_device, &ret);
|
||||
+ r = device_shallow_clone(device, &dest);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
- r = device_read_db(ret);
|
||||
+ r = device_read_db(dest);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
- ret->sealed = true;
|
||||
-
|
||||
- *new_device = TAKE_PTR(ret);
|
||||
+ dest->sealed = true;
|
||||
|
||||
+ *ret = TAKE_PTR(dest);
|
||||
return 0;
|
||||
}
|
||||
|
||||
diff --git a/src/libsystemd/sd-device/device-private.h b/src/libsystemd/sd-device/device-private.h
|
||||
index 9b2557a39c..b6b36b6727 100644
|
||||
--- a/src/libsystemd/sd-device/device-private.h
|
||||
+++ b/src/libsystemd/sd-device/device-private.h
|
||||
@@ -51,8 +51,8 @@ int device_get_properties_nulstr(sd_device *device, const uint8_t **nulstr, size
|
||||
int device_get_properties_strv(sd_device *device, char ***strv);
|
||||
|
||||
int device_rename(sd_device *device, const char *name);
|
||||
-int device_shallow_clone(sd_device *old_device, sd_device **new_device);
|
||||
-int device_clone_with_db(sd_device *old_device, sd_device **new_device);
|
||||
+int device_shallow_clone(sd_device *device, sd_device **ret);
|
||||
+int device_clone_with_db(sd_device *device, sd_device **ret);
|
||||
int device_copy_properties(sd_device *device_dst, sd_device *device_src);
|
||||
int device_new_from_synthetic_event(sd_device **new_device, const char *syspath, const char *action);
|
||||
|
||||
--
|
||||
2.39.1
|
||||
|
||||
@ -0,0 +1,57 @@
|
||||
From 17761fb3bfa494c565683222a707cfa28d14b560 Mon Sep 17 00:00:00 2001
|
||||
From: Yu Watanabe <watanabe.yu+github@gmail.com>
|
||||
Date: Sun, 17 Apr 2022 14:59:06 +0900
|
||||
Subject: [PATCH] sd-device: use ERRNO_IS_DEVICE_ABSENT() at one more place
|
||||
|
||||
Conflict:NA
|
||||
Reference:https://github.com/systemd/systemd/commit/17761fb3bfa494c565683222a707cfa28d14b560
|
||||
|
||||
---
|
||||
src/libsystemd/sd-device/device-private.c | 7 +++----
|
||||
src/libsystemd/sd-device/sd-device.c | 11 +++++++----
|
||||
2 files changed, 10 insertions(+), 8 deletions(-)
|
||||
|
||||
diff --git a/src/libsystemd/sd-device/device-private.c b/src/libsystemd/sd-device/device-private.c
|
||||
index 6ad49c05a0..47b62e7421 100644
|
||||
--- a/src/libsystemd/sd-device/device-private.c
|
||||
+++ b/src/libsystemd/sd-device/device-private.c
|
||||
@@ -835,10 +835,9 @@ int device_shallow_clone(sd_device *old_device, sd_device **new_device) {
|
||||
return r;
|
||||
}
|
||||
|
||||
- /* And then read uevent file, but ignore errors, as some devices seem to return a spurious
|
||||
- * error on read, e.g. -ENODEV, and even if ifindex or devnum is set in the above,
|
||||
- * sd_device_get_ifindex() or sd_device_get_devnum() fails. See. #19788. */
|
||||
- (void) device_read_uevent_file(ret);
|
||||
+ r = device_read_uevent_file(ret);
|
||||
+ if (r < 0)
|
||||
+ return r;
|
||||
|
||||
*new_device = TAKE_PTR(ret);
|
||||
return 0;
|
||||
diff --git a/src/libsystemd/sd-device/sd-device.c b/src/libsystemd/sd-device/sd-device.c
|
||||
index 6c2d1243ac..0c5b2a67e3 100644
|
||||
--- a/src/libsystemd/sd-device/sd-device.c
|
||||
+++ b/src/libsystemd/sd-device/sd-device.c
|
||||
@@ -724,11 +724,14 @@ int device_read_uevent_file(sd_device *device) {
|
||||
path = strjoina(syspath, "/uevent");
|
||||
|
||||
r = read_full_virtual_file(path, &uevent, &uevent_len);
|
||||
- if (IN_SET(r, -EACCES, -ENOENT))
|
||||
- /* The uevent files may be write-only, or the device may not have uevent file. */
|
||||
- return 0;
|
||||
- if (r < 0)
|
||||
+ if (r < 0) {
|
||||
+ /* The uevent files may be write-only, the device may be already removed, or the device
|
||||
+ * may not have the uevent file. */
|
||||
+ if (r == -EACCES || ERRNO_IS_DEVICE_ABSENT(r))
|
||||
+ return 0;
|
||||
+
|
||||
return log_device_debug_errno(device, r, "sd-device: Failed to read uevent file '%s': %m", path);
|
||||
+ }
|
||||
|
||||
for (size_t i = 0; i < uevent_len; i++)
|
||||
switch (state) {
|
||||
--
|
||||
2.39.1
|
||||
|
||||
12
systemd.spec
12
systemd.spec
@ -21,7 +21,7 @@
|
||||
Name: systemd
|
||||
Url: https://www.freedesktop.org/wiki/Software/systemd
|
||||
Version: 249
|
||||
Release: 65
|
||||
Release: 66
|
||||
License: MIT and LGPLv2+ and GPLv2+
|
||||
Summary: System and Service Manager
|
||||
|
||||
@ -613,6 +613,13 @@ Patch6564: backport-rules-import-previous-SYSTEMD_READY-state-for-suspen.pa
|
||||
Patch6565: backport-rules-go-to-the-end-of-rules-indeed-when-dm-is-suspe.patch
|
||||
Patch6566: backport-CVE-2023-7008.patch
|
||||
Patch6567: backport-core-add-possibility-to-not-track-certain-unit-types.patch
|
||||
Patch6568: backport-sd-device-reduce-indentation.patch
|
||||
Patch6569: backport-sd-device-use-ERRNO_IS_DEVICE_ABSENT-at-one-more-pla.patch
|
||||
Patch6570: backport-sd-device-fix-possible-use-of-uninitialized-value.patch
|
||||
Patch6571: backport-sd-device-rename-arguments-and-variables.patch
|
||||
Patch6572: backport-sd-device-drop-unused-device_copy_properties.patch
|
||||
Patch6573: backport-sd-device-make-device_shallow_clone-static.patch
|
||||
Patch6574: backport-sd-device-do-not-read-uevent-file-in-device_clone_wi.patch
|
||||
|
||||
Patch9001: update-rtc-with-system-clock-when-shutdown.patch
|
||||
Patch9002: udev-add-actions-while-rename-netif-failed.patch
|
||||
@ -2112,6 +2119,9 @@ grep -q -E '^KEYMAP="?fi-latin[19]"?' /etc/vconsole.conf 2>/dev/null &&
|
||||
%{_libdir}/security/pam_systemd.so
|
||||
|
||||
%changelog
|
||||
* Wed Feb 21 2024 huyubiao <huyubiao@huawei.com> - 249-66
|
||||
- fix the old symbolic links are not deleted when the NVMe partition is renamed
|
||||
|
||||
* Sun Feb 4 2024 huajingyun <huajingyun@loongson.cn> - 249-65
|
||||
- fix src.rpm missing loongarch patches
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user