[sane-devel] SCSI problems with avision backend

Henning Meier-Geinitz henning at meier-geinitz.de
Fri Apr 12 17:06:03 BST 2002


Hi,

On Thu, Apr 11, 2002 at 11:58:21PM -0400, Douglas Gilbert wrote:
> If you open an sg device with O_EXCL and it is already open
> then:
>   - if O_NONBLOCK is also set then the open() will fail
>     with EBUSY
>   - otherwise you will wait (interruptible) until the existing
>     open()s on that device are close()d.

Ok, that sounds reasonable. I was just a bit surprissed because I
thought we gor EBUSY until some time ago.

> All scsi bus scans done using sg should use O_NONBLOCK else
> they run the risk of hanging on somebody else's O_EXCL lock.

So we would change sanei_scsi.c line 1113

  fd = open (dev, O_RDWR | O_EXCL);
  
to

  fd = open (dev, O_RDWR | O_EXCL | O_NONBLOCK);

? 

Does this work with the other operating systems also. Or to be more
exact, O_NONBLOCK compiles everywhere? The man page suggests that it's
not Linux-specific.

Maybe we should also return SANE_STATUS_DEVICE_BUSY on EBUSY.

Bye,
  Henning



More information about the sane-devel mailing list