Identify a mounted volume as a CD/DVD on osx Identify a mounted volume as a CD/DVD on osx bash bash

Identify a mounted volume as a CD/DVD on osx


You get the most detailed information from

diskutil info /Volume/foo

In particular see Optical Drive and Optical Media entries which you only get for CD/DVDs so it is quite reliable.

Unfortunately the frameworks that diskutil uses to get all that information are private, so it will be hard to replicate it in C code.

I didn't dig deeper into other options, but since you can get the disk name from statfs it may be in theory possible to use IOKit to check out the device and you'll see IOCDMedia or IODVDMedia class if it is a CD/DVD drive (i.e. if you look for IO*Media class the BSD Name property has the disk name like disk6)


Apple Developer Central has a sample code project called CDROMSample that shows using IOKit routines to access CD-ROM properties. This might give you a start into handling DVDs, as well.