Note that multiple file descriptors may be open to the same SCSI device.
[This is a way of side stepping the SG_MAX_QUEUE limit.] At the sg level
separate state information is maintained. This means that even if
multiple file descriptors are open to a single SCSI device their
write() read() sequences are essentially independent.
Open() calls may be blocked due to exclusive locks (i.e. O_EXCL). An
exclusive lock applies to a single SCSI device and only to sg's
use of that device (i.e. it has no effect on access via sd, sr or st
to that device). If the O_NONBLOCK flag is used then open() calls
that would have otherwise blocked, yield EBUSY. Applications that
scan sg devices trying to determine their identity (e.g. whether
one is a scanner) should use the O_NONBLOCK flag otherwise they
run the risk of blocking.
The driver will attempt to reserve SG_DEF_RESERVED_SIZE bytes (32KBytes in
the current sg.h) on open(). The size of this reserved buffer can
subsequently be modified with the SG_SET_RESERVED_SIZE ioctl(). In both
cases these are requests subject to various dynamic constraints. The actual
amount of memory obtained can be found by the SG_GET_RESERVED_SIZE ioctl().
The reserved buffer will be used if:
Returns a file descriptor if >= 0 , otherwise -1 implies an error.