Eliminate lots of expr(1) calls, as suggested by Charles.
This commit is contained in:
parent
0bbccb98a0
commit
618f2d5911
|
@ -1,5 +1,7 @@
|
|||
#!/bin/sh -
|
||||
#
|
||||
# $NetBSD: MAKEDEV,v 1.19 1996/11/11 22:34:51 pk Exp $
|
||||
#
|
||||
# Copyright (c) 1990 The Regents of the University of California.
|
||||
# All rights reserved.
|
||||
#
|
||||
|
@ -72,21 +74,20 @@ umask 77
|
|||
for i
|
||||
do
|
||||
|
||||
unit=`expr $i : '[a-z][a-z]*\([0-9][0-9]*\)'`
|
||||
[ "$unit" ] || unit=0
|
||||
|
||||
case $i in
|
||||
|
||||
all)
|
||||
sh MAKEDEV std sd0 sd1 sd2 sd3 sd4 xd0 xd1 xd2 xd3 xy0 xy1 xy2 xy3
|
||||
sh MAKEDEV cd0 st0 st1 fd0
|
||||
sh MAKEDEV pty0 vnd0 vnd1 vnd2 vnd3 audio tun0 tun1 tun2 tun3
|
||||
sh MAKEDEV ccd0 ccd1 ccd2 ccd3
|
||||
sh MAKEDEV bpf0 bpf1 bpf2 bpf3 bwtwo0 cgthree0 cgfour0 cgsix0
|
||||
sh MAKEDEV cgeight0
|
||||
sh MAKEDEV lkm local
|
||||
sh -$- $0 std sd0 sd1 sd2 sd3 sd4 xd0 xd1 xd2 xd3 xy0 xy1 xy2 xy3
|
||||
sh -$- $0 cd0 st0 st1 fd0
|
||||
sh -$- $0 pty0 vnd0 vnd1 vnd2 vnd3 audio tun0 tun1 tun2 tun3
|
||||
sh -$- $0 ccd0 ccd1 ccd2 ccd3
|
||||
sh -$- $0 bpf0 bpf1 bpf2 bpf3 bwtwo0 cgthree0 cgfour0 cgsix0
|
||||
sh -$- $0 cgeight0
|
||||
sh -$- $0 lkm local
|
||||
;;
|
||||
std)
|
||||
rm -f console tty kmem mem null zero eeprom openprom drum klog \
|
||||
stdin stdout stderr fd/* ttya ttyb fb mouse kbd
|
||||
mknod console c 0 0
|
||||
mknod tty c 2 0 ; chmod 666 tty
|
||||
mknod kmem c 3 1 ; chmod 640 kmem ; chgrp kmem kmem
|
||||
|
@ -94,7 +95,7 @@ std)
|
|||
mknod null c 3 2 ; chmod 666 null
|
||||
mknod zero c 3 12 ; chmod 666 zero
|
||||
mknod eeprom c 3 11 ; chmod 640 eeprom ; chgrp kmem eeprom
|
||||
mknod openprom c 70 0 ; chmod 644 openprom
|
||||
mknod openprom c 70 0 ; chmod 640 openprom;chgrp kmem openprom
|
||||
mknod drum c 7 0 ; chmod 640 drum ; chgrp kmem drum
|
||||
mknod klog c 16 0 ; chmod 600 klog
|
||||
mknod stdin c 24 0 ; chmod 666 stdin
|
||||
|
@ -116,38 +117,48 @@ std)
|
|||
;;
|
||||
|
||||
bwtwo*)
|
||||
unit=${i#bwtwo}
|
||||
rm -f bwtwo$unit
|
||||
mknod bwtwo$unit c 27 $unit; chmod 666 bwtwo$unit
|
||||
;;
|
||||
|
||||
cgthree*)
|
||||
unit=${i#cgthree}
|
||||
rm -f cgthree$unit
|
||||
mknod cgthree$unit c 55 $unit; chmod 666 cgthree$unit
|
||||
;;
|
||||
|
||||
cgfour*)
|
||||
unit=${i#cgfour}
|
||||
rm -f cgfour$unit
|
||||
mknod cgfour$unit c 39 $unit; chmod 666 cgfour$unit
|
||||
;;
|
||||
|
||||
cgsix*)
|
||||
unit=${i#cgsix}
|
||||
rm -f cgsix$unit
|
||||
mknod cgsix$unit c 67 $unit; chmod 666 cgsix$unit
|
||||
;;
|
||||
|
||||
cgeight*)
|
||||
unit=${i#cgeight}
|
||||
rm -f cgeight$unit
|
||||
mknod cgeight$unit c 64 $unit; chmod 666 cgeight$unit
|
||||
;;
|
||||
|
||||
tcx*)
|
||||
unit=${i#tcx}
|
||||
rm -f tcx$unit
|
||||
mknod tcx$unit c 109 $unit; chmod 666 tcx$unit
|
||||
;;
|
||||
|
||||
audio)
|
||||
rm -f audio
|
||||
mknod audio c 69 0; chmod 666 audio
|
||||
;;
|
||||
|
||||
openprom)
|
||||
mknod openprom c 70 0; chmod 600 openprom
|
||||
;;
|
||||
|
||||
bpf*)
|
||||
unit=${i#bpf}
|
||||
rm -f bpf$unit
|
||||
mknod bpf$unit c 105 $unit
|
||||
chmod 600 bpf$unit
|
||||
|
@ -155,6 +166,7 @@ bpf*)
|
|||
;;
|
||||
|
||||
tun*)
|
||||
unit=${i#tun}
|
||||
rm -f tun$unit
|
||||
mknod tun$unit c 111 $unit
|
||||
chmod 600 tun$unit
|
||||
|
@ -162,6 +174,7 @@ tun*)
|
|||
;;
|
||||
|
||||
rd*)
|
||||
unit=${i#tun}
|
||||
rm -f rd$unit
|
||||
mknod rd$unit b 5 $unit
|
||||
chown root.operator rd$unit
|
||||
|
@ -171,34 +184,34 @@ rd*)
|
|||
ccd*|fd*|sd*|xd*|xy*|cd*|vnd*)
|
||||
umask 2
|
||||
case $i in
|
||||
ccd*) name=ccd; blk=9; chr=23;;
|
||||
fd*) name=fd; blk=16; chr=54;;
|
||||
sd*) name=sd; blk=7; chr=17;;
|
||||
xd*) name=xd; blk=10; chr=42;;
|
||||
xy*) name=xy; blk=3; chr=9;;
|
||||
cd*) name=cd; blk=18; chr=58;;
|
||||
vnd*) name=vnd; blk=8; chr=110;;
|
||||
ccd*) name=ccd; unit=${i#ccd}; blk=9; chr=23;;
|
||||
fd*) name=fd; unit=${i#fd}; blk=16; chr=54;;
|
||||
sd*) name=sd; unit=${i#sd}; blk=7; chr=17;;
|
||||
xd*) name=xd; unit=${i#xd}; blk=10; chr=42;;
|
||||
xy*) name=xy; unit=${i#xy}; blk=3; chr=9;;
|
||||
cd*) name=cd; unit=${i#cd}; blk=18; chr=58;;
|
||||
vnd*) name=vnd; unit=${i#vnd}; blk=8; chr=110;;
|
||||
esac
|
||||
case $unit in
|
||||
0|1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|16|\
|
||||
17|18|19|20|21|22|23|24|25|26|27|28|29|30|31)
|
||||
rm -f ${name}${unit}[a-h] r${name}${unit}[a-h]
|
||||
mknod ${name}${unit}c b $blk `expr $unit '*' 8 + 2`
|
||||
mknod r${name}${unit}c c $chr `expr $unit '*' 8 + 2`
|
||||
mknod ${name}${unit}a b $blk `expr $unit '*' 8 + 0`
|
||||
mknod ${name}${unit}b b $blk `expr $unit '*' 8 + 1`
|
||||
mknod ${name}${unit}d b $blk `expr $unit '*' 8 + 3`
|
||||
mknod ${name}${unit}e b $blk `expr $unit '*' 8 + 4`
|
||||
mknod ${name}${unit}f b $blk `expr $unit '*' 8 + 5`
|
||||
mknod ${name}${unit}g b $blk `expr $unit '*' 8 + 6`
|
||||
mknod ${name}${unit}h b $blk `expr $unit '*' 8 + 7`
|
||||
mknod r${name}${unit}a c $chr `expr $unit '*' 8 + 0`
|
||||
mknod r${name}${unit}b c $chr `expr $unit '*' 8 + 1`
|
||||
mknod r${name}${unit}d c $chr `expr $unit '*' 8 + 3`
|
||||
mknod r${name}${unit}e c $chr `expr $unit '*' 8 + 4`
|
||||
mknod r${name}${unit}f c $chr `expr $unit '*' 8 + 5`
|
||||
mknod r${name}${unit}g c $chr `expr $unit '*' 8 + 6`
|
||||
mknod r${name}${unit}h c $chr `expr $unit '*' 8 + 7`
|
||||
mknod ${name}${unit}c b $blk $(($unit * 8 + 2))
|
||||
mknod ${name}${unit}a b $blk $(($unit * 8 + 0))
|
||||
mknod ${name}${unit}b b $blk $(($unit * 8 + 1))
|
||||
mknod ${name}${unit}d b $blk $(($unit * 8 + 3))
|
||||
mknod ${name}${unit}e b $blk $(($unit * 8 + 4))
|
||||
mknod ${name}${unit}f b $blk $(($unit * 8 + 5))
|
||||
mknod ${name}${unit}g b $blk $(($unit * 8 + 6))
|
||||
mknod ${name}${unit}h b $blk $(($unit * 8 + 7))
|
||||
mknod r${name}${unit}a c $chr $(($unit * 8 + 0))
|
||||
mknod r${name}${unit}b c $chr $(($unit * 8 + 1))
|
||||
mknod r${name}${unit}c c $chr $(($unit * 8 + 2))
|
||||
mknod r${name}${unit}d c $chr $(($unit * 8 + 3))
|
||||
mknod r${name}${unit}e c $chr $(($unit * 8 + 4))
|
||||
mknod r${name}${unit}f c $chr $(($unit * 8 + 5))
|
||||
mknod r${name}${unit}g c $chr $(($unit * 8 + 6))
|
||||
mknod r${name}${unit}h c $chr $(($unit * 8 + 7))
|
||||
chgrp operator ${name}${unit}[a-h] r${name}${unit}[a-h]
|
||||
chmod 640 ${name}${unit}[a-h] r${name}${unit}[a-h]
|
||||
;;
|
||||
|
@ -212,18 +225,18 @@ ccd*|fd*|sd*|xd*|xy*|cd*|vnd*)
|
|||
st*)
|
||||
umask 2
|
||||
case $i in
|
||||
st*) name=st; blk=11; chr=18;;
|
||||
st*) name=st; unit=${i#st}; blk=11; chr=18;;
|
||||
esac
|
||||
rm -f $name$unit n$name$unit e$name$unit en$name$unit \
|
||||
r$name$unit nr$name$unit er$name$unit enr$name$unit
|
||||
mknod ${name}${unit} b $blk `expr $unit '*' 16 + 0`
|
||||
mknod n${name}${unit} b $blk `expr $unit '*' 16 + 1`
|
||||
mknod e${name}${unit} b $blk `expr $unit '*' 16 + 2`
|
||||
mknod en${name}${unit} b $blk `expr $unit '*' 16 + 3`
|
||||
mknod r${name}${unit} c $chr `expr $unit '*' 16 + 0`
|
||||
mknod nr${name}${unit} c $chr `expr $unit '*' 16 + 1`
|
||||
mknod er${name}${unit} c $chr `expr $unit '*' 16 + 2`
|
||||
mknod enr${name}${unit} c $chr `expr $unit '*' 16 + 3`
|
||||
mknod ${name}${unit} b $blk $(($unit * 16 + 0))
|
||||
mknod n${name}${unit} b $blk $(($unit * 16 + 1))
|
||||
mknod e${name}${unit} b $blk $(($unit * 16 + 2))
|
||||
mknod en${name}${unit} b $blk $(($unit * 16 + 3))
|
||||
mknod r${name}${unit} c $chr $(($unit * 16 + 0))
|
||||
mknod nr${name}${unit} c $chr $(($unit * 16 + 1))
|
||||
mknod er${name}${unit} c $chr $(($unit * 16 + 2))
|
||||
mknod enr${name}${unit} c $chr $(($unit * 16 + 3))
|
||||
chgrp operator ${name}${unit} n${name}${unit} \
|
||||
e$name$unit en$name$unit \
|
||||
r${name}${unit} nr${name}${unit} \
|
||||
|
@ -238,10 +251,10 @@ st*)
|
|||
ch*)
|
||||
umask 2
|
||||
case $i in
|
||||
ch*) name=ch; chr=19;;
|
||||
ch*) name=ch; unit=${i#ch}; chr=19;;
|
||||
esac
|
||||
rm -f $name$unit
|
||||
mknod ${name}${unit} c $chr `expr $unit '*' 16 + 0`
|
||||
mknod ${name}${unit} c $chr $(($unit * 16 + 0))
|
||||
chgrp operator ${name}${unit}
|
||||
chmod 640 ${name}${unit}
|
||||
umask 77
|
||||
|
@ -255,7 +268,8 @@ lkm)
|
|||
;;
|
||||
|
||||
pty*)
|
||||
case $unit in
|
||||
class=${i#pty}
|
||||
case $class in
|
||||
0) offset=0 name=p;;
|
||||
1) offset=16 name=q;;
|
||||
2) offset=32 name=r;;
|
||||
|
@ -264,16 +278,20 @@ pty*)
|
|||
4) offset=64 name=t;;
|
||||
*) echo bad unit for pty in: $i;;
|
||||
esac
|
||||
case $unit in
|
||||
case $class in
|
||||
0|1|2|3|4)
|
||||
umask 0
|
||||
eval `echo $offset $name | awk ' { b=$1; n=$2 } END {
|
||||
for (i = 0; i < 16; i++)
|
||||
for (i = 0; i < 16; i++) { \
|
||||
printf("rm -f tty%s%x pty%s%x; ", \
|
||||
n, i, n, i); \
|
||||
printf("mknod tty%s%x c 20 %d; \
|
||||
mknod pty%s%x c 21 %d; ", \
|
||||
n, i, b+i, n, i, b+i); }'`
|
||||
n, i, b+i, n, i, b+i); \
|
||||
} \
|
||||
}'`
|
||||
umask 77
|
||||
if [ $unit = 1 ]; then
|
||||
if [ $class = 1 ]; then
|
||||
mv ttyqf ttyv0; mv ptyqf ptyv0
|
||||
fi
|
||||
;;
|
||||
|
@ -282,7 +300,7 @@ pty*)
|
|||
|
||||
local)
|
||||
umask 0
|
||||
sh MAKEDEV.local
|
||||
sh -$- $0.local
|
||||
;;
|
||||
*)
|
||||
echo $i: unknown device
|
||||
|
|
Loading…
Reference in New Issue