summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2016-01-22 17:28:05 +0100
committerLennart Poettering <lennart@poettering.net>2016-01-22 17:28:05 +0100
commite14c67d046a6d28dca289bda415ac071f2dbfa07 (patch)
tree20909a7bce5620ab568a971b9b83e15b6a4af804
parentdd17a7aa12dd4559e3f79a5fcff865489d09462d (diff)
parentac9d396b2abbae4e7ab84f7b556f70681b66236b (diff)
Merge pull request #2412 from fbuihuu/device-fixes
Device fixes
-rw-r--r--src/core/device.c19
1 files changed, 13 insertions, 6 deletions
diff --git a/src/core/device.c b/src/core/device.c
index 56ed947089..807547c87f 100644
--- a/src/core/device.c
+++ b/src/core/device.c
@@ -315,12 +315,19 @@ static int device_setup_unit(Manager *m, struct udev_device *dev, const char *pa
u = manager_get_unit(m, e);
- if (u &&
- sysfs &&
- DEVICE(u)->sysfs &&
- !path_equal(DEVICE(u)->sysfs, sysfs)) {
- log_unit_debug(u, "Device %s appeared twice with different sysfs paths %s and %s", e, DEVICE(u)->sysfs, sysfs);
- return -EEXIST;
+ /* The device unit can still be present even if the device was
+ * unplugged: a mount unit can reference it hence preventing
+ * the GC to have garbaged it. That's desired since the device
+ * unit may have a dependency on the mount unit which was
+ * added during the loading of the later. */
+ if (u && DEVICE(u)->state == DEVICE_PLUGGED) {
+ /* This unit is in plugged state: we're sure it's
+ * attached to a device. */
+ if (!path_equal(DEVICE(u)->sysfs, sysfs)) {
+ log_unit_error(u, "Dev %s appeared twice with different sysfs paths %s and %s",
+ e, DEVICE(u)->sysfs, sysfs);
+ return -EEXIST;
+ }
}
if (!u) {