summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkay.sievers@vrfy.org <kay.sievers@vrfy.org>2003-12-22 20:34:53 -0800
committerGreg KH <gregkh@suse.de>2005-04-26 21:13:09 -0700
commit4af58c70571c5c63edaff20d2032c8eeb59678b6 (patch)
tree506d8fa6d52bfbcd258ff67cd7525793a4396c91
parent958479a0dead606c6e44490a30a7040773654281 (diff)
[PATCH] experimental CALLOUT script for devfs ide node creation with cd, disc, part
Here is a experimental CALLOUT script for udev to create devfs nodes for IDE-devices. Not that I need these, I just wanted to see if it works :) The script is really stupid, no error handling, nothing more than absolutely needed. The rule uses the 'k' format char of the previous patch. The %D is not used, so the user can have disc or disk :) this single line: CALLOUT, BUS="ide", PROGRAM="/etc/udev/ide-devfs.sh %k %b %n", ID="hd*", NAME="%1c", SYMLINK="%2c" creates the following on my machine with two hard disks, one DVD and a PCMCIA-compact-flash inserted: /udev |-- hda |-- hda1 |-- hda2 |-- hda4 |-- hdb |-- hdb1 |-- hdc |-- hde |-- hde1 `-- ide |-- host0 | |-- bus0 | | |-- target0 | | | `-- lun0 | | | |-- disc -> ../../../../../hda | | | |-- part1 -> ../../../../../hda1 | | | |-- part2 -> ../../../../../hda2 | | | `-- part4 -> ../../../../../hda4 | | `-- target1 | | `-- lun0 | | |-- disc -> ../../../../../hdb | | `-- part1 -> ../../../../../hdb1 | `-- bus1 | `-- target0 | `-- lun0 | `-- cd -> ../../../../../hdc `-- host2 `-- bus0 `-- target0 `-- lun0 |-- disc -> ../../../../../hde `-- part1 -> ../../../../../hde1
-rw-r--r--extras/ide-devfs.sh27
1 files changed, 27 insertions, 0 deletions
diff --git a/extras/ide-devfs.sh b/extras/ide-devfs.sh
new file mode 100644
index 0000000000..3409c407eb
--- /dev/null
+++ b/extras/ide-devfs.sh
@@ -0,0 +1,27 @@
+#!/bin/sh
+
+# udev CALLOUT script
+# return devfs-names for ide-devices
+# CALLOUT, BUS="ide", PROGRAM="/etc/udev/ide-devfs.sh %k %b %n", ID="hd*", NAME="%1c", SYMLINK="%2c"
+
+HOST=${2%\.[0-9]}
+TARGET=${2#[0-9]\.}
+
+if [ -z ${HOST#[13579]} ]; then
+ HOST=`expr $HOST - 1`
+ BUS="1"
+else
+ BUS="0"
+fi
+
+if [ -z "$3" ]; then
+ MEDIA=`cat /proc/ide/$1/media`
+ if [ "$MEDIA" = "cdrom" ]; then
+ echo $1 ide/host$HOST/bus$BUS/target$TARGET/lun0/cd
+ elif [ "$MEDIA" = "disk" ]; then
+ echo $1 ide/host$HOST/bus$BUS/target$TARGET/lun0/disc
+ fi
+else
+ echo $1 ide/host$HOST/bus$BUS/target$TARGET/lun0/part$3
+fi
+