mounted cd and tray locking

Andriy Gapon avg at
Thu Dec 13 02:39:54 PST 2007

on 13/12/2007 12:28 Andriy Gapon said the following:
> on 13/12/2007 12:13 Nikos Vassiliadis said the following:
>> On Thursday 13 December 2007 11:42:00 Andriy Gapon wrote:
>>> on 13/12/2007 09:30 Nikos Vassiliadis said the following:
>>>> I have no atapicam in my kernel. Nor hald running.
>>>> I reproduced it like this:
>>>> mount /cdrom
>>>> cdcontrol eject
>>> I don't think you reproduced it. Why would you execute the above command
>>> unless it is your intention to eject the disk ?
>> You got it wrong. cdcontrol *does not* eject the disk, it works
>> correctly, as it should. cdcontrol never ejects mounted media.
> Well, I got it right, it's just that in my opinion you knew what you
> were doing.
>> It triggers the situation where I can then press the eject key
>> on the cdrom and really eject the cdrom.
> It would be interesting to see what exact ioctls/commands cdcontrol
> issues. ktrace+kdump can help with this. Assuming your drive is ATAPI
> (not SCSI) then if only CDIOCEJECT is issued then the drive should not
> become unlocked.

Tried this myself:
 11991 cdcontrol CALL  open(0x7fffffffe130,0,0x9)
 11991 cdcontrol NAMI  "/dev/acd0"
 11991 cdcontrol RET   open 3
 11991 cdcontrol CALL  ioctl(0x3,CDIOCALLOW,0)
 11991 cdcontrol RET   ioctl 0
 11991 cdcontrol CALL  ioctl(0x3,CDIOCEJECT,0)
 11991 cdcontrol RET   ioctl -1 errno 16 Device busy
 11991 cdcontrol CALL  exit(0xffffffff)

It is a question for me how atapi-cd should behave on CDIOCALLOW command
issued on an opened disk (by something other than the entity doing
ioctl, i.e. geom acr > 1). Maybe it should work the same way as for
CDIOCEJECT, maybe geom ace should be taken into account somehow.
Part of me says: do not allow unlocking tray if something is mounted,
the other part says: let user do what he wants.
Maybe the easiest solution here is to change cdcontrol to do only

Andriy Gapon

More information about the freebsd-questions mailing list