Re: Lock drive



Hi,

Lelouch the Kid:
If you guys could explain to me how the lock drive works and how can I do
that, I would be eternally grateful.

Joerg Schilling:
Just call 
        cdrecord -lock

This is not enough didactical effort to gain eternal gratitude.

At the lowest level which is in reach for us, the tray locking is
done by SCSI command 0x1E PREVENT ALLOW MEDIUM REMOVAL. It is
documented in volume SPC of the SCSI specs. E.g. SPC-3.
Lock:    1E 00 00 00 01 00
Unlock:  1E 00 00 00 00 00

Afaik, this has no effect on laptop drives with no tray motor.

On e.g. Linux we transport this command to the drive by ioctl(SG_IO).
See struct sg_io_hdr in /usr/include/scsi/sg.h.

Further there is a Linux ioctl(CDROM_LOCKDOOR).

On library level i could offer libburn's function burn_drive_scan_and_grab()
for locking the tray
  http://libburnia-project.org/browser/libburn/tags/1.3.6/libburn/libburn.h#L882
and burn_drive_leave_locked() for leaving it locked
  http://libburnia-project.org/browser/libburn/tags/1.3.6/libburn/libburn.h#L1208
The demo program test/libburner.c may be used starting template for
libburn applications
  http://libburnia-project.org/browser/libburn/tags/1.3.6/test/libburner.c

On shell command level there is already Joerg's proposal.
I know several systems where the lock does not survive the end of
the program run, though.
Interestingly, the program "eject" can break the lock but does not
offer an option to set one.


Have a nice day :)

Thomas



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]