When you mount something in osx, it appears under / Volumes / mountname
Is there a way using the command line or C / C ++ to identify the volume as a CD / DVD?
My best idea is something like this.
df | grep mountname
to get the path / dev / diskNsM
and then
drutil | grep /dev/diskN
to ensure that the device installed in the path is a burner.
This works, but I am concerned about the case when the CD / DVD is not a burner. Will it be displayed on drutil output? Does the Mac even have a non-burning CD?
Also, I would prefer to use C, C ++, or the C target for this.
I already use
const char *tmp = '/Volumes/mysterydrive'; statfs(tmp, &m); if(m.f_flags & MNT_RDONLY) { read_only = true; }
to determine if the volume is read-only, but I donβt see if this or any related call can distinguish between a CD / DVD and a volume that has just been installed on a tone.
It will only need to work for OSX 10.5 and later.
Any ideas?
EDIT:
Using
diskutil info /Volumes/mysterydrive
I got the following output if its a CD / DVD
Optical Drive Type: CD-ROM, CD-R, CD-RW, DVD-ROM, DVD-R, DVD-R DL, DVD-RW, DVD+R, DVD+R DL, DVD+RW Optical Media Type: DVD-R Optical Media Erasable: No
And all I need!
I will learn about using IOKit to do this programmatically later, but this is apparently the fastest way to do this.