[sane-devel] attach function status?

Dave Close dclose@anim.dreamworks.com
Wed, 01 May 2002 11:09:28 -0700


The sanei_config_attach_matching_devices() function returns void. This
seems to imply that the internal attach() function, which is called
by the sanei library, has no way to return status to a frontend. Sure,
it can put a message in the debug log, but that's not the same thing.

I'm dealing with a SCSI backend using the Linux sg (generic SCSI)
interface. The scanner is not always present on the SCSI bus, and when
present is not the last SCSI device discovered. This means that the
device name, /dev/sg?, usually used by the scanner, may be assigned to
a different device when the scanner is not attached. The other device,
usually a disk, has different permissions, and attach() fails.

The usual sequence of operations in most backends is to call
sanei_config_attach_matching_devices() in the sane_init() function.
Because it cannot return status while sane_init() can, sane_init()
lies to the frontend and always returns SANE_STATUS_GOOD. Then when the
frontend tries to call sane_open(), there is no valid device name and
sane_open() reports SANE_STATUS_INVALID. This is misleading at best.

Is there a better way to handle this situation?
-- 
Dave Close                    Dreamworks SKG, Animation Technology
+1 818 695 6962               Glendale California 91201-3007
dclose@anim.dreamworks.com    http://www.dreamworks.com/