I'm using the g_file_storage
gadget in Linux to export a partition as a removable USB mass storage device to host PC's (Windows, Linux, MAC).
All of these host OS's (can) automatically mount the removable disk and access it without issues, and I'm looking for a way to detect that the host has ejected/unmounted the disk.
The only way I've found so far is limited to Windows XP. When the users choses "Safely Remove Hardware", XP puts the USB device to suspend mode which can be detected at the remote end. For some reason, this does not work in Vista.
EDIT: you are probably looking for Windows solution even if you tagged your question as Linux...
you can check dmesg for output like this: