summaryrefslogtreecommitdiff
path: root/makedevs
diff options
context:
space:
mode:
Diffstat (limited to 'makedevs')
-rwxr-xr-xmakedevs137
1 files changed, 20 insertions, 117 deletions
diff --git a/makedevs b/makedevs
index fe8f46b..809f57b 100755
--- a/makedevs
+++ b/makedevs
@@ -1,123 +1,26 @@
-#!/bin/bash
+#!/bin/sh
-# $1 = base name
-# $2 = type (b/c)
-# $3 = start
-# $4 = finish
-# $5 = device major
-# $6 = device minor of first index
-mksubdevs() {
- minor=$6
- for i in `seq $3 $4`; do
- devname="$1$i"
- mknod $devname $2 $5 $minor
- minor=$(($minor+1))
- done
-}
+# a cheeky way of dynamically creating a /dev tree
+devdir="/dev"
+[ "$1" ] && devdir=$1
-usage() {
- echo "usage: makedevs <device root> [class] [class] ..."
- echo
- echo "available classes: base,ide,scsi,fd,tty,pty,rd,md,loop,dm"
- echo " (use 'all' to select all)"
- echo
- echo "example: makedevs /dev base ide scsi"
- echo
- exit 0
-}
+cd $devdir
-DEV_ROOT=$1
-[ "$1" == "" ] && usage
-shift
-
-cd $DEV_ROOT || exit 1
-
-CLASSES=
-while [ "$1" ]; do
- if [ "$1" == "all" ]; then
- CLASSES="base ide scsi fd tty pty rd md loop dm"
- else
- CLASSES="$CLASSES $1"
- fi
- shift
+for i in `find /sys/block -name dev`; do
+ # get the second-to-last field
+ name=`echo $i | rev | cut -d/ -f2 | rev`
+ maj=`cat $i | cut -d: -f1`
+ min=`cat $i | cut -d: -f2`
+ [ ! -e $name ] && mknod $name b $maj $min
done
-for CLASS in $CLASSES; do
- case $CLASS in
- base)
- mknod console c 5 1
- mknod full c 1 7
- mknod mem c 1 1
- mknod null c 1 3
- mknod psaux c 10 1
- mknod random c 1 8
- mknod tty c 5 0
- mknod urandom c 1 9
- mknod zero c 1 5
- ;;
- ide)
- mknod hda b 3 0
- mknod hdb b 3 64
- mknod hdc b 22 0
- mknod hdd b 22 64
- mknod hde b 33 0
- mknod hdf b 33 64
- mknod hdg b 34 0
- mknod hdh b 34 64
- mksubdevs hda b 1 12 3 1
- mksubdevs hdb b 1 12 3 65
- mksubdevs hdc b 1 12 22 1
- mksubdevs hdd b 1 12 22 65
- mksubdevs hde b 1 12 33 1
- mksubdevs hdf b 1 12 33 65
- mksubdevs hdg b 1 12 34 1
- mksubdevs hdh b 1 12 34 65
- ;;
- scsi)
- mknod sda b 8 0
- mknod sdb b 8 16
- mknod sdc b 8 32
- mknod sdd b 8 48
- mknod sde b 8 64
- mknod sdf b 8 80
- mknod sdg b 8 96
- mknod sdh b 8 112
- mksubdevs sda b 1 12 8 1
- mksubdevs sdb b 1 12 8 17
- mksubdevs sdc b 1 12 8 33
- mksubdevs sdd b 1 12 8 49
- mksubdevs sde b 1 12 8 65
- mksubdevs sdf b 1 12 8 81
- mksubdevs sdg b 1 12 8 97
- mksubdevs sdh b 1 12 8 113
- # SCSI CD-ROMs
- mksubdevs scd b 0 3 11 0
- mksubdevs sr b 0 3 11 0
- ;;
- fd)
- mksubdevs fd b 0 3 2 0
- ;;
- tty)
- mksubdevs tty c 0 63 4 0
- ;;
- pty)
- mknod ptmx c 5 2
- ;;
- rd)
- mksubdevs ram b 0 15 1 0
- ;;
- md)
- mksubdevs md b 0 15 9 0
- ;;
- loop)
- mksubdevs loop b 0 7 7 0
- ;;
- dm)
- mkdir mapper >/dev/null 2>&1
- mknod mapper/control c 10 63
- ;;
- *)
- echo "Unknown class: $CLASS" >&2
- ;;
- esac
+for i in `find /sys/class -name dev`; do
+ # get the second-to-last field
+ name=`echo $i | rev | cut -d/ -f2 | rev`
+ # skip all the tty?? nodes
+ #[ "${name%%??}" = "tty" ] && continue
+ #[ "${name%%??}" = "pty" ] && continue
+ maj=`cat $i | cut -d: -f1`
+ min=`cat $i | cut -d: -f2`
+ [ ! -e $name ] && mknod $name c $maj $min
done