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.