There's a number of things that never fail to amaze me. One of them is the
ioctl(2) system call. It should really be a rather plain thing: first argument is always a file-descriptor, second one always the operation to carry out and then some additional arguments that pass and retrieve the data related to the intended operation.
I was experimenting with the various controls concerning a CDROM drive. So I opened
/dev/cdrom (which is a symlink to
O_READ|O_NONBLOCK and threw a
CDROMREADRAW at the drive. Most of the time it complained about bad arguments so I played a little with the third argument to ioctl which - according to
ioctl_list(2) - should be a
struct cdrom_read_audio* (but nowehere it is said how this structure should be initialized). And indeed, after some attempts it seemed to do something.
Interestingly, the control light of my CDRW drive (which is
/dev/hdc) lid up. The one of the drive that I opened remained dark. Nonetheless, both drives were blocked and the light of the writer happily kept burning. The only way to put things back to normal was actually a reboot. Very strange.
The whole thing very much reminds me of accessing my soundcard via
ioctl. I needed a couple of google-sessions to get it right. The same thing is now required for the cdrom thing, I guess.