diff options
author | md@Linux.IT <md@Linux.IT> | 2005-02-06 01:07:13 +0100 |
---|---|---|
committer | Greg KH <gregkh@suse.de> | 2005-04-26 23:24:20 -0700 |
commit | 882b97455b4f8e3859abc6e6357b0e233cf4a0c8 (patch) | |
tree | 6ca91fe6a64953e5635cf4d659ad1b4ad005c4a8 | |
parent | fd3eeb7502d9ed52569bdb3e01a50ecbc132035e (diff) |
[PATCH] raid-devfs.sh: devfs names for hardware RAID controllers
-rw-r--r-- | extras/raid-devfs.sh | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/extras/raid-devfs.sh b/extras/raid-devfs.sh new file mode 100644 index 0000000000..796232b497 --- /dev/null +++ b/extras/raid-devfs.sh @@ -0,0 +1,50 @@ +#!/bin/sh -e +# +# Copyright (c) 2004 Marco d'Itri <md@linux.it> +# Copyright (c) 2004 Piotr Roszatycki <dexter@debian.org> +# +# Usage: +# KERNEL="cciss!*", PROGRAM="/etc/udev/scripts/raid-devfs.sh %k", NAME="%c{1}", SYMLINK="%k" +# KERNEL="ida!*", PROGRAM="/etc/udev/scripts/raid-devfs.sh %k", NAME="%c{1}", SYMLINK="%k" +# KERNEL="rd!*", PROGRAM="/etc/udev/scripts/raid-devfs.sh %k", NAME="%c{1}", SYMLINK="%k" + +get_dev_number_cciss() { + grep '^cciss/' /proc/driver/cciss/* | cat -n | \ + sed -n "/cciss\/$1:/s/cciss.*//p" +} + +get_dev_number_ida() { + grep '^ida/' /proc/driver/cpqarray/* | cat -n | \ + sed -n "/ida\/$1:/s/ida.*//p" +} + +get_dev_number_rd() { + grep '^ */dev/rd/' /proc/rd/*/initial_status | cat -n | \ + sed -n "/rd\/$1:/s/\/dev\/rd.*//p" +} + +get_dev_number() { + dev=$1 + num=$(eval $(echo get_dev_number_$TYPE $dev)) + [ "$num" ] || exit 1 + echo $(($num - 1)) +} + +TYPE=${1%%/*} +NAME=${1#*/} + +# abort if there was no match +[ "$TYPE" != "$1" ] || exit 1 + +case "$NAME" in + *p*) + LONG_NAME=disc$(get_dev_number ${NAME%%p*})/part${NAME##*p} + ;; + *) + LONG_NAME=disc$(get_dev_number $NAME)/disc + ;; +esac + +echo "$TYPE/$LONG_NAME" +exit 0 + |