I'm looking to create a function in C++ running on Linux that returns true if the CDRom media is a DVD and false if its anything else (e.g. Audio CD).
I have been using ioctl with linux/cdrom.h.
I tried using the DVD_READ_STRUCT but it always returns true. Maybe I'm using it incorrectly.
dvd_struct s
if (ioctl(hDEV, DVD_READ_STRUCT, &s)) {
return true;
}
Look at
/proc/sys/dev/cdrom/info, it contains something like this:(it is updated by the kernel and available in all distros) You can use this information in addition to the
ioctl's fromcdrom.h. Also keep in mind thatcdrom.his an attempt to create a standard interface, it does not yet cater for all manufacturers, some still using SCSI-codes or some other proprietary schemes. So to be safe you should also check at least using the SCSIioctlcodes - do#include <scsi/...to have them available.