Alan Stern wrote:It doesn't decide that -- the device itself does. If the device was connected the entire time then it will respond properly. If it was disconnected then it will reset itself, losing its address. Hence it will not reply to further requests at the old address. usb_get_status() simply indicates whether or not a response was received.
I see. Then this information is unreliable and should not be trusted ( when resuming from a suspend ), as it leads to incorrect behavior.
Note: By "disconnected", I mean that the power session was interrupted. So even if the cable remained plugged in, if the bus suspend power wasn't present then the device was disconnected. Note also that it is impossible to tell whether the cable has been unplugged -- the hardware is capable of detecting only whether or not the power session was interrupted.
Given those caveats, yes, I agree that the routine should not indicate the device was disconnected if in fact it wasn't.
Exactly. Yes, there is no good way to determine _for certain_ that the user did no do something stupid, such as replace the drive with another one just like it, or change the contents in another machine, but that is no reason to assume that the user DID do something like that, and break the mount, when they in fact, did nothing of the sort.
Does the kernel have any problem figuring out when a _different_ device of the same type is connected at the old address after resume?
With USB, if the entire bus is powered off then every device on it is automatically disconnected. By definition.
Then the kernel needs to ignore those disconnect events ( provided that the device appears to still actually be there ) because they are false and lead to data loss.
You are complaining because you don't like the way USB was designed. That's fine, but it leaves you advocating a non- standardized position.
No, I am complaining because the kernel interprets the notice that the bus gives that the device _may_ have changed as a notice that the device in fact, _has_ changed,