Hey guys, I'm writing a program in C where I can see what the status of the optical drive tray is: open, closed, closed with disc, etc. Does anyone know where I can find the commands to actually do that?
Here's output of dmesg related to cd1:
Here's what I've found so far ..
I found the code in the kernel where it displays the status above, but not sure where to go from there https://github.com/freebsd/freebsd-...15273da5282ff7e/sys/cam/scsi/scsi_all.c#L2201
cdio.h has a list of ioctl commands you can do, but nothing to poll its status https://man.freebsd.org/cgi/man.cgi?query=cdio&sektion=7i&manpath=SunOS+5.7
Then I can see in the kernel the enums that are set (cd_flags, cd_ccb_state, cd_state), but don't know how to programatically access those either: https://github.com/freebsd/freebsd-...c815273da5282ff7e/sys/cam/scsi/scsi_cd.c#L102
dvd+rw-mediainfo can detect it:
But the code is complex / hard to read, so it's hard for me to figure out what calls it's making: https://github.com/rbrito/pkg-dvd-rw-tools/blob/master/dvd%2Brw-mediainfo.cpp
thanks guys
Here's output of dmesg related to cd1:
Code:
cd1 at umass-sim0 bus 0 scbus3 target 0 lun 0
cd1: <ASUS BC-12B1ST b 3.11> Removable CD-ROM SCSI device
cd1: 400.000MB/s transfers
cd1: Attempt to query device size failed: NOT READY, Medium not present - tray closed
cd1: quirks=0x10<10_BYTE_ONLY>
Here's what I've found so far ..
I found the code in the kernel where it displays the status above, but not sure where to go from there https://github.com/freebsd/freebsd-...15273da5282ff7e/sys/cam/scsi/scsi_all.c#L2201
Then I can see in the kernel the enums that are set (cd_flags, cd_ccb_state, cd_state), but don't know how to programatically access those either: https://github.com/freebsd/freebsd-...c815273da5282ff7e/sys/cam/scsi/scsi_cd.c#L102
dvd+rw-mediainfo can detect it:
Code:
$ dvd+rw-mediainfo /dev/cd0
INQUIRY: [Slimtype][DVD A DA8AESH ][XA1M]
GET [CURRENT] CONFIGURATION:
Mounted Media: 10h, DVD-ROM
Speed Descriptor#0: 08/2737183 [EMAIL]R@8.0x1385[/EMAIL]=11080KB/s [EMAIL]W@8.0x1385[/EMAIL]=11080KB/s
READ DVD STRUCTURE[#0h]:
Media Book Type: 00h, DVD-ROM book [revision 0]
Legacy lead-out at: 1627120*2KB=3332341760
DVD-ROM media detected, exiting...
But the code is complex / hard to read, so it's hard for me to figure out what calls it's making: https://github.com/rbrito/pkg-dvd-rw-tools/blob/master/dvd%2Brw-mediainfo.cpp
thanks guys
