Subject: Re: CD control commands
To: Manuel Bouyer , <tech-kern@netbsd.org>
From: Peter Fairbrother <peter.fairbrother@ntlworld.com>
List: tech-kern
Date: 10/07/2001 13:35:39
> Manuel Bouyer wrote:

> On Sun, Oct 07, 2001 at 07:13:52AM +0100, Peter Fairbrother wrote:
>> Hi, I hope this is not too OT, perhaps someone here can help:
>> 
>> Does anyone know where the controls for a CD player are in source, or how
>> they work? I want to arrange things so that if the eject button on the CD
> 
> The driver is in sys/dev/scsipi/cd.c

Thanks. 

>> player is pressed the box will power down immediately, whether or nor the CD
>> is mounted. 
> 
> I don't think this is possible. I'm not sure at all the CD has a way to
> report whenever the eject button has been pressed or not.

Oh dear.  I took a look at cd.c , and it looks like you may be right :(
Thanks anyway. 

Perhaps a cron daemon could detect (in timely fashion) that the cd had been
ejected, if the drive was mounted but not locked? Hmmm... The CD is being
read pretty nearly continuously anyway, as part of a high-volume rng, and
for verification purposes...  Back to the drawing board!

> There is a command which prevents ejecting the CD (the LOCK command);
> the cd driver uses it.
>
> You may be able to do what you want in hardware though; if you can disconnect
> the eject switch from the CD circuitery and connect it in place of the ATX
> power switch.
> Or maybe just remove the eject button ?

It's for a public program <www.m-o-o-t.org> to be used on many machines, so
regrettably that wouldn't be practical :)

-- Peter