Annotation of src/etc/MAKEDEV.mi, Revision 1.83
1.72 miod 1: define(COMM,`#')dnl
1.1 todd 2: include(MAKEDEV.sub)dnl
3: dnl
1.83 ! deraadt 4: vers(a, {-$OpenBSD: MAKEDEV.mi,v 1.82 2016/03/12 17:58:59 espie Exp $-})dnl
1.1 todd 5: dnl
6: divert(1)dnl
7: {-#-}
1.71 todd 8: {-#-} Copyright (c) 2001-2004 Todd T. Fries <todd@OpenBSD.org>
1.1 todd 9: {-#-}
1.60 todd 10: {-#-} Permission to use, copy, modify, and distribute this software for any
11: {-#-} purpose with or without fee is hereby granted, provided that the above
12: {-#-} copyright notice and this permission notice appear in all copies.
1.1 todd 13: {-#-}
1.60 todd 14: {-#-} THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
15: {-#-} WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
16: {-#-} MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
17: {-#-} ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
18: {-#-} WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
19: {-#-} ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
20: {-#-} OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
1.1 todd 21: {-#-}
1.72 miod 22: define(quote,{-"$1" -})dnl
23: include(MAKEDEV.common)dnl
1.1 todd 24: dnl
1.72 miod 25: __devtitle(make, {-Device "make" file. Valid arguments-})dnl
26: __devitem({-all-}, {-all-}, {-makes all known devices{-,-} including local devices.
1.1 todd 27: {-#-} Tries to make the ``standard'' number of each type.-})dnl
1.72 miod 28: __devitem(std,{-std-},Standard devices)dnl
29: __devitem(local,local,Configuration specific devices)dnl
1.18 todd 30: dnl
1.1 todd 31: dnl _std
32: dnl
33: dnl $1: tty
34: dnl $2: memstuff
35: dnl $3: ksyms
1.79 miod 36: dnl $4: klog
1.1 todd 37: dnl
1.72 miod 38: define({-_std-},{-dnl
1.1 todd 39: std)
40: M console c 0 0 600
41: M tty c $1 0
42: M mem c $2 0 640 kmem
43: M kmem c $2 1 640 kmem
44: M null c $2 2
45: M zero c $2 12
46: M stdin c major_fdesc_c 0
47: M stdout c major_fdesc_c 1
48: M stderr c major_fdesc_c 2
49: M ksyms c $3 0 640 kmem
1.79 miod 50: M klog c $4 0 600-})dnl
1.1 todd 51: dnl
52: divert(1)dnl
1.72 miod 53: define(__mddivert,7)dnl
1.78 todd 54: include(MAKEDEV.md)dnl
1.1 todd 55: dnl
56: dnl
57: divert(0)dnl
58: #!/bin/sh -
59: #
60: # THIS FILE AUTOMATICALLY GENERATED. DO NOT EDIT.
61: # generated from:
62: #
63: show_vers()dnl <-- now that all files are included, show versions
64: #
65: dnl
66: divert(2)dnl
67: PATH=/sbin:/usr/sbin:/bin:/usr/bin
68: T=$0
69:
70: # set this to echo for Echo-Only debugging
71: [ "$eo" ] || eo=
72:
73: hex()
74: {
75: case ${--}1 in
1.26 deraadt 76: [0-9]) echo -n {-$-}1;;
77: 10) echo -n a;;
78: 11) echo -n b;;
79: 12) echo -n c;;
80: 13) echo -n d;;
81: 14) echo -n e;;
82: 15) echo -n f;;
1.1 todd 83: esac
1.65 todd 84: }
85:
86: alph2d()
87: {
1.73 david 88: local t="$1"
1.65 todd 89: local p="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
90: local sub=${p%${t}*}
91: echo ${#sub}
1.1 todd 92: }
1.26 deraadt 93:
1.62 todd 94: h2d()
1.1 todd 95: {
1.62 todd 96: local s="$1"
97: local f=${s%*[0-9a-f]} n=${s#[0-9a-f]*}
98:
99: echo $(($(_h2d $f)*16+ $(_h2d $n) ))
100: }
101:
102: _h2d()
103: {
104: case $1 in
105: [0-9]) echo -n $1;;
106: a) echo -n 10;;
107: b) echo -n 11;;
108: c) echo -n 12;;
109: d) echo -n 13;;
110: e) echo -n 14;;
111: f) echo -n 15;;
1.1 todd 112: esac
113: }
1.26 deraadt 114:
1.1 todd 115: unt()
116: {
117: # XXX pdksh can't seem to deal with locally scoped variables
118: # in ${foo#$bar} expansions
119: arg="{-$-}1"
120: tmp="${arg#[a-zA-Z]*}"
121: tmp="${tmp%*[a-zA-Z]}"
122: while [ "$tmp" != "$arg" ]
123: do
124: arg=$tmp
125: tmp="${arg#[a-zA-Z]*}"
126: tmp="${tmp%*[a-zA-Z]}"
127: done
128: echo $arg
129: }
130: dnl
1.29 todd 131: dnl dodisk(name, unit, blkmaj, chrmaj, unit, off[, stepping])
1.5 todd 132: dnl arg: 1 2 3 4 5 6 7
1.1 todd 133: dnl
1.26 deraadt 134:
1.1 todd 135: dodisk()
136: {
1.27 todd 137: [ "$DEBUG" ] && set -x
1.29 todd 138: n=Add(Mult(${5}, ${7:-16}), ${6}) count=0
1.13 todd 139: [ 0$7 -ne 8 ] && l="i j k l m n o p"
140: for d in a b c d e f g h $l
1.1 todd 141: do
1.76 otto 142: M {-$-}1{-$-}2$d b {-$-}3 Add($n, $count) 640 operator
1.75 otto 143: M r{-$-}1{-$-}2$d c {-$-}4 Add($n, $count) 640 operator
1.1 todd 144: let count=count+1
145: done
146: }
147: dnl
1.29 todd 148: dnl dodisk2(name, unit, blkmaj, chrmaj, unit, off[, stepping])
1.1 todd 149: dnl
150: dnl 1. name - prefix name of the device
151: dnl 2. unit - beginning unit number for block devices
152: dnl 3. blkmaj - block device major number
153: dnl 4. chrmaj - character device major number
154: dnl 5. unit - beginning unit number for character devices
1.80 thib 155: dnl 6. off - offset from 0 for all minor numbers
1.5 todd 156: dnl 7. step - optional, defaults to 16, number of partitions per device
1.1 todd 157: dnl
1.26 deraadt 158:
1.1 todd 159: dodisk2()
160: {
1.29 todd 161: n=Add(Mult({-$-}5, ${7:-16}), {-$-}6)
1.1 todd 162: M {-$-}1{-$-}2a b {-$-}3 $n 640 operator
163: M r{-$-}1{-$-}2a c {-$-}4 $n 640 operator
1.29 todd 164: n=Add($n, 2)
1.1 todd 165: M {-$-}1{-$-}2c b {-$-}3 $n 640 operator
166: M r{-$-}1{-$-}2c c {-$-}4 $n 640 operator
167: }
168:
169: # M name b/c major minor [mode] [group]
1.77 otto 170: RMlist[0]="rm -f"
1.26 deraadt 171:
1.1 todd 172: mkl() {
173: dnl
1.82 espie 174: dnl multi mknod
1.1 todd 175: dnl
1.82 espie 176: : {-$-}{mklist[0]:=";mknod"}
177: mklist[{-$-}{#mklist[*]}]=" -m {-$-}1 {-$-}2 {-$-}3 {-$-}4 {-$-}5"
1.1 todd 178: }
1.26 deraadt 179:
1.1 todd 180: M() {
1.77 otto 181: RMlist[{-$-}{#RMlist[*]}]={-$-}1
1.1 todd 182: mkl ${5-666} {-$-}1 {-$-}2 {-$-}3 {-$-}4
183: G={-$-}{6:-wheel}
184: [ "{-$-}7" ] && {
1.81 jasper 185: MKlist[{-$-}{#MKlist[*]}]="&& chown {-$-}7:{-$-}G {-$-}1"
1.1 todd 186: } || {
187: case $G in
1.77 otto 188: wheel)
1.81 jasper 189: [ {-$-}{#whlist[*]} = 0 ] && whlist[0]="&& chgrp wheel"
1.77 otto 190: whlist[{-$-}{#whlist[*]}]="$1"
191: ;;
192: operator)
1.81 jasper 193: [ {-$-}{#oplist[*]} = 0 ] && oplist[0]="&& chgrp operator"
1.77 otto 194: oplist[{-$-}{#oplist[*]}]="$1"
195: ;;
196: *)
1.81 jasper 197: MKlist[{-$-}{#MKlist[*]}]="&& chgrp $G $1";
1.1 todd 198: esac
199: }
200: return 0
201: }
202: divert(7)dnl
203: dnl
204: dnl there is no blank line at the end of etc.arch/MAKEDEV.md files, so add one
205: dnl on the following line:
206:
207: show_devs()dnl
208: dnl
209: divert(9)dnl
210: *)
211: echo $i: unknown device
212: ;;
213: esac
214: done
215: }
216: _recurse "$@"
1.77 otto 217: {
218: echo -n ${RMlist[*]}
219: echo -n ${mklist[*]}
220: echo -n ${MKlist[*]}
221: echo -n ${whlist[*]}
222: echo ${oplist[*]}
223: } | if [ "$eo" = "echo" ]; then
1.83 ! deraadt 224: cat
1.1 todd 225: else
1.77 otto 226: sh
1.1 todd 227: fi
1.41 todd 228: divert(3)dnl
1.1 todd 229: dnl
1.26 deraadt 230:
1.1 todd 231: R() {
1.23 todd 232: [ "$DEBUG" ] && set -x
1.1 todd 233: for i in "$@"
234: do
235: U=`unt $i`
236: [ "$U" ] || U=0
237:
238: case $i in
239: dnl