LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (http://www.linuxquestions.org/questions/slackware-14/)
-   -   Udev rule required for scsi scanner (http://www.linuxquestions.org/questions/slackware-14/udev-rule-required-for-scsi-scanner-490305/)

samac 10-07-2006 07:27 AM

Udev rule required for scsi scanner
 
BACKGROUND

I only use the scanner (UMAX Astra 1200S) occasionally and the scsi module aic7xxx takes around 20 seconds to auto detect on boot, so I do not load it on boot.

scsi scanners either have to be turned on at boot or detected with rescan-scsi-bus (root priveledges required).

I do not want other users to have the root password, so I used to use the following method.

The user would run the shell script "use_scanner" this calls a script "scanner" and then "xsane". The script "scanner" runs sudo and modprobes the scsi card then rescans the bus. xsane then runs as a normal user in the scanner group.

To enable this to work /dev/sg0 had to have been changed to owner root:scanner

PROBLEM

udev creates /dev/sg0 root:root automatically when the scsi bus is scanned. As it is not a persistent device I cannot chown it.

POTENTIAL WORK AROUNDS

---------------------------------------------

I have tried to create a udev rule in /etc/udev/rules.d/10-local.rules using udevinfo but to tell you the truth I don't relly understand udev yet.

Quote:

bash-3.1$ udevinfo -a -p /sys/class/scsi_generic/sg0

Udevinfo starts with the device specified by the devpath and then
walks up the chain of parent devices. It prints for every device
found, all possible attributes in the udev rules key format.
A rule to match, can be composed by the attributes of the device
and the attributes from one single parent device.

looking at device '/class/scsi_generic/sg0':
KERNEL=="sg0"
SUBSYSTEM=="scsi_generic"
DRIVER==""
SYSFS{dev}=="21:0"

looking at parent device '/devices/pci0000:00/0000:00:0c.0/host0/target0:0:6/0:0:6:0':
ID=="0:0:6:0"
BUS=="scsi"
DRIVER==""
SYSFS{ioerr_cnt}=="0x0"
SYSFS{iodone_cnt}=="0x6"
SYSFS{iorequest_cnt}=="0x6"
SYSFS{iocounterbits}=="32"
SYSFS{timeout}=="0"
SYSFS{state}=="running"
SYSFS{rev}=="V1.4"
SYSFS{model}=="Astra 1200S "
SYSFS{vendor}=="UMAX "
SYSFS{scsi_level}=="3"
SYSFS{type}=="6"
SYSFS{queue_type}=="none"
SYSFS{queue_depth}=="2"
SYSFS{device_blocked}=="0"

looking at parent device '/devices/pci0000:00/0000:00:0c.0/host0/target0:0:6':
ID=="target0:0:6"
BUS==""
DRIVER==""

looking at parent device '/devices/pci0000:00/0000:00:0c.0/host0':
ID=="host0"
BUS==""
DRIVER==""

looking at parent device '/devices/pci0000:00/0000:00:0c.0':
ID=="0000:00:0c.0"
BUS=="pci"
DRIVER=="aic7xxx"
SYSFS{modalias}=="pci:v00009004d00005078sv00009004sd00007850bc01sc00i00"
SYSFS{local_cpus}=="1"
SYSFS{irq}=="11"
SYSFS{class}=="0x010000"
SYSFS{subsystem_device}=="0x7850"
SYSFS{subsystem_vendor}=="0x9004"
SYSFS{device}=="0x5078"
SYSFS{vendor}=="0x9004"

looking at parent device '/devices/pci0000:00':
ID=="pci0000:00"
BUS==""
DRIVER==""
---------------------------------------------

There appear to be persistent devices in /lib/udev/devices that are copied to /dev when rc.udev is started. Is this the case, and if so would it be safe to create a new sg0 device here?

---------------------------------------------

What suggestions/fixes would you do?

Samac

marnold 10-07-2006 09:40 AM

I don't have a scanner to test this rule with, but something like this should work. Add it to your 10-local.rules:

BUS=="scsi", KERNEL=="sg*", SYSFS{model}=="Astra 1200S ", GROUP="scanner"

If you really wanted to get cool you could add this to the end:

SYMLINK+="scanner"

This would create /dev/scanner as a symbolic link pointing to /dev/sg0. The benefit is that /dev/scanner will always work, even if you add more SCSI devices later. Check Writing udev Rules for more details.

samac 10-07-2006 10:32 AM

Many thanks marnold that worked fine.

The mistakes I made.

BUS=="scsi", KERNEL=="sg0", SYSFS{Model}=="Astra 1200S ", GROUP="scanner"

As you can see I tried to specify the device to sg0, I don't know if that was a mistake.

I had model with a capital M (definite mistake).

I also think I had KERNEL as the third item (don't know if that would be a problem).

Thanks again.

Samac


All times are GMT -5. The time now is 03:55 AM.