It's fairly easy on macOS to detect mount and unmount operations with an NSNotificationCenter
listener, as explained here.
But I'm actually looking for a way to detect whether a (physical or virtual) storage device was attached (without mount) or detached (e.g. after unmount).
(It must be possible because there are a couple of applications like Jettison or Mountain that have this functionality, e.g. they will notice when the external storage device is detached, or whether it's still present for re-mounting.)