When the reader is connected to the computer, this hack will
- display a happy face if the Kobo umounted the filesystems properly.
- display a sad face if it's still mounted even though it should not be.
If you see a sad face, you might have filesystem corruption and/or still running processes doing the wrong thing.
While the USB is connected it will keep checking state for about 5 minutes, so if some process is slow to free resources you will see a sad face first and it turns into a happy face. (But if the filesystem was mounted/used while it was still a sad face, there might still be corruption).
A possible cause for the sad face will be stored in /tmp/UsbDebug.log
After making this I found a bug in one of my own mods
This is mainly to debug other mods that may behave incorrectly during a USB connection.
I should also point out that this is by no means a complete check. It only considers obvious mounts; processes with open files or PWD; and libraries linked in by running programs. It does not cover loop devices, bind mounts, and more obscure ways to keep the filesystem busy.
Update:
Added a umount hook so it detects whether non-lazy umount would have worked or not.
The debug info is now copied to .addons/usbdebug/
Hack can be uninstalled by creating .addons/usbdebug/uninstall
Update: now also resolves offending fd names
Update 20160918: fix for GloHD/KA1