4

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.

7
  • I'm not 100% sure on this, but I suspect OS X shows the eject button for any external drives. (i.e. non-internal: kDADiskDescriptionDeviceInternalKey being false) Thunderbolt drives are really just external PCIe drive controllers, 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.
    – pmdj
    Commented Jul 21, 2016 at 12:37
  • OK, thanks a lot! That is the only alternative I saw as well but the documentation of isInternal is sketchy at best but so far for all drives checked, this seems to be correct, so I'll probably do that. I'll wait a bit more for answers before closing this to allow for some more answers but then I'll probably accept this as the answer. Commented Jul 22, 2016 at 15:33
  • Having written storage device drivers myself, I can tell you the internal/external distinction is purely driver based - so it's entirely possible for a driver to claim that an external drive is internal and vice versa. To some extent you just have to trust the driver on this… In any case, I'll make my answer an answer not a comment.
    – pmdj
    Commented Jul 23, 2016 at 13:10
  • Are you sure you're looking at the proper level of the hierarchy? Are you working with the whole disk partition? If you use DADiskCopyWholeDisk() and copy its description, is it ejectable? Commented Jul 23, 2016 at 14:45
  • I am looking at the individual partition, i.e. if a drive is formatted with two partitions A and B, I look at A and B individually. Apart from the thunderbolt case this has worked but I'll check it out, next time I get my hands on a thunderbolt drive, which will be two days fro now, and report back. Commented Jul 24, 2016 at 19:29

2 Answers 2

2

I'm not 100% sure on this, but I suspect OS X shows the eject button for any external drives. (i.e. 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.

1
  • Just as a counter-example, here I have a disk image I have mounted where kDADiskDescriptionDeviceInternalKey is true.
    – Hakanai
    Commented Jul 11, 2017 at 23:03
2

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, e.g. 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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.