* scsi-devfs.sh
@ 2004-01-08 7:35 Remco
2004-01-08 10:30 ` scsi-devfs.sh Kay Sievers
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Remco @ 2004-01-08 7:35 UTC (permalink / raw)
To: linux-hotplug
Analogous to the 'ide-devfs.sh' script, I created a 'scsi-devfs.sh' CALLOUT script.
I tried to make it useful for any SCSI device. (using names taken from the Linux SCSCI 2.4 howto,
so if there were any major changes in 2.6 they are not reflected in the script)
Since I only own one external USB drive that's all I could test it with, so other devices have not been tested.
Main reason for having this script is not necessarily being devfs compliant,
but for not having all device nodes in one flat directory structure.
If anyone is interrested, feel free to grab it.
scsi-devfs.sh:
#!/bin/sh
# udev CALLOUT script
# return devfs-like-names for scsi-devices
# CALLOUT, BUS="scsi", PROGRAM="/etc/udev/scsi-devfs.sh %k %b %n", ID="[nst*]", NAME="%1c", SYMLINK="%2c"
# CALLOUT, BUS="scsi", PROGRAM="/etc/udev/scsi-devfs.sh %k %b %n", ID="[scd*]", NAME="%1c", SYMLINK="%2c"
# CALLOUT, BUS="scsi", PROGRAM="/etc/udev/scsi-devfs.sh %k %b %n", ID="s[dgrt]*", NAME="%1c", SYMLINK="%2c"
SCSI_ID=$2 # format is straight forward "n1:n2:n3:n4" => "HOST:BUS:TARGET:LUN"
# Get host id (n1)
HOST=${SCSI_ID%%\:*};
# Shift to the next id (n2) and discard n1
SCSI_ID=${SCSI_ID#*\:};
# Get the bus id
BUS=${SCSI_ID%%\:*};
# Shift to the next id (n3) and discard n2
SCSI_ID=${SCSI_ID#*\:};
# Get target id
TARGET=${SCSI_ID%%\:*};
# Shift to the next id (n4) and discard n3
SCSI_ID=${SCSI_ID#*\:};
# Get lun id
LUN=$SCSI_ID;
# Determine medium name and type
# Kernel device name/type combinations were extracted from "The Linux 2.4 SCSI subsystem HOWTO"
if [ -z "$3" ]; then
case "$1" in
scd* | sr*)
# CDROM
DEVICE=scsi/host$HOST/bus$BUS/target$TARGET/lun$LUN/cd
;;
sd*)
# Hard disc
DEVICE=scsi/host$HOST/bus$BUS/target$TARGET/lun$LUN/disc
;;
nst*)
# Tape without rewind
DEVICE=scsi/host$HOST/bus$BUS/target$TARGET/lun$LUN/mtan
;;
st*)
# Tape with rewind
DEVICE=scsi/host$HOST/bus$BUS/target$TARGET/lun$LUN/mt
;;
sg* | *)
# Generic / all left-overs
DEVICE=scsi/host$HOST/bus$BUS/target$TARGET/lun$LUN/generic
;;
esac
else
# Partitions
DEVICE=scsi/host$HOST/bus$BUS/target$TARGET/lun$LUN/part$3
fi
# Return DEVICE to udev
echo $1 $DEVICE
exit 0
-------------------------------------------------------
This SF.net email is sponsored by: Perforce Software.
Perforce is the Fast Software Configuration Management System offering
advanced branching capabilities and atomic changes on 50+ platforms.
Free Eval! http://www.perforce.com/perforce/loadprog.html
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
Linux-hotplug-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: scsi-devfs.sh
2004-01-08 7:35 scsi-devfs.sh Remco
@ 2004-01-08 10:30 ` Kay Sievers
2004-01-08 10:51 ` scsi-devfs.sh Remco
2004-01-08 11:18 ` scsi-devfs.sh Kay Sievers
2 siblings, 0 replies; 4+ messages in thread
From: Kay Sievers @ 2004-01-08 10:30 UTC (permalink / raw)
To: linux-hotplug
On Thu, Jan 08, 2004 at 08:35:58AM +0100, Remco wrote:
> Analogous to the 'ide-devfs.sh' script, I created a 'scsi-devfs.sh' CALLOUT script.
> I tried to make it useful for any SCSI device. (using names taken from the Linux SCSCI 2.4 howto,
> so if there were any major changes in 2.6 they are not reflected in the script)
> Since I only own one external USB drive that's all I could test it with, so other devices have not been tested.
>
> Main reason for having this script is not necessarily being devfs compliant,
> but for not having all device nodes in one flat directory structure.
>
> If anyone is interrested, feel free to grab it.
>
>
> scsi-devfs.sh:
>
> #!/bin/sh
>
> # udev CALLOUT script
> # return devfs-like-names for scsi-devices
> # CALLOUT, BUS="scsi", PROGRAM="/etc/udev/scsi-devfs.sh %k %b %n", ID="[nst*]", NAME="%1c", SYMLINK="%2c"
> # CALLOUT, BUS="scsi", PROGRAM="/etc/udev/scsi-devfs.sh %k %b %n", ID="[scd*]", NAME="%1c", SYMLINK="%2c"
> # CALLOUT, BUS="scsi", PROGRAM="/etc/udev/scsi-devfs.sh %k %b %n", ID="s[dgrt]*", NAME="%1c", SYMLINK="%2c"
What does a character class with a asterisk ID="[nst*]" mean?
Shouldn't it be ID="nst*"? Same for ID="scd*".
thanks,
Kay
-------------------------------------------------------
This SF.net email is sponsored by: Perforce Software.
Perforce is the Fast Software Configuration Management System offering
advanced branching capabilities and atomic changes on 50+ platforms.
Free Eval! http://www.perforce.com/perforce/loadprog.html
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
Linux-hotplug-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: scsi-devfs.sh
2004-01-08 7:35 scsi-devfs.sh Remco
2004-01-08 10:30 ` scsi-devfs.sh Kay Sievers
@ 2004-01-08 10:51 ` Remco
2004-01-08 11:18 ` scsi-devfs.sh Kay Sievers
2 siblings, 0 replies; 4+ messages in thread
From: Remco @ 2004-01-08 10:51 UTC (permalink / raw)
To: linux-hotplug
Op donderdag 08 januari 2004 11:30, schreef Kay Sievers:
> On Thu, Jan 08, 2004 at 08:35:58AM +0100, Remco wrote:
> > Analogous to the 'ide-devfs.sh' script, I created a 'scsi-devfs.sh'
> > CALLOUT script. I tried to make it useful for any SCSI device. (using
> > names taken from the Linux SCSCI 2.4 howto, so if there were any major
> > changes in 2.6 they are not reflected in the script) Since I only own one
> > external USB drive that's all I could test it with, so other devices have
> > not been tested.
> >
> > Main reason for having this script is not necessarily being devfs
> > compliant, but for not having all device nodes in one flat directory
> > structure.
> >
> > If anyone is interrested, feel free to grab it.
> >
> >
> > scsi-devfs.sh:
> >
> > #!/bin/sh
> >
> > # udev CALLOUT script
> > # return devfs-like-names for scsi-devices
> > # CALLOUT, BUS="scsi", PROGRAM="/etc/udev/scsi-devfs.sh %k %b %n",
> > ID="[nst*]", NAME="%1c", SYMLINK="%2c" # CALLOUT, BUS="scsi",
> > PROGRAM="/etc/udev/scsi-devfs.sh %k %b %n", ID="[scd*]", NAME="%1c",
> > SYMLINK="%2c" # CALLOUT, BUS="scsi", PROGRAM="/etc/udev/scsi-devfs.sh %k
> > %b %n", ID="s[dgrt]*", NAME="%1c", SYMLINK="%2c"
>
> What does a character class with a asterisk ID="[nst*]" mean?
> Shouldn't it be ID="nst*"? Same for ID="scd*".
>
> thanks,
> Kay
I don't know how I came up with those brackets but you're absolutely right !
Correct me if I'm wrong but any rule like "ID=[???*]" would mean ID-ing every
device in the system and this seems pretty senseless in general.
Thanks for your response.
-------------------------------------------------------
This SF.net email is sponsored by: Perforce Software.
Perforce is the Fast Software Configuration Management System offering
advanced branching capabilities and atomic changes on 50+ platforms.
Free Eval! http://www.perforce.com/perforce/loadprog.html
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
Linux-hotplug-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: scsi-devfs.sh
2004-01-08 7:35 scsi-devfs.sh Remco
2004-01-08 10:30 ` scsi-devfs.sh Kay Sievers
2004-01-08 10:51 ` scsi-devfs.sh Remco
@ 2004-01-08 11:18 ` Kay Sievers
2 siblings, 0 replies; 4+ messages in thread
From: Kay Sievers @ 2004-01-08 11:18 UTC (permalink / raw)
To: linux-hotplug
On Thu, Jan 08, 2004 at 11:51:48AM +0100, Remco wrote:
> Op donderdag 08 januari 2004 11:30, schreef Kay Sievers:
> > On Thu, Jan 08, 2004 at 08:35:58AM +0100, Remco wrote:
> > > Analogous to the 'ide-devfs.sh' script, I created a 'scsi-devfs.sh'
> > > CALLOUT script. I tried to make it useful for any SCSI device. (using
> > > names taken from the Linux SCSCI 2.4 howto, so if there were any major
> > > changes in 2.6 they are not reflected in the script) Since I only own one
> > > external USB drive that's all I could test it with, so other devices have
> > > not been tested.
> > >
> > > scsi-devfs.sh:
> > >
> > > #!/bin/sh
> > >
> > > # udev CALLOUT script
> > > # return devfs-like-names for scsi-devices
> > > # CALLOUT, BUS="scsi", PROGRAM="/etc/udev/scsi-devfs.sh %k %b %n",
> > > ID="[nst*]", NAME="%1c", SYMLINK="%2c" # CALLOUT, BUS="scsi",
> > > PROGRAM="/etc/udev/scsi-devfs.sh %k %b %n", ID="[scd*]", NAME="%1c",
> > > SYMLINK="%2c" # CALLOUT, BUS="scsi", PROGRAM="/etc/udev/scsi-devfs.sh %k
> > > %b %n", ID="s[dgrt]*", NAME="%1c", SYMLINK="%2c"
> >
> > What does a character class with a asterisk ID="[nst*]" mean?
> > Shouldn't it be ID="nst*"? Same for ID="scd*".
>
> I don't know how I came up with those brackets but you're absolutely right !
> Correct me if I'm wrong but any rule like "ID=[???*]" would mean ID-ing every
> device in the system and this seems pretty senseless in general.
>
Everything inside the brackets are a character class.
A character class may contain a list of characters that should match or
a range like [0-9] or [a-z]. But everything inside is only compared with
one single char of the string.
udev's matching is partly based on fnmatch():
http://developer.novell.com/ndk/doc/libc/index.html?page=/ndk/doc/libc/libc_enu/data/amsgxku.html
You may also use only one rule in udev.rules.
Just use ID="*" and exit with nonzero in the script when no device is
matching your processing. The rule is only applied when the callout
returns successful.
thanks,
Kay
-------------------------------------------------------
This SF.net email is sponsored by: Perforce Software.
Perforce is the Fast Software Configuration Management System offering
advanced branching capabilities and atomic changes on 50+ platforms.
Free Eval! http://www.perforce.com/perforce/loadprog.html
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
Linux-hotplug-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2004-01-08 11:18 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-01-08 7:35 scsi-devfs.sh Remco
2004-01-08 10:30 ` scsi-devfs.sh Kay Sievers
2004-01-08 10:51 ` scsi-devfs.sh Remco
2004-01-08 11:18 ` scsi-devfs.sh Kay Sievers
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).