# how do I get udev to set /dev/sg0 (scanner) correctly ?

## yfh2

I have an Umax Astra scsi scanner, which uses the module aic7xxx

The scanner is attached to /dev/sg0

Problem is : after boot, the perimssions are set uncorrectly

```

crw-rw----  1 root root 21, 0 aoû 16  2003 /dev/sg0

```

Udev rules are set like this regarding 'sg' devices :

```

grep sg /etc/udev/rules.d/50-udev.rules

BUS=="scsi",    KERNEL="sg[0-9]*", ACTION=="add", DRIVER=="sr", GROUP="cdrom", MODE="0666"

```

First thing is : MODE and GROUP are not taken into account ...

Second is : why should I have my scanner device in cdrom group ?

Third : I load the module aicxxx at boot time, and I get plenty of weird messages (I don't know where to find the log) by udev, waiting for several devices (or else) to answer ...

Now : what should I do ?

----------

## lost+found

 *yfh2 wrote:*   

> I have an Umax Astra scsi scanner, which uses the module aic7xxx
> 
> ...
> 
> Third : I load the module aicxxx at boot time, and I get plenty of weird messages (I don't know where to find the log) by udev, waiting for several devices (or else) to answer ...
> ...

 

There's a bug in the aic7xxx scsi driver. If you downgrade to a 2.6.13 or older kernel, it should work again... 

https://forums.gentoo.org/viewtopic-t-429277-start-0-postdays-0-postorder-asc-highlight-.html

http://bugzilla.kernel.org/show_bug.cgi?id=5659

 Cheers.

----------

## yfh2

My kernel is 2.6.10, so truth should be elsewhere ...

----------

## yfh2

I have tried to replace the rule with

[code]

BUS=="scsi",    KERNEL="sg0", MODE="0666" 

[/code]

I also tried to restrict to 

[code]

BUS=="scsi",  SYSFS{type}="6",    KERNEL="sg0", MODE="0666" 

[/code]

But somehow, udev does not seem to take the rule into account.

I always end up with permissions set as 660 :-(

Any idea ?

----------

## yfh2

Hello ...ooo...oo..o ? Anyone there ... ere ... er .... r ... ?

----------

## PCanavan

I use /dev/scanner, with the following in my /etc/udev/rules.d/10-local.rules:

```

# permissions for SCSI scanner

BUS=="scsi", SYSFS{model}=="Perfection1200", NAME="%k", SYMLINK="scanner", MODE="0660", GROUP="scanner"

```

Obviously, if you don't have an Epson Perfection 1200S then you'll need to change the SYSFS{model} bit.

----------

## yfh2

Well, I have tried that (and many other things), but no game.

I can see that udev creates /dev/sg0, but it absolutely refuses to follow any rule about it.

There is nothing in the regular 50-udev.rules about /dev/sg* , and nothing in other .rules file.

I'm stumped

----------

## lbrtuk

I use

```
BUS=="scsi", sysfs{type}=="6", GROUP="scanner"
```

in my udev rules to catch all scsi scanners ('type' 6). Works a charm.

----------

## yfh2

Yes ... sigh

What I'd like to know is why it does not work on my box 

Anyone for pointing me where to start looking, like udevd log or something ? (I did not find the log, for a start)

----------

## PCanavan

You can turn on udev logging via /etc/udev/udev.conf:

```

# udev_log - set to "yes" if you want logging

udev_log="no"

```

Only found it this weekend whilst trying to get my Freecom DVB to work (<sigh>), so don't know if it'll give you anything of use. There's also a utility which will dry-run your uDev rules, but can't remember what it's called. Have a look in /var/db/pkg/sys-fs/udev*/CONTENTS for a likely suspect, or search the web. Might be closer to what you want (or might not...).

To keep the rest of us happy, when you say adding a new rule doesn't work on your machine, do you mean you don't get the device, the permissions on that device aren't set correctly, or you just can't use the device? Do you have a copy of the line that you actually added to your rules?

----------

## yfh2

Thanks for your tips. I'll dig into the udev installed files.

As for the rest :

1) It was obvious to me, but I should have mentionned it : "udev_log" was already set to 'yes'

-> Where is the log ???

2) If you just feel like reading some lines above in the thread, you will make out that :

    - I have the device, and getting it working by udev

    - However, whatever ruleset (pls read above) in xx_zzz.rules, it is ignored by udevd (like GROUP, MODE, SYMLINK, 

      etc ...)

----------

## musv

I think I have the contrary problem. In my box I'm using an AHA-2940 with the same driver (aic7xxx). And last night after many months I wanted grab a cd, but none of the installed burn apps wanted to find my CD-Writer (Plextor PX-W1210S). 

Usually I get read access to the cd drives with my own udev-rules and own device names. But the burn apps didn't use these device names. So I grabbed the cd directly with cdrecord without front end. 

cdrecord -scanbus gives me in Knoppix (Kernel 2.6.12):

```

Using libscg version 'ubuntu-0.8ubuntu1'.

scsibus0:

        0,0,0     0) *

        0,1,0     1) *

        0,2,0     2) *

        0,3,0     3) 'PLEXTOR ' 'CD-ROM PX-40TS  ' '1.14' Removable CD-ROM

        0,4,0     4) 'PLEXTOR ' 'CD-R   PX-W1210S' '1.06' Removable CD-ROM

        0,5,0     5) *

        0,6,0     6) 'SCANNER ' '                ' '2.02' Scanner

        0,7,0     7) *

```

and in Gentoo (Kernel 2.6.15-r7 and 2.6.16)

```

        0,0,0     0) *

        0,1,0     1) *

        0,2,0     2) *

        0,3,0     3) *

        0,4,0     4) *

        0,5,0     5) *

        0,6,0     6) 'SCANNER ' '                ' '2.02' Scanner

        0,7,0     7) *

```

The only device I can get access through the scsi generic devices is the Scanner. CD Drives are not accessable with /dev/sg* or /dev/sr*. I can't remember exactly the last working Kernel version of this driver. Maybe 2.6.13 or 2.6.14..

----------

## PCanavan

To answer yfh:

1) the uDev log lines seem to go to the kernel message log - /var/log/messages unless you've got a weird setup.

2) my suggestion was for creating a new device node (symlink) with the right permissions, not for using sg0 with "the right" permissions. Wanted to know if you'd also tried this before to no effect.

Only trying to be helpful.

----------

## yfh2

1) grep udev /var/log/messages return nothing

/etc/udev/udev.conf is :

```

# /etc/udev/udev.conf:  main config file for udev

# $Header: /var/cvsroot/gentoo-x86/sys-fs/udev/files/udev.conf.post_059,v 1.1 2005/07/03 07:11:11 gregkh Exp $

#

# This file can be used to override some of udev's default values

# for where it looks for files, and where it places device nodes.

# udev_root - where in the filesystem to place the device nodes

udev_root="/dev/"

# udev_db - The name and location of the udev database.

#           NOTE: this should be somewhere that is writable before

#                 / is mounted rw, like /dev ...

udev_db="/dev/.udevdb"

# udev_rules - The name and location of the udev rules file

udev_rules="/etc/udev/rules.d/"

# udev_log - set to "yes" if you want logging

udev_log="yes"

```

2) Of course I have tried symlink ... and it does not work.

Last : for some reason, the device sg0 does not appear in the database (/dev/.udev/db/)

(and neither the /dev/sda1 for usb key, which works)

----------

