mirror of
https://github.com/systemd/systemd-stable.git
synced 2024-12-24 21:34:08 +03:00
[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
This commit is contained in:
parent
958479a0de
commit
4af58c7057
27
extras/ide-devfs.sh
Normal file
27
extras/ide-devfs.sh
Normal file
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user