I’ve just uploaded to unstable a new revision of SANE which fixes the longstanding SCSI interface problem in 32/64bit mixed environments. If you own a SCSI scanner, please read on and give it a go.
For the past several years, it wasn’t possible to scan using a SCSI scanner if you were running a 64bit kernel and a 32bit userland. The sg_hdr struct, which is the base of the Linux SG3 interface, contains pointers (you see that coming, right?) so its size obviously differs in 32bit and 64bit mode; and a 32bit pointer is kind of useless as-is for a 64bit kernel. The SG3 asynchronous interface (read/write calls on /dev/sgX) does not handle the 32/64bit conversion and returns an error while sanity checking the sg_hdr struct passed to it.
Hopefully, the SG_IO ioctl interface, also part of SG3 and now generalized to every SCSI device (not limited to /dev/sgX), uses the same sg_hdr struct with the added bonus that the ioctl 32bit compat layer built into the kernel converts the 32bit sg_hdr it gets from userland to a 64bit sg_hdr it passes on to the 64bit ioctl handler, and back again.
Only difference, the SG_IO ioctl interface is synchronous, whereas the read/write interface is asynchronous and thus allows command queueing. So SANE (sanei_scsi) now has lost its command queueing feature but it looks like (after testing) it wasn’t making any difference anymore.
This problem affects users on the following architectures, when running a 64bit kernel with a 32bit userland: i386/amd64, MIPS, MIPSel, SPARC, PowerPC, ia64. That makes for an important part of our supported architectures.
If you own a SCSI scanner, here’s a test you can do: scan using the current version of SANE in unstable (1.0.19~cvs20070505-2), then with the new, patched version (1.0.19~cvs20070505-3) and report back if:
- the scanner backtracks more than it does with the previous version
- you see weird errors OR you see no error and you should be seeing some
- performance sucks
- the resulting image is broken in one way or another
If all goes well, this patch will make it into SANE upstream RSN.