On Fri May 23 04:23:45 2025 +0000, Alexandre Julliard wrote:
There is probably some tiny DVD somewhere in the world that will still
be misdetected, but I'm not sure that issuing SCSI commands to the drive to try to determine the disc type would be any more reliable. To support an app that is most likely going to issue DVD ioctls, checking by using a DVD ioctl seems preferable.
Linux has only three [DVD ioctls](https://docs.kernel.org/userspace-api/ioctl/cdrom.html): DVD_READ_STRUCT, DVD_WRITE_STRUCT, and DVD_AUTH. It has no blu-ray ioctls. Of the three DVD ioctls, only DVD_READ_STRUCT would be suitable for disc type detection.
DVD_READ_STRUCT can read five kinds of information: DVD_STRUCT_PHYSICAL, DVD_STRUCT_COPYRIGHT, DVD_STRUCT_DISCKEY, DVD_STRUCT_BCA, and DVD_STRUCT_MANUFACT. Of those five, only DVD_STRUCT_PHYSICAL would be suitable for disc type detection.
At least on my LG WH16NS40 drive, DVD_STRUCT_PHYSICAL succeeds when there is a DVD in the drive, but it fails when there is a CD or a blu-ray in the drive. That means that we could use DVD_STRUCT_PHYSICAL to accurately detect whether there is a DVD in the drive, but we would still need another way to detect blu-rays.
Is there another ioctl that you had in mind, or something else that I missed? Do you want to try DVD_STRUCT_PHYSICAL first and fall back to guessing based on the data size if it fails? Please let me know how to proceed.