This is a repost of an answer I provided to my own identical question on the Unix & Linux site titled: How can I disable the button of my CD/DVD drive?.
The problem is definitely caused by UDEV as you've guessed. The issue is this line that is in most UDEV files related to the cdrom drive.
Example
On Fedora 19 there is the following file, /usr/lib/udev/rules.d/60-cdrom_id.rules
. In this file is the following line which is co-opting the eject button for CD/DVD devices.
ENV{DISK_EJECT_REQUEST}=="?*", RUN+="cdrom_id --eject-media $devnode", GOTO="cdrom_end"
You can work around the issue and disable UDEV's ability to co-opt the eject button by doing the following:
Make a copy of the file 60-cdrom_id.rules
$ sudo cp /usr/lib/udev/rules.d/60-cdrom_id.rules /etc/udev/rules.d/.
Edit this copied version of the file and comment out the line containing the string, DISK_EJECT_REQUEST
.
$ sudoedit /etc/udev/rules.d/60-cdrom_id.rules
Save the file and the change should be noticeable immediately!
The above solution fixes the problem for both eject
and cdctl
. So now the following commands work as expected:
lock the drive
$ eject -i on /dev/sr0
eject: CD-Drive may NOT be ejected with device button
-or-
$ cdctl -o1
unlock the drive
$ eject -i off /dev/sr0
eject: CD-Drive may be ejected with device button
-or-
$ cdctl -o0
cdctl -o
orcdctl --lockdoor
(cdctl website).cdctl -o
expects a numeric argument. I tried 0 and 1, both do not lock the door. I also triedeject -i 1 /dev/sr0
andecho 1 > /proc/sys/dev/cdrom/lock
as root and manually sending a CDROM_LOCKDOOR ioctl to the device. Nothing seems to work.