I just disable all hotplugging support in my OS. Anything plugged into the machine must be manually mounted, enabled, etc. This works really great for me as it's rare that anything is attached to this machine other than the charger.
This is something I wrote a few days ago. All it requires is a POSIX shell and POSIX [, printf, dd and stty. Great for use in an initrd/initramfs or smaller environment as these tools are most likely available.
File operations (cp, mv, rm, etc) have not yet been implemented. It's on the TODO list. (though I'm unsure if
they're even needed) We'll see. :)
Writing this was... interesting. POSIX shell is very limited in what it can do. Endless tricks have been used, see the "implementation details" section of the README.