Why would I like to lock the cdrom driver from manual open?
This is a handy feature because often you press the eject button of your cd-drive by fault and your cdrom opens while it's not expected to do so. The only 'traditional' way is to put a cd in the drive and mount it.
So I thought why not lock the drive while there is NO cd in it?
How to do that?
It's very easy:
int lock; ioctl(fd, CDROM_LOCKDOOR, lock);
This is the linux-kernel API for locking. I implemented it into eject, see below.
Read on here: /usr/src/linux/Documentation/ioctl/cdrom.txt
patchng eject -> eject-2.1.5.diff
Copy the eject-2.1.5.diff to /tmp/eject and patch the software using:
cd /tmp/eject cat eject-2.1.5.diff | patch -p0 eject.c
The result should look like this:
joachim@Z3:/tmp/eject 18 $ cat eject-2.1.5.diff | patch -p0 eject.c patching file eject.c
Next compile and install it.
With some luck this patch may be integrated in the upcoming eject version.
How to enable the lock?
joachim@Z3:~ $ eject -i on /dev/cdrom CD-Drive may NOT be ejected with device button
The lock will be overwritten using any program to eject the CD via the kernel API so you might have to set the lock again.