#!/bin/sh - # # $OpenBSD: MAKEDEV,v 1.18 2000/03/22 07:34:30 niklas Exp $ # $NetBSD: MAKEDEV,v 1.3 1996/01/07 16:53:15 ragge Exp $ # # @(#)MAKEDEV 8.1 (Berkeley) 6/9/93 # # Device "make" file. Valid arguments: # std standard devices # local configuration specific devices # all create a reasonable amount of all files # Tapes: # ht* massbus tm03 & tu?? # tm* unibus tm11 & te10 emulations (e.g. Emulex tc-11) # tms* unibus/qbus TMSCP (e.g. TU81, TK50) # ts* unibus ts11 # mt* massbus tu78 # ut* unibus tu45 emulations (e.g.si 9700) # uu* tu58 cassettes on dl11 controller # st* SCSI tapes # Disks: # hp* massbus rm?? # hk* unibus rk06 and rk07 # up* other unibus devices (e.g. on Emulex sc-21v controller) # ra* unibus uda50 w/ ra?? # kra* bi kdb50 w/ ra?? # rl* unibus rl02 # rb* 730 idc w/ rb80 and/or rb02 # rx* unibus rx211 floppy disk # ccd* "concatenated" pseudo-disks # vnd* "file" pseudo-disks # hd* HDC9224 rd disks on VS2000 # sd* SCSI disks # cd* SCSI CD-ROM # Terminal multiplexors: # dz* unibus dz11 and dz32 # dh* unibus dh11 and emulations (e.g. Able dmax, Emulex cs-11) # dmf* unibus dmf32 # dhu* unibus dhu11 # dmz* unibus dmz32 # Pseudo terminals: # pty* set of 16 master and slave pseudo terminals # Printers: # ct* unibus parallel interface to CAT typesetter # lp* unibus lp11 parallel interface # va* unibus varian parallel interface # vp* unibus versatec parallel interface # Call units: # dn* unibus dn11 and emulations (e.g. Able Quadracall) # Special purpose devices: # ik* unibus interface to ikonas frame buffer # ps* unibus interface to e&s picture system 2 # ad* unibus interface to data translation a/d converter # np* unibus ethernet co-processor interface, for downloading. # qv* qvss (microvax) display # lkm loadable kernel modules # *random random data source # PATH=/sbin:/usr/sbin:/bin:/usr/bin umask 77 for i do case $i in all) sh MAKEDEV std vnd0 ccd0 pty0 lkm ipl sh MAKEDEV tms0 ts0 st0 st1 sh MAKEDEV ra0 ra1 ra2 ra3 ra4 ra5 ra6 ra7 hp0 hp1 random sh MAKEDEV sd0 sd1 sd2 sd3 hd0 hd1 hd2 ;; std) rm -f console drum floppy crl csa1 csa2 tu0 tu1 kUmem kmem mem null rm -f zero tty klog stdin stdout stderr mknod console c 0 0 mknod drum c 7 0 ; chmod 640 drum ; chown root.kmem drum mknod floppy c 8 0 mknod crl c 35 0 mknod csa1 c 51 0 mknod csa2 c 51 1 mknod tu0 b 8 0 mknod tu1 b 8 1 mknod kUmem c 3 3 ; chmod 600 kUmem mknod kmem c 3 1 ; chmod 640 kmem ; chown root.kmem kmem mknod mem c 3 0 ; chmod 640 mem ; chown root.kmem mem mknod null c 3 2 ; chmod 666 null mknod zero c 3 12 ; chmod 666 zero mknod tty c 2 0 ; chmod 666 tty mknod klog c 33 0 ; chmod 600 klog mknod stdin c 53 0 ; chmod 666 stdin mknod stdout c 53 1 ; chmod 666 stdout mknod stderr c 53 2 ; chmod 666 stderr mkdir fd > /dev/null 2>&1 (cd fd && eval `echo "" | awk ' BEGIN { \ for (i = 0; i < 64; i++) \ printf("rm -f %d; mknod %d c 53 %d;", i, i, i)}'`) chown -R root.wheel fd chmod 555 fd chmod 666 fd/* ;; ht*|tm*|tms*|ts*|ut*|st*) umask 0 ; unit=`expr $i : '[^0-9]*\(.*\)'` case $i in ht*) name=ht; blk=1; chr=5 ;; tms*) name=tms; blk=15; chr=38;; tm*) name=tm; blk=5; chr=14;; ts*) name=ts; blk=6; chr=16;; ut*) name=ut; blk=10; chr=17;; st*) name=st; blk=21; chr=60;; esac case $unit in 0|1|2|3|4|5|6|7) four=`expr $unit + 4` ; eight=`expr $unit + 8` twelve=`expr $unit + 12`; twenty=`expr $unit + 20` rm -f $name$unit $name$four $name$eight $name$twelve rm -f n$name$unit n$name$eight nr$name$unit nr$name$eight rm -f r$name$unit r$name$four r$name$eight r$name$twelve mknod $name$unit b $blk $unit mknod $name$four b $blk $four mknod $name$eight b $blk $eight mknod $name$twelve b $blk $twelve mknod n$name$unit b $blk $four ;: sanity w/pdp11 v7 mknod n$name$eight b $blk $twelve ;: ditto mknod nr$name$unit c $chr $four ;: sanity w/pdp11 v7 mknod nr$name$eight c $chr $twelve ;: ditto mknod r$name$unit c $chr $unit mknod r$name$four c $chr $four mknod r$name$eight c $chr $eight mknod r$name$twelve c $chr $twelve chown root.operator {,n,r,nr}$name{$unit,$eight} chown root.operator {,r}$name{$four,$twelve} chmod 660 {,n,r,nr}$name{$unit,$eight} chmod 660 {,r}$name{$four,$twelve} if [ $i = ut ] then rm -f $name$twenty r$name$twenty mknod $name$twenty b $blk $twenty mknod r$name$twenty c $chr $twenty chown root.operator {,r}$name$twenty chmod 660 {,r}$name$twenty fi if [ ! -e rmt$eight ] # compatibility stuff then rm -f mt$unit mt$four mt$eight mt$twelve rm -f nmt$unit nmt$eight nrmt$unit nrmt$eight rm -f rmt$unit rmt$four rmt$eight rmt$twelve ln -s $name$unit mt$unit ln -s $name$four mt$four ln -s $name$eight mt$eight ln -s $name$twelve mt$twelve ln -s n$name$unit nmt$unit ln -s n$name$eight nmt$eight ln -s nr$name$unit nrmt$unit ln -s nr$name$eight nrmt$eight ln -s r$name$unit rmt$unit ln -s r$name$four rmt$four ln -s r$name$eight rmt$eight ln -s r$name$twelve rmt$twelve fi ;; *) echo bad unit for tape in: $1 ;; esac umask 77 ;; mt*) umask 0 ; unit=`expr $i : '..\(.*\)'` case $i in mt*) blk=7; chr=19;; esac case $unit in 0|1|2|3|4|5|6|7) eight=`expr $unit + 0`; twelve=`expr $unit + 4`; sixteen=`expr $unit + 8`; twenty=`expr $unit + 12`; rm -f mt8 mt12 mt16 mt20 nmt8 nrmt8 rmt8 rmt12 rmt16 rmt20 rm -f nmt16 nrmt16 mknod mt8 b $blk $eight mknod mt12 b $blk $twelve mknod mt16 b $blk $sixteen mknod mt20 b $blk $twenty mknod nmt8 b $blk $twelve ;: ditto mknod nrmt8 c $chr $twelve ;: ditto mknod rmt8 c $chr $eight mknod rmt12 c $chr $twelve mknod rmt16 c $chr $sixteen mknod rmt20 c $chr $twenty mknod nmt16 b $blk $twenty ;: ditto mknod nrmt16 c $chr $twenty ;: ditto chown root.operator {,n,r,nr}mt{8,16} chown root.operator {,r}mt{12,20} chmod 660 {,n,r,nr}mt{8,16} chmod 660 {,r}mt{12,20} ;; *) echo bad unit for tape in: $1 ;; esac umask 77 ;; random|srandom|urandom|prandom|arandom) rm -f random urandom srandom prandom arandom mknod random c 58 0 mknod srandom c 58 1 mknod urandom c 58 2 mknod prandom c 58 3 mknod arandom c 58 4 chown root.wheel random srandom urandom prandom arandom chmod 644 random srandom urandom prandom arandom ;; hp*|hk*|up*|ra*|kra*|rl*|rb*|ccd*|hd*|sd*) umask 2 ; unit=`expr $i : '.*[^0-9]\([0-9]*\)'` case $i in hp*) name=hp; blk=0; chr=4;; hk*) name=hk; blk=3; chr=11;; up*) name=up; blk=2; chr=13;; ra*) name=ra; blk=9; chr=9;; kra*) name=kra; blk=16; chr=52;; rb*) name=rb; blk=11; chr=23;; rl*) name=rl; blk=14; chr=32;; ccd*) name=ccd; blk=17; chr=54;; hd*) name=hd; blk=19; chr=58;; sd*) name=sd; blk=20; chr=59;; 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}[abcg] r${name}${unit}[abcg] mknod ${name}${unit}a b $blk `expr $unit '*' 8 + 0` mknod ${name}${unit}b b $blk `expr $unit '*' 8 + 1` mknod ${name}${unit}c b $blk `expr $unit '*' 8 + 2` mknod ${name}${unit}g b $blk `expr $unit '*' 8 + 6` 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}c c $chr `expr $unit '*' 8 + 2` mknod r${name}${unit}g c $chr `expr $unit '*' 8 + 6` if [ $name != hk ] then rm -f ${name}${unit}[defh] r${name}${unit}[defh] 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}h b $blk `expr $unit '*' 8 + 7` 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}h c $chr `expr $unit '*' 8 + 7` fi chown root.operator ${name}${unit}[a-h] r${name}${unit}[a-h] chmod 640 ${name}${unit}[a-h] r${name}${unit}[a-h] ;; *) echo bad unit for disk in: $i ;; esac umask 77 ;; vnd*) umask 2 ; unit=`expr $i : 'vnd\(.*\)'` for name in vnd svnd; do blk=18; chr=55; case $name in vnd) off=0;; svnd) off=128;; esac rm -f $name$unit? r$name$unit? mknod ${name}${unit}a b $blk `expr $unit '*' 8 + $off + 0` mknod ${name}${unit}b b $blk `expr $unit '*' 8 + $off + 1` mknod ${name}${unit}c b $blk `expr $unit '*' 8 + $off + 2` mknod ${name}${unit}d b $blk `expr $unit '*' 8 + $off + 3` mknod ${name}${unit}e b $blk `expr $unit '*' 8 + $off + 4` mknod ${name}${unit}f b $blk `expr $unit '*' 8 + $off + 5` mknod ${name}${unit}g b $blk `expr $unit '*' 8 + $off + 6` mknod ${name}${unit}h b $blk `expr $unit '*' 8 + $off + 7` mknod r${name}${unit}a c $chr `expr $unit '*' 8 + $off + 0` mknod r${name}${unit}b c $chr `expr $unit '*' 8 + $off + 1` mknod r${name}${unit}c c $chr `expr $unit '*' 8 + $off + 2` mknod r${name}${unit}d c $chr `expr $unit '*' 8 + $off + 3` mknod r${name}${unit}e c $chr `expr $unit '*' 8 + $off + 4` mknod r${name}${unit}f c $chr `expr $unit '*' 8 + $off + 5` mknod r${name}${unit}g c $chr `expr $unit '*' 8 + $off + 6` mknod r${name}${unit}h c $chr `expr $unit '*' 8 + $off + 7` chown root.operator ${name}${unit}[a-h] r${name}${unit}[a-h] chmod 640 ${name}${unit}[a-h] r${name}${unit}[a-h] done umask 77 ;; cd*) umask 2 ; unit=`expr $i : '.*cd\(.*\)'` case $i in cd*) name=cd; blk=22; chr=61;; esac rm -f $name$unit? r$name$unit? mknod ${name}${unit}a b $blk `expr $unit '*' 8 + 0` mknod ${name}${unit}c b $blk `expr $unit '*' 8 + 2` mknod r${name}${unit}a c $chr `expr $unit '*' 8 + 0` mknod r${name}${unit}c c $chr `expr $unit '*' 8 + 2` chown root.operator ${name}${unit}[a-h] r${name}${unit}[a-h] chmod 640 ${name}${unit}[a-h] r${name}${unit}[a-h] umask 77 ;; rx*) unit=`expr $i : '..\(.*\)'` name=rx; chr=30; blk=12; case $unit in 0|1|2|3|4|5|6|7) rm -f ${name}{${unit} r${name}${unit}[abcd] mknod ${name}${unit} b $blk `expr $unit '*' 8 + 0` 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}c c $chr `expr $unit '*' 8 + 2` mknod r${name}${unit}d c $chr `expr $unit '*' 8 + 3` ;; *) echo bad unit for floppy disk in: $i ;; esac ;; uu*) unit=`expr $i : '..\(.*\)'` name=uu; blk=13; case $unit in 0|1|2|3) rm -f ${name}${unit} ${name}${unit}a mknod ${name}${unit} b $blk `expr $unit '*' 2 + 0` mknod ${name}${unit}a b $blk `expr $unit '*' 2 + 1` ;; *) echo bad unit for uu cassette in: $i ;; esac ;; dz*) unit=`expr $i : 'dz\(.*\)'` case $unit in 0|1|2|3|4|5|6|7) eval `echo $unit | awk ' { u = $1 } END { for (i = 0; i < 8; i++) printf("rm -f tty%02d; mknod tty%02d c 1 %d; ", u * 8 + i, u * 8 + i, u * 8 + i); }'` ;; *) echo bad unit for dz in: $i ;; esac ;; dhu*|dh*|dmf*|dmz*) case $i in dmz*) name=dmz; major=37; count=24; unit=`expr $i : "$name\(.*\)"` case $unit in 0) ch=a ;; 1) ch=b ;; 2) ch=c ;; 3) ch=e ;; 4) ch=f ;; 5) ch=g ;; *) echo bad unit for $name in: $i ;; esac;; dmf*) name=dmf; major=22; count=8; unit=`expr $i : "$name\(.*\)"` case $unit in 0) ch=A ;; 1) ch=B ;; 2) ch=C ;; 3) ch=E ;; 4) ch=F ;; 5) ch=G ;; 6) ch=H ;; 7) ch=I ;; *) echo bad unit for $name in: $i ;; esac;; dhu*) name=dhu; major=34; count=16; unit=`expr $i : "$name\(.*\)"`; case $unit in 0) ch=S ;; 1) ch=T ;; 2) ch=U ;; 3) ch=V ;; 4) ch=W ;; 5) ch=X ;; 6) ch=Y ;; 7) ch=Z ;; *) echo bad unit for $name in: $i ;; esac;; dh*) name=dh; major=12; count=16; unit=`expr $i : "$name\(.*\)"` case $unit in 0) ch=h ;; 1) ch=i ;; 2) ch=j ;; 3) ch=k ;; 4) ch=l ;; 5) ch=m ;; 6) ch=n ;; 7) ch=o ;; *) echo bad unit for $name in: $i ;; esac;; esac eval `echo $ch $unit $major $count | awk ' { ch = $1; u = $4 * $2; m = $3; cnt = $4 } END { for (i = 0; i < cnt; i++) if (i < 10) printf("rm -f tty%s%x; mknod tty%s%x c %d %d; ", ch, i, ch, i, m, u + i); else printf("rm -f tty%s%c; mknod tty%s%c c %d %d; ", ch, 87 + i, ch, 87 + i, m, u + i); }'` ;; lp*|va*|vp*) case $i in lp*) name=lp; major=15;; va*) name=va; major=10;; vp*) name=vp; major=6;; esac unit=`expr $i : "$name\(.*\)"` case $unit in 0|1|2|3|4|5|6|7) rm -f $i mknod $i c $major $unit; chmod 666 $i ;; *) echo bad unit for $name in: $i ;; esac ;; pty*) class=`expr $i : 'pty\(.*\)'` case $class in 0) offset=0 name=p;; 1) offset=16 name=q;; 2) offset=32 name=r;; 3) offset=48 name=s;; 4) offset=64 name=t;; 5) offset=80 name=u;; 6) offset=96 name=v;; 7) offset=112 name=w;; 8) offset=128 name=x;; 9) offset=144 name=y;; 10) offset=160 name=z;; 11) offset=176 name=P;; 12) offset=192 name=Q;; 13) offset=208 name=R;; 14) offset=224 name=S;; 15) offset=240 name=T;; *) echo bad unit for pty in: $i;; esac case $class in 0|1|2|3|4|5|6|7|8|9|10|11|12|13|14|15) umask 0 eval `echo $offset $name | awk ' { b=$1; n=$2 } END { for (i = 0; i < 16; i++) printf("rm -f tty%s%x; mknod tty%s%x c 20 %d;" \ "rm -f pty%s%x; mknod pty%s%x c 21 %d; ", \ n, i, n, i, b + i, n, i, n, i, b + i); }'` umask 77 ;; esac ;; ipl) rm -f ipl ipnat ipstate ipauth mknod ipl c 50 0 mknod ipnat c 50 1 mknod ipstate c 50 2 mknod ipauth c 50 3 chown root.wheel ipl ipnat ipstate ipauth ;; np*) class=`expr $i : 'np\(.*\)'` case $class in 0) offset=0 name=0;; 1) offset=16 name=1;; 2) offset=32 name=2;; *) echo bad unit for np in: $i;; esac case $class in 0|1|2) eval `echo $offset | awk ' { b=$1 } END { for (i = 0; i < 4; i++) printf("rm -f np%02d; mknod np%02d c 39 %d;", \ b + i, b + i, b + i); }'` ;; esac ;; dn*|ik*|ps*|ad*|ct*) unit=`expr $i : '..\(.*\)'` case $i in ct*) name=ct; chr=18;; dn*) name=cu; chr=24;; ps*) name=ps; chr=27;; ad*) name=ad; chr=29;; ik*) name=ik; chr=31;; esac case $unit in 0|1|2|3|4|5|6|7) umask 0 rm -f ${name}${unit} mknod ${name}${unit} c ${chr} ${unit} umask 77 ;; *) echo bad unit for ${name} in: $i ;; esac ;; lkm) rm -f lkm mknod lkm c 28 0 chown root.kmem lkm chmod 640 lkm ;; qv0) rm -f qv0 qvcons mouse mknod qv0 c 40 0 mknod qvcons c 40 1 mknod mouse c 40 2 ;; local) test -s MAKEDEV.local && sh MAKEDEV.local ;; esac done