Re: New CD-Rom-Code: How detect if cd is in drive?

Eberhard Moenkeberg (emoenke@gwdg.de)
26 May 1996 19:16:03 GMT


Thomas Niederreiter (tn@bv.rz.fh-muenchen.de) wrote:

: I just read the docs about the new CD-Rom-interface and I think
: its execellent...All the ioctls I waited for so long are there
: (eg. CHECK_DRIVE_STATUS, CHECK_DISK_STATUS...), but
: Only a small fraction of the calls are actually working yet...
: I know its quite bunch of work to implement all these call in all
: the hardware dependent-drivers.
: Are there plans to to have this ready when 2.0 comes out?

It is supposed to get done by step-by-step additions to <linux/cdrom.h>;
one driver writer implements his version, the others try to adapt it.

This way, every CDROM driver writer/maintainer can force the "evolution"
by small steps. Goal is to build the "enhanced" functionality without
an additional software layer - just by improving and unifying all the
"base" CDROM drivers directly -, and David van Leeuwen's proposal is
the guide (but not in all of its current aspects).

: I am asking because I need a nice way to check if a CD is in the
: drive and ready for operation.

If the open() request does not fail, you can have a look at the ToC
entries currently; if it fails, you can check the return code for a
reason.

: This is easy for SCSI-CD-Rom (send TEST_UNIT_READY and check the
: returned sense-key), but how can I do this for NON-SCSI-Drives?
: (As long the above mentioned ioctls are not working).

Some drivers can give answer by log messages currently. Maybe some
aspects of your needs can get easily fulfilled by specific error codes.

Thomas, you could implement "your" missing IOCTLS for the SCSI driver as
a first step or correspond with Gerd Knorr, Thomas Quinot and the other
SCSI CDROM driver developers about it. An addition to <linux/cdrom.h>
with an exact parameter description and an email reference could be the
starting shot.
But: it will not be possible to do a successful open() call (which is
necessary to commandeer an IOCTL) if there is no disk in the drive. The
status information "empty drive" and/or "open tray" has to get obtained
from the return code of a failing open(). Opening/closing the tray
without having a disk in is possible as a standard behavior of a failing
open() request. Most of the drivers still need to get "trimmed" to a
solid behavior during failing open() requests.

Cheers -e

-- 
Eberhard Moenkeberg                                GGG   W   W  DDDD    GGG
                                                  G      W   W  D   D  G
E-Mail:   emoenke@gwdg.de                         G GGG  W   W  D   D  G GGG
Phone: +49 551 2011551  Fax: +49 551 21119        G   G  W W W  D   D  G   G
SnailMail:                                         GGG   WW WW  DDDD    GGG
Gesellschaft fuer wissenschaftliche Datenverarbeitung mbH
Am Fassberg, D-37077 Goettingen, GERMANY
At home: Modem+ISDN ("guest") ++49-551-7704102, ISDN-HDLC 7704103