Zbigniew Jędrzejewski-Szmek 77e6ed
From 9ad7334d68fe2187968c4716097a24575835ab04 Mon Sep 17 00:00:00 2001
Zbigniew Jędrzejewski-Szmek 77e6ed
From: Martin Pitt <martin.pitt@ubuntu.com>
Zbigniew Jędrzejewski-Szmek 77e6ed
Date: Fri, 13 Mar 2015 08:35:59 +0100
Zbigniew Jędrzejewski-Szmek 77e6ed
Subject: [PATCH] core: don't change removed devices to state "tentative"
Zbigniew Jędrzejewski-Szmek 77e6ed
Zbigniew Jędrzejewski-Szmek 77e6ed
Commit 628c89c introduced the "tentative" device state, which caused
Zbigniew Jędrzejewski-Szmek 77e6ed
devices to go from "plugged" to "tentative" on a remove uevent. This
Zbigniew Jędrzejewski-Szmek 77e6ed
breaks the cleanup of stale mounts (see commit 3b48ce4), as that only
Zbigniew Jędrzejewski-Szmek 77e6ed
applies to "dead" devices.
Zbigniew Jędrzejewski-Szmek 77e6ed
Zbigniew Jędrzejewski-Szmek 77e6ed
The "tentative" state only really makes sense on adding a device when
Zbigniew Jędrzejewski-Szmek 77e6ed
we don't know where it was coming from (i. e. not from udev). But when
Zbigniew Jędrzejewski-Szmek 77e6ed
we get a device removal from udev we definitively know that it's gone,
Zbigniew Jędrzejewski-Szmek 77e6ed
so change the device state back to "dead" as before 628c89c.
Zbigniew Jędrzejewski-Szmek 77e6ed
Zbigniew Jędrzejewski-Szmek 77e6ed
(cherry picked from commit 496068a8288084ab3ecf8b179a8403ecff1a6be8)
Zbigniew Jędrzejewski-Szmek 77e6ed
---
Zbigniew Jędrzejewski-Szmek 77e6ed
 src/core/device.c | 2 +-
Zbigniew Jędrzejewski-Szmek 77e6ed
 1 file changed, 1 insertion(+), 1 deletion(-)
Zbigniew Jędrzejewski-Szmek 77e6ed
Zbigniew Jędrzejewski-Szmek 77e6ed
diff --git a/src/core/device.c b/src/core/device.c
Zbigniew Jędrzejewski-Szmek 77e6ed
index 4ff8827219..cc4ebd2c87 100644
Zbigniew Jędrzejewski-Szmek 77e6ed
--- a/src/core/device.c
Zbigniew Jędrzejewski-Szmek 77e6ed
+++ b/src/core/device.c
Zbigniew Jędrzejewski-Szmek 77e6ed
@@ -421,7 +421,7 @@ static void device_update_found_one(Device *d, bool add, DeviceFound found, bool
Zbigniew Jędrzejewski-Szmek 77e6ed
         if (now) {
Zbigniew Jędrzejewski-Szmek 77e6ed
                 if (d->found & DEVICE_FOUND_UDEV)
Zbigniew Jędrzejewski-Szmek 77e6ed
                         device_set_state(d, DEVICE_PLUGGED);
Zbigniew Jędrzejewski-Szmek 77e6ed
-                else if (d->found != DEVICE_NOT_FOUND)
Zbigniew Jędrzejewski-Szmek 77e6ed
+                else if (add && d->found != DEVICE_NOT_FOUND)
Zbigniew Jędrzejewski-Szmek 77e6ed
                         device_set_state(d, DEVICE_TENTATIVE);
Zbigniew Jędrzejewski-Szmek 77e6ed
                 else
Zbigniew Jędrzejewski-Szmek 77e6ed
                         device_set_state(d, DEVICE_DEAD);