Skip to content

Commit 4fc69e8

Browse files
yuwatamrc0mmand
authored andcommitted
core/device: do not downgrade device state if it is already enumerated
On switching root, a device may have a persistent databse. In that case, Device.enumerated_found may have DEVICE_FOUND_UDEV flag, and it is not necessary to downgrade the Device.deserialized_found and Device.deserialized_state. Otherwise, the state of the device unit may be changed plugged -> dead -> plugged, if the device has not been mounted. Fixes #23429. [mwilck: cherry-picked from #23437]
1 parent cf1ac0c commit 4fc69e8

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/core/device.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,8 @@ static int device_coldplug(Unit *u) {
201201
* Of course, deserialized parameters may be outdated, but the unit state can be adjusted later by
202202
* device_catchup() or uevents. */
203203

204-
if (!m->honor_device_enumeration && !MANAGER_IS_USER(m)) {
204+
if (!m->honor_device_enumeration && !MANAGER_IS_USER(m) &&
205+
!FLAGS_SET(d->enumerated_found, DEVICE_FOUND_UDEV)) {
205206
found &= ~DEVICE_FOUND_UDEV; /* ignore DEVICE_FOUND_UDEV bit */
206207
if (state == DEVICE_PLUGGED)
207208
state = DEVICE_TENTATIVE; /* downgrade state */

0 commit comments

Comments
 (0)