Re: Mapping /dev/*st0* to fixed names using scsi_id

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



>>>>> "John" == John Stoffel <john@xxxxxxxxxxx> writes:

John> I've been pounding my head against this issue for a while, and
John> cursing the lack of comments in the example rules for udev.

I'm still cursing, but I've been reading the docs over and over again
and I've come up with some ideas.

Basically, I need to map my tape device to a scsi_generic device, so
I can then run '/lib/udev/scsi_id --whitelisted --export --device=%k'
on the generic device, to get back a useable $ID_SERIAL that I can use
to match.

I hit upon the idea of using the following as a basic match:

    # Find SCSI_TAPE devices, export SCSI_ID env in "#:#:#:#" format 
    SUBSYSYEMS=="scsi",ATTRS{type}=="1",ENV{SCSI_ID}="%k"

    # Wait for SCSI_ID, then get the /dev/sg# for this tape
    SUBSYSYEMS=="scsi",ATTRS{type}=="1",WAIT_FOR="$env{SCSI_ID}", \
      IMPORT{program}="/lib/udev/sg_dev $env{SCSI_ID}"  

    # Wait for SG_DEV, then get the /dev/sg# for this tape
    SUBSYSYEMS=="scsi",ATTRS{type}=="1",WAIT_FOR="$env{SG_DEV}", \
      IMPORT{program}="/lib/udev/scsi_id --replace-whitespace
      --whitelisted --export --device=$env{SG_DEV}"  

    # Wait for ID_SERIAL and then name the tape device
    SUBSYSYEMS=="scsi",ATTRS{type}=="1",WAIT_FOR="$env{ID_SERIAL}", \
      ENV{ID_SERIAL}=="SQUANTUM_DLT7000_CX752S1059", SYMLINK="dlt7k-left"


And the /lib/udev/sg_dev script is just the trivially simple, but hard
to do (to me at least) in udev script:

    #!/bin/sh

    lsscsi -g $1 | awk '{print "SG_DEV=" $NF}'


BUT!  This doesn't quite address all the issues, since I really need
to have some way to create symlinks to a bunch of /dev/st#[alm ]
devices, and I'm not sure how to do this.  

Any hints?  


I've also tried looking at the output of 

  udevadm info -a -p /sys/class/scsi_tape/st0 > /tmp/st0
  udevadm info -a -p /sys/class/scsi_tape/st0a > /tmp/st0a

and diffing it, but I only see the following, which doesn't help me.
Is there a way to view the minor number(s) of a device from within
UDEV easily?

    # diff -u /tmp/st0* |less
    --- /tmp/st0    2009-06-04 16:58:44.000000000 -0400
    +++ /tmp/st0a   2009-06-04 16:58:14.000000000 -0400
    @@ -5,11 +5,11 @@
     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_tape/st0':
    -    KERNEL=="st0"
    +  looking at device '/class/scsi_tape/st0a':
    +    KERNEL=="st0a"
	 SUBSYSTEM=="scsi_tape"
	 DRIVER==""
    -    ATTR{defined}=="1"
    +    ATTR{defined}=="0"
	 ATTR{default_blksize}=="-1"
	 ATTR{default_density}=="-1"
	 ATTR{default_compression}=="-1"


So I would suspect that Udev knows about the major/minor device
numbers, but the docs on

  http://reactivated.net/writing_udev_rules.html 

don't talk about them at all to any useful degree.

Can anyone tell me if I'm on the right track here?

Thanks,
John
--
To unsubscribe from this list: send the line "unsubscribe linux-hotplug" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel]     [Linux DVB]     [Asterisk Internet PBX]     [DCCP]     [Netdev]     [X.org]     [Util Linux NG]     [Fedora Women]     [ALSA Devel]     [Linux USB]

  Powered by Linux