From: "John Stoffel" <john@stoffel.org>
To: linux-hotplug@vger.kernel.org
Subject: Re: Mapping /dev/*st0* to fixed names using scsi_id
Date: Thu, 04 Jun 2009 21:03:39 +0000 [thread overview]
Message-ID: <18984.13995.659485.806267@stoffel.org> (raw)
In-Reply-To: <18982.53980.652743.304603@stoffel.org>
>>>>> "John" = John Stoffel <john@stoffel.org> 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
next prev parent reply other threads:[~2009-06-04 21:03 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-06-03 19:45 Mapping /dev/*st0* to fixed names using scsi_id John Stoffel
2009-06-04 21:03 ` John Stoffel [this message]
2009-06-07 10:04 ` John Huttley
2009-06-09 15:27 ` John Stoffel
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=18984.13995.659485.806267@stoffel.org \
--to=john@stoffel.org \
--cc=linux-hotplug@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).