This kernel loadable module emulates all proc filesystem files and devices that is needed to run linux program using scsi Scanner Access Now Easy - SANE interface.
The source can be found from the http://www.iki.fi/kivinen/lsc/lsc-1.2.tar.gz . There is also README file, that contains same information than this html page.
It supports three different devices:
When it is loaded it automatically creates those devices under the /emul/linux tree, and when it is unloaded it removes all devices it created.
The /proc/sys/kernel/sg-big-buff device is used to read the maximum transfer size between kernel and user mode program. The default value is 128kB - 512 = 130560 bytes. This is supposed to be maximum value allowed by the linux kernel.
The /proc/scsi/scsi device lists information about devices connected to the scsi buses. Say cat /emul/linux/proc/scsi/scsi to see what kind of information it returns.
When the module is loaded it detects all scsi scanners connected to any of the buses, and creates /dev/sg0 device for the first scanner, and /dev/sg1 for the next etc. By default the driver supports 8 scanners, but this can be configured to be larger if needed by changing the LSC_MAX_SCANNERS define in the beginning of the linux_sanei_compat.c.
The scanners are attaced in the order they appear in the scsibuses, starting from the lowest scsi bus, target 0, lun 0 and then going up from there.
When /dev/sg* device is opened the module allocates memory buffers for incoming and outgoing data transfer and starts reading linux sg_header structures from the device. When it receives one it sends the command to real scsi device and writes sg_header packet back to user level. Current driver only supports one concurrent operation per device.
Then you can test the module by loading it to kernel with command "modload lsc.o". It should print out its version number to console and also print the number of scsi scanners it found. Then check that the scsi probe system is working properly by saying "cat /emul/linux/proc/scsi/scsi". That file should contain all scsi devices you have connected to all busses.
To unload the driver you need to first find out the Id number of the module by using the "modstat" command and then you can unload the module by "modunload -i xxx" command. In normal case the Id number of the module is 0, so "modunload -i 0" should work.
If you want to load the module automatically when the machine is booted, copy the lsc.o to /lkm directory and then add "/lkm/lsc.o - - - - -" line to the /etc/lkm.conf. Also make sure that the /etc/rc.conf file has "lkm=YES" line.
Tero Kivinen
<kivinen@iki.fi>
http://www.iki.fi/kivinen/lsc/