Skip to content

Commit 2659b04

Browse files
yuwatamwilck
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: backport of a5dedd6]
1 parent 7e46a5c commit 2659b04

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

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)