When a USB device is ejected using the GUI in Finder, what exactly happens at a low level? Are there certain signals sent to the device? 

The reason I am asking is because I am trying to emulate manual ejection of a device by adding and removing the file storage module via the console of a device running embedded Linux. Just removing the module works fine on a PC, but a Mac gives me the "not properly ejected" error, and the Linux kernel "panics" and gets a kernel null pointer error. 

Here is some extra information:

I am using a USB Gumstix COM device that is running embedded Linux. The device is plugged into a host (Windows or Mac), and I emulate physically removing it by removing the mass storage module in the Linux kernel of the device, thus making the host not see it as a storage device any longer. I accomplish this with `modprobe -r g_file_storage`. 

This works with no problem on Windows. It is not working on a Mac, because I get an error on the Mac host saying the device was not ejected correctly. This causes a null pointer error in the device's Linux kernel, and it panics.

This leads me to believe that there is something the ONLY the Mac does when properly ejecting a USB device that I need to be emulating in my script on the device.

Basically, I want to know if I need to be doing some signal handling or something on the device to properly emulate ejection on Mac hosts.