Exclusive access to block devices

Grant R. Guenther (grant@gear.torque.net)
Fri, 3 May 1996 08:35:54 -0400 (EDT)


A friend and I are working on a program to access Iomega's special features
for the ZIP drive. It's easy enough to use the SCSI_SEND_COMMAND ioctl
to actually do the things we need from a user mode program, but these
ioctls are things that should not be done when the drive is otherwise
in use. There doesn't appear to be any general way to specify that an
ioctl should only be executed if the access count is == 1, or to
test that a block device is not mounted or otherwise open ... (While
an absolute race-free lock would be nice, a simple busy test would be
adequate for the application.)

My friend wants to add the new ioctls into scsi_ioctl.c, but I'm arguing that
vendor-specific functions ought not to be in the kernel.

I feel certain that I'm missing something obvious - anyone care to enlighten
me ? :-)

Should we have a general low-level "lock this device for exclusive use"
ioctl for all block devices ? The access counters required to implement
it are all there already.

--------------------------------------------------------------------------
Grant R. Guenther grant@torque.net
--------------------------------------------------------------------------