简体   繁体   中英

Thunderbolt drives not marked as ejectable in disk arbitration/iokit although they clearly are

I am developing an application that uses disk arbitration to find out which devices are connected to a machine and react to connect/disconnect events and that has been working well for years. Just recently I discovered that something does not work as expected when working with external thunderbolt drives and I debugged this to find that the volume's ejectable property (kDADiskDescriptionMediaEjectableKey in Disk Arbitration which maps to kIOMediaEjectableKey i IOKit) is set to false. However, the drive is displayed with an eject button.

What does finder use to decide if this volume is ejectable? Obviously not the obvious kDADiskDescriptionMediaEjectableKey.

Any hint appreciated.

I did not find any other way but make heuristics based on trial and error with as many devices as I could find. Neither kDADiskDescriptionMediaEjectableKey nor kDADiskDescriptionMediaRemovableKey nor kDADiskDescriptionDeviceInternalKey properties can be relied on, eg an SD card inserted into the integrated card reader of a Macbook has kDADiskDescriptionDeviceInternalKey being true. Thus the condition I am using now is:

MediaEjectable == true || MediaRemovable == true || DeviceInternal == false) || DeviceProtocol == "USB" || DeviceProtocol == "FireWire"

Very ugly but haven't found a better way.

I'm not 100% sure on this, but I suspect OS X shows the eject button for any external drives. (ie non-internal: kDADiskDescriptionDeviceInternalKey being false) Thunderbolt drives are really just external PCIe drive controllers (SATA or whatever), and don't have a bus concept of "ejecting;" clicking eject will usually just unmount the volume and send the drive into standby. You can re-mount it anytime if you don't actually unplug it. Contrast this with many USB drives, which actually seem to fall off the bus when you eject them. So if the driver supports an explicit "eject" action, that will be performed as well when you click eject, but it's not a requirement for showing the eject UI.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM