Re: Exclusive access to block devices

Grant R. Guenther (grant@gear.torque.net)
Mon, 6 May 1996 11:05:10 -0400 (EDT)


Bernd Eckenfels wrote:
> Grant R. Guenther <grant@gear.torque.net> wrote:
> > 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.)
>
> You can use O_EXCL in conjunction with fstat(). The generic SCSI driver
> seems to support that. Problem may be root access, not sure if it works, but
> thats what the flag is for :)

Really ?

The documented function of this flag is something entirely different:
it causes a creat() to fail if the file already exists. Thus, it can
be used to implement simple application level locking, but that's not
what we are looking for.

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