From 4af58c70571c5c63edaff20d2032c8eeb59678b6 Mon Sep 17 00:00:00 2001 From: "kay.sievers@vrfy.org" Date: Mon, 22 Dec 2003 20:34:53 -0800 Subject: [PATCH] [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 --- extras/ide-devfs.sh | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 extras/ide-devfs.sh diff --git a/extras/ide-devfs.sh b/extras/ide-devfs.sh new file mode 100644 index 00000000..3409c407 --- /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 + -- 2.39.5