1. What is This?
cdlock includes utilities for locking and unlocking the door of your CD/DVD drives. Once the door is locked, you should not be able to eject the tray by pressing the 'Eject' button located at the front side of the drive (even the tray is empty). It works on Linux with 2.6.x kernel.
Scroll down for technical notes. I implemented this to guard my DVD drive!
2. Source Code
cdlock-0.1.tar.bz2To install it, simply do:
\$ make && sudo make install
The code is distributed under the terms of GPL.
3. Usage
To lock the door of a CD/DVD drive:
\$ cdlock [<device>]
The program assumes /dev/cdrom by default. The program returns zero if and only if it does not detect any error.
To unlock the door:
\$ cdunlock [<device>]
4. Technical Notes
The program is so simple and it basically does an ioctl() with CDROM_LOCKDOOR. I write this because I fail to find a handy utility just to do this simple task. Tell me if you are aware of any utility that has included this feature, or you want to include this program under the umbrella of a more sophisticated and GPL-compatible software.
I have tested the program with three CD/DVD drives. All of them work in the sense that, once I have run the utility to lock the door, the function of the 'Eject' button is virtually disabled. However, there are some weird behaviors I do not understand yet:
- On some computers, the
ejectcommand fails to eject the tray after I have locked the door. Good. But while I expectejectto return 1 since the operation has failed, it returns 0 instead. Is it a feature or a bug? - I use DVD writers of the same model (LITE-ON DVDRW SOHW-1673S) on two different computers instead with Ubuntu 7.10. After locking the drives' doors, I can
ejectsuccessfully on one computer but fail on another. Why is it so? I don't think I have change any setting related to the drives. Is there anything to do with the IDE cables?
Tell me if you know the answers.

