[sane-devel] rules for scsi scanner

Klaus Dahlke klaus.dahlke at gmx.de
Tue Dec 13 20:55:27 UTC 2005


On Tue, 13 Dec 2005 17:38:14 +0000
Tony van der Hoff <lists at nospam.vanderhoff.org> wrote:

> Hi list,
> 
> I have a UMAX scanner in the SCSI bus, which is correctly detected as
> /dev/sg3. The .udevdb entry for this device is:
> 
> P:/class/scsi_generic/sg3
> N:sg3
> S: scsi/host1/bus0/target5/lun0/generic
> M:21:3
> A:0
> R:0
> 
> On boot /dev/sg3 is assigned to group cdrw. I have to manually chgrp it to
> scanner, to allow designated users to access it.
> 
> I have been fiddling for days now to set up a udev rule to automatically
> assign it to the correct group, but without success. I'm also slightly
> concerned that after any configuration change it may not come up as
> /dev/sg3, so would really prefer it to be called /dev/scanner.
> 
> Given my miserable failure to learn udev rules, has anyone out there cracked
> the code? How's it done?
> 
> TIA, Tony
> -- 
> Tony van der Hoff          | mailto:tony at vanderhoff.org

Hi Tony,
here is what do to have my scanner working. It is an Umax Astra 220 linked via SCSI on a Tekram 395 (no bios). System is a gentoo with kernel 2.6.12 on an amd64. As I use the scanner only rarely (usually scanner is switched off at boot) I do/did the following: 

- during boot I load already the dc395x kernel module

- I have an udev rule (filename: 10-udev-rules) to make sure it is loaded before the standard udev rules:
BUS=="scsi", SYSFS{model}=="Astra 2200      ", NAME="scanner", GROUP="scanner"
The rules creates a device called /dev/scanner/ with group 'scanner'. Users belong to group scanner. Device is only created after switching on and accessing the scanner.

- I put a kind of wrapper script around xsane: I start xsane with the command 'xsane-start':
#!/bin/sh
if [ `grep -c UMAX /proc/scsi/scsi` = 0 ] ; then
   sudo /usr/local/bin/add_to_scsi
fi
exec xsane

The script 'add_to_scsi' insert the proper line to /proc/scsi/scsi so that xsane detect the scanner:
#!/bin/sh
channel=`dmesg | grep 395 | grep scsi | tail -n 1 | cut -c 5`
/bin/echo "scsi add-single-device $channel 0 1 0" > /proc/scsi/scsi

Finally, I edited '/etc/sudoers' to get the sudo command above working without password.

After switching the scanner on, it takes a little moment for scanner detection, but it works fine

HTH and good luck,
Klaus




More information about the sane-devel mailing list