LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices

Reply
 
LinkBack Search this Thread
Old 10-07-2006, 07:27 AM   #1
samac
Senior Member
 
Registered: Mar 2004
Location: Westray, Orkney
Distribution: Slackware64-14.1 (multi-lib) KDE 4.11.4
Posts: 1,399

Rep: Reputation: 131Reputation: 131
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

Last edited by samac; 10-07-2006 at 08:02 AM.
 
Old 10-07-2006, 09:40 AM   #2
marnold
Member
 
Registered: Dec 2005
Distribution: Slackware64 14.1
Posts: 249

Rep: Reputation: 32
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.
 
Old 10-07-2006, 10:32 AM   #3
samac
Senior Member
 
Registered: Mar 2004
Location: Westray, Orkney
Distribution: Slackware64-14.1 (multi-lib) KDE 4.11.4
Posts: 1,399

Original Poster
Rep: Reputation: 131Reputation: 131
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
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
udev-Rule for Mobile tuxangler Linux - Hardware 1 03-28-2006 05:41 AM
Making a udev rule for sonypi blimbo Linux - Software 4 03-01-2006 07:48 PM
Wrong group with custom udev rule enragedchip Linux - Hardware 1 12-11-2005 02:46 PM
Issues with adding a udev rule... Ateo Linux - General 1 03-04-2005 08:02 PM
Hotplug SCSI scanner or How to write to /proc/scsi/scsi from within a shell script. samac Linux - Hardware 1 08-30-2004 02:28 PM


All times are GMT -5. The time now is 01:38 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration