1
0
mirror of https://github.com/openbsd/src.git synced 2024-12-22 16:42:56 -08:00

Greatly speedup MAKEDEV by using arrays instead of very long strings

that get copied around a lot. Needs sh(1) max array index bump I
committed earlier. ok todd@ deraadt@
This commit is contained in:
otto 2005-10-06 06:43:19 +00:00
parent 69485dd93e
commit 449c289590
2 changed files with 36 additions and 49 deletions

View File

@ -1,4 +1,4 @@
vers(a, {-$OpenBSD: MAKEDEV.common,v 1.20 2005/08/01 22:22:12 deraadt Exp $-})dnl
vers(a, {-$OpenBSD: MAKEDEV.common,v 1.21 2005/10/06 06:43:19 otto Exp $-})dnl
divert(1)dnl
dnl
dnl Common device definitions.
@ -226,8 +226,8 @@ __devitem(ss, ss*, SCSI scanners)dnl
_mkdev(ss, ss*, {-M ss$U c major_ss_c Mult($U,16) 640 operator
M nss$U c major_ss_c Add(Mult($U,16),1) 640 operator
M enss$U c major_ss_c Add(Mult($U,16),3) 640 operator
RMlist="$RMlist scan$U"
MKlist="$MKlist;umask 77;ln -s ss$U scan$U"-})dnl
RMlist[${#RMlist[*]}]="scan$U"
MKlist[${#MKlist[*]}]=";umask 77;ln -s ss$U scan$U"-})dnl
dnl XXX see ramdisk above
__devitem(ramd, ramdisk, Ramdisk kernel devices,nothing)dnl
_mkdev(ramd, ramdisk, {-dnl
@ -450,10 +450,10 @@ _mkdev(au, audio*, {-M sound$U c major_au_c $U
M mixer$U c major_au_c Add($U, 16)
M audio$U c major_au_c Add($U, 128)
M audioctl$U c major_au_c Add($U, 192)
MKlist="$MKlist;[ -e audio ] || ln -s audio$U audio"
MKlist="$MKlist;[ -e mixer ] || ln -s mixer$U mixer"
MKlist="$MKlist;[ -e sound ] || ln -s sound$U sound"
MKlist="$MKlist;[ -e audioctl ] || ln -s audioctl$U audioctl"-})dnl
MKlist[${#MKlist[*]}]=";[ -e audio ] || ln -s audio$U audio"
MKlist[${#MKlist[*]}]=";[ -e mixer ] || ln -s mixer$U mixer"
MKlist[${#MKlist[*]}]=";[ -e sound ] || ln -s sound$U sound"
MKlist[${#MKlist[*]}]=";[ -e audioctl ] || ln -s audioctl$U audioctl"-})dnl
__devitem(asc, asc*, ASC Audio device)dnl
_mkdev(asc, asc*, {-M asc$U major_asc_c 0-})dnl
__devitem(bio, bio, {-ioctl tunnel pseudo-device-})dnl
@ -461,15 +461,15 @@ _mkdev(bio, bio, {-M bio c major_bio_c 0 600-})dnl
__devitem(music, music*, MIDI devices,midi)dnl
_mkdev(music, music*, {-M music$U c major_music_c $U
M sequencer$U c major_music_c Add($U, 128)
MKlist="$MKlist;[ -e music ] || ln -s music$U music"
MKlist="$MKlist;[ -e sequencer ] || ln -s sequencer$U sequencer"-})dnl
MKlist[${#MKlist[*]}]=";[ -e music ] || ln -s music$U music"
MKlist[${#MKlist[*]}]=";[ -e sequencer ] || ln -s sequencer$U sequencer"-})dnl
__devitem(radio, radio*, FM tuner devices)dnl
_mkdev(radio, radio*, {-M radio$U c major_radio_c $U
MKlist="$MKlist;[ -e radio ] || ln -s radio$U radio"-})dnl
MKlist[${#MKlist[*]}]=";[ -e radio ] || ln -s radio$U radio"-})dnl
__devitem(fdesc, fd, fd/* nodes for fdescfs,mount_fdesc 8)dnl
_mkdev(fdesc, fd, {-RMlist="mkdir -p fd;$RMlist" n=0
_mkdev(fdesc, fd, {-RMlist[${#RMlist[*]}]=";mkdir -p fd;rm -f" n=0
while [ $n -lt 64 ];do M fd/$n c major_fdesc_c $n;n=Add($n, 1);done
MKlist="$MKlist;chmod 555 fd"-})dnl
MKlist[${#MKlist[*]}]=";chmod 555 fd"-})dnl
__devitem(grf_mac, grf*, Raw interface to the mac68k graphics devices,grf)dnl
__devitem(oppr, openprom,PROM settings,openprom)dnl
_cdev(oppr, openprom, 70, 0)dnl

View File

@ -1,7 +1,7 @@
define(COMM,`#')dnl
include(MAKEDEV.sub)dnl
dnl
vers(a, {-$OpenBSD: MAKEDEV.mi,v 1.76 2005/10/04 18:33:52 otto Exp $-})dnl
vers(a, {-$OpenBSD: MAKEDEV.mi,v 1.77 2005/10/06 06:43:19 otto Exp $-})dnl
dnl
divert(1)dnl
{-#-}
@ -169,45 +169,34 @@ dodisk2()
}
# M name b/c major minor [mode] [group]
RMlist="rm -f"
MKlist=":"
RMlist[0]="rm -f"
mkl() {
dnl
dnl uncomment if multi mknod happens
dnl
ifelse(1, 0,
[ "${mklist[{-$-}1]}" ] && mklist[{-$-}1]="${mklist[{-$-}1]} {-$-}2 {-$-}3 {-$-}4 {-$-}5" || {
mklist[{-$-}1]="mknod -m {-$-}1 {-$-}2 {-$-}3 {-$-}4 {-$-}5"
modes="$modes {-$-}1"
},
dnl
dnl non multi mknod
dnl
[ "${mklist[{-$-}1]}" ] && {
mklist[{-$-}1]="${mklist[{-$-}1]};mknod -m {-$-}1 {-$-}2 {-$-}3 {-$-}4 {-$-}5"
} || {
mklist[{-$-}1]="mknod -m {-$-}1 {-$-}2 {-$-}3 {-$-}4 {-$-}5"
modes="$modes {-$-}1"
})
mklist[{-$-}{#mklist[*]}]=";mknod -m {-$-}1 {-$-}2 {-$-}3 {-$-}4 {-$-}5"
}
M() {
RMlist="$RMlist {-$-}1"
RMlist[{-$-}{#RMlist[*]}]={-$-}1
mkl ${5-666} {-$-}1 {-$-}2 {-$-}3 {-$-}4
G={-$-}{6:-wheel}
[ "{-$-}7" ] && {
MKlist="$MKlist;chown {-$-}7:{-$-}G {-$-}1"
MKlist[{-$-}{#MKlist[*]}]=";chown {-$-}7:{-$-}G {-$-}1"
} || {
case $G in
wheel)g=0;;kmem)g=2;;operator)g=5;;tty)g=4;;dialer)g=117;;_lkm)g=61;;
wheel)
[ {-$-}{#whlist[*]} = 0 ] && whlist[0]=";chgrp wheel"
whlist[{-$-}{#whlist[*]}]="$1"
;;
operator)
[ {-$-}{#oplist[*]} = 0 ] && oplist[0]=";chgrp operator"
oplist[{-$-}{#oplist[*]}]="$1"
;;
*)
MKlist[{-$-}{#MKlist[*]}]=";chgrp $G $1";
esac
[ "${grplist[$g]}" ] && {
grplist[$g]="${grplist[$g]} {-$-}1"
} || {
groups="$groups $g"
grplist[$g]="chgrp $G {-$-}1"
}
}
return 0
}
@ -226,18 +215,16 @@ esac
done
}
_recurse "$@"
list="$RMlist"
for mode in $modes; do
list="$list;${mklist[$mode]}"
done
for group in $groups; do
list="$list;${grplist[$group]}"
done
list="$list;$MKlist"
if [ "$eo" = "echo" ]; then
$eo "$list"
{
echo -n ${RMlist[*]}
echo -n ${mklist[*]}
echo -n ${MKlist[*]}
echo -n ${whlist[*]}
echo ${oplist[*]}
} | if [ "$eo" = "echo" ]; then
cat
else
echo "$list" | sh
sh
fi
divert(3)dnl
dnl