xref: /openbsd/etc/MAKEDEV.mi (revision 25a960cc)
1884154f4Smioddefine(COMM,`#')dnl
2a5e63cf5Stoddinclude(MAKEDEV.sub)dnl
3a5e63cf5Stodddnl
4*25a960ccSderaadtvers(a, {-$OpenBSD: MAKEDEV.mi,v 1.83 2016/09/11 03:06:31 deraadt Exp $-})dnl
5a5e63cf5Stodddnl
6a5e63cf5Stodddivert(1)dnl
7a5e63cf5Stodd{-#-}
82c1f0813Stodd{-#-} Copyright (c) 2001-2004 Todd T. Fries <todd@OpenBSD.org>
9a5e63cf5Stodd{-#-}
103632945aStodd{-#-} Permission to use, copy, modify, and distribute this software for any
113632945aStodd{-#-} purpose with or without fee is hereby granted, provided that the above
123632945aStodd{-#-} copyright notice and this permission notice appear in all copies.
13a5e63cf5Stodd{-#-}
143632945aStodd{-#-} THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
153632945aStodd{-#-} WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
163632945aStodd{-#-} MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
173632945aStodd{-#-} ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
183632945aStodd{-#-} WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
193632945aStodd{-#-} ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
203632945aStodd{-#-} OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
21a5e63cf5Stodd{-#-}
22884154f4Smioddefine(quote,{-"$1" -})dnl
23884154f4Smiodinclude(MAKEDEV.common)dnl
24a5e63cf5Stodddnl
25884154f4Smiod__devtitle(make, {-Device "make" file.  Valid arguments-})dnl
26884154f4Smiod__devitem({-all-}, {-all-}, {-makes all known devices{-,-} including local devices.
27a5e63cf5Stodd{-#-}		Tries to make the ``standard'' number of each type.-})dnl
28884154f4Smiod__devitem(std,{-std-},Standard devices)dnl
29884154f4Smiod__devitem(local,local,Configuration specific devices)dnl
307953ad03Stodddnl
31a5e63cf5Stodddnl _std
32a5e63cf5Stodddnl
33a5e63cf5Stodddnl $1: tty
34a5e63cf5Stodddnl $2: memstuff
35a5e63cf5Stodddnl $3: ksyms
36d8bf3db4Smioddnl $4: klog
37a5e63cf5Stodddnl
38a5e63cf5Stodddefine({-_std-},{-dnl
39a5e63cf5Stoddstd)
40a5e63cf5Stodd	M console	c 0 0 600
41a5e63cf5Stodd	M tty		c $1 0
42a5e63cf5Stodd	M mem		c $2 0 640 kmem
43a5e63cf5Stodd	M kmem		c $2 1 640 kmem
44a5e63cf5Stodd	M null		c $2 2
45a5e63cf5Stodd	M zero		c $2 12
46a5e63cf5Stodd	M stdin		c major_fdesc_c 0
47a5e63cf5Stodd	M stdout	c major_fdesc_c 1
48a5e63cf5Stodd	M stderr	c major_fdesc_c 2
49a5e63cf5Stodd	M ksyms		c $3 0 640 kmem
50d8bf3db4Smiod	M klog		c $4 0 600-})dnl
51a5e63cf5Stodddnl
52a5e63cf5Stodddivert(1)dnl
53884154f4Smioddefine(__mddivert,7)dnl
54e5e1c7efStoddinclude(MAKEDEV.md)dnl
55a5e63cf5Stodddnl
56a5e63cf5Stodddnl
57a5e63cf5Stodddivert(0)dnl
58a5e63cf5Stodd#!/bin/sh -
59a5e63cf5Stodd#
60a5e63cf5Stodd# THIS FILE AUTOMATICALLY GENERATED.  DO NOT EDIT.
61a5e63cf5Stodd# generated from:
62a5e63cf5Stodd#
63a5e63cf5Stoddshow_vers()dnl <-- now that all files are included, show versions
64a5e63cf5Stodd#
65a5e63cf5Stodddnl
66a5e63cf5Stodddivert(2)dnl
67a5e63cf5StoddPATH=/sbin:/usr/sbin:/bin:/usr/bin
68a5e63cf5StoddT=$0
69a5e63cf5Stodd
70a5e63cf5Stodd# set this to echo for Echo-Only debugging
71a5e63cf5Stodd[ "$eo" ] || eo=
72a5e63cf5Stodd
73a5e63cf5Stoddhex()
74a5e63cf5Stodd{
75a5e63cf5Stodd	case ${--}1 in
76a5e63cf5Stodd	[0-9]) echo -n {-$-}1;;
77a5e63cf5Stodd	10) echo -n a;;
78a5e63cf5Stodd	11) echo -n b;;
79a5e63cf5Stodd	12) echo -n c;;
80a5e63cf5Stodd	13) echo -n d;;
81a5e63cf5Stodd	14) echo -n e;;
82a5e63cf5Stodd	15) echo -n f;;
83a5e63cf5Stodd	esac
84a5e63cf5Stodd}
85ee7baf74Sderaadt
86ac8c3c2cStoddalph2d()
87ac8c3c2cStodd{
88ac8c3c2cStodd	local t="$1"
89ac8c3c2cStodd	local p="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
90ac8c3c2cStodd	local sub=${p%${t}*}
91ac8c3c2cStodd	echo ${#sub}
92ac8c3c2cStodd}
93ac8c3c2cStodd
942495cbffStoddh2d()
95a5e63cf5Stodd{
962495cbffStodd	local s="$1"
972495cbffStodd	local f=${s%*[0-9a-f]} n=${s#[0-9a-f]*}
982495cbffStodd
992495cbffStodd	echo $(($(_h2d $f)*16+ $(_h2d $n) ))
1002495cbffStodd}
1012495cbffStodd
1022495cbffStodd_h2d()
1032495cbffStodd{
1042495cbffStodd	case $1 in
1052495cbffStodd	[0-9]) echo -n $1;;
1062495cbffStodd	a) echo -n 10;;
1072495cbffStodd	b) echo -n 11;;
1082495cbffStodd	c) echo -n 12;;
1092495cbffStodd	d) echo -n 13;;
1102495cbffStodd	e) echo -n 14;;
1112495cbffStodd	f) echo -n 15;;
112a5e63cf5Stodd	esac
113a5e63cf5Stodd}
114ee7baf74Sderaadt
115a5e63cf5Stoddunt()
116a5e63cf5Stodd{
117a5e63cf5Stodd	# XXX pdksh can't seem to deal with locally scoped variables
118a5e63cf5Stodd	# in ${foo#$bar} expansions
119a5e63cf5Stodd	arg="{-$-}1"
120a5e63cf5Stodd	tmp="${arg#[a-zA-Z]*}"
121a5e63cf5Stodd	tmp="${tmp%*[a-zA-Z]}"
122a5e63cf5Stodd	while [ "$tmp" != "$arg" ]
123a5e63cf5Stodd	do
124a5e63cf5Stodd		arg=$tmp
125a5e63cf5Stodd		tmp="${arg#[a-zA-Z]*}"
126a5e63cf5Stodd		tmp="${tmp%*[a-zA-Z]}"
127a5e63cf5Stodd	done
128a5e63cf5Stodd	echo $arg
129a5e63cf5Stodd}
130a5e63cf5Stodddnl
13130d6f335Stodddnl dodisk(name, unit, blkmaj, chrmaj, unit, off[, stepping])
13230d6f335Stodddnl   arg: 1    2    3      4      5    6    7
133a5e63cf5Stodddnl
134ee7baf74Sderaadt
135a5e63cf5Stodddodisk()
136a5e63cf5Stodd{
137b031a4cbStodd	[ "$DEBUG" ] && set -x
13830d6f335Stodd	n=Add(Mult(${5}, ${7:-16}), ${6}) count=0
13930941efeStodd	[ 0$7 -ne 8 ] && l="i j k l m n o p"
14030941efeStodd	for d in a b c d e f g h $l
141a5e63cf5Stodd	do
142088078d6Sotto		M {-$-}1{-$-}2$d	b {-$-}3 Add($n, $count) 640 operator
14379a9b89fSotto		M r{-$-}1{-$-}2$d	c {-$-}4 Add($n, $count) 640 operator
144a5e63cf5Stodd		let count=count+1
145a5e63cf5Stodd	done
146a5e63cf5Stodd}
147a5e63cf5Stodddnl
14830d6f335Stodddnl dodisk2(name, unit, blkmaj, chrmaj, unit, off[, stepping])
149a5e63cf5Stodddnl
150a5e63cf5Stodddnl 1. name    - prefix name of the device
151a5e63cf5Stodddnl 2. unit    - beginning unit number for block devices
152a5e63cf5Stodddnl 3. blkmaj  - block device major number
153a5e63cf5Stodddnl 4. chrmaj  - character device major number
154a5e63cf5Stodddnl 5. unit    - beginning unit number for character devices
155a4975643Sthibdnl 6. off     - offset from 0 for all minor numbers
15630d6f335Stodddnl 7. step    - optional, defaults to 16, number of partitions per device
157a5e63cf5Stodddnl
158ee7baf74Sderaadt
159a5e63cf5Stodddodisk2()
160a5e63cf5Stodd{
16130d6f335Stodd	n=Add(Mult({-$-}5, ${7:-16}), {-$-}6)
162a5e63cf5Stodd	M {-$-}1{-$-}2a b {-$-}3 $n 640 operator
163a5e63cf5Stodd	M r{-$-}1{-$-}2a c {-$-}4 $n 640 operator
164a5e63cf5Stodd	n=Add($n, 2)
165a5e63cf5Stodd	M {-$-}1{-$-}2c b {-$-}3 $n 640 operator
166a5e63cf5Stodd	M r{-$-}1{-$-}2c c {-$-}4 $n 640 operator
167a5e63cf5Stodd}
168a5e63cf5Stodd
169a5e63cf5Stodd# M name b/c major minor [mode] [group]
170449c2895SottoRMlist[0]="rm -f"
171ee7baf74Sderaadt
172a5e63cf5Stoddmkl() {
173a5e63cf5Stodddnl
1748ff8729aSespiednl multi mknod
175a5e63cf5Stodddnl
1768ff8729aSespie	: {-$-}{mklist[0]:=";mknod"}
1778ff8729aSespie	mklist[{-$-}{#mklist[*]}]=" -m {-$-}1 {-$-}2 {-$-}3 {-$-}4 {-$-}5"
178a5e63cf5Stodd}
179ee7baf74Sderaadt
180a5e63cf5StoddM() {
181449c2895Sotto	RMlist[{-$-}{#RMlist[*]}]={-$-}1
182a5e63cf5Stodd	mkl ${5-666} {-$-}1 {-$-}2 {-$-}3 {-$-}4
183a5e63cf5Stodd	G={-$-}{6:-wheel}
184a5e63cf5Stodd	[ "{-$-}7" ] && {
185c68ed997Sjasper		MKlist[{-$-}{#MKlist[*]}]="&& chown {-$-}7:{-$-}G {-$-}1"
186a5e63cf5Stodd	} || {
187a5e63cf5Stodd		case $G in
188449c2895Sotto		wheel)
189c68ed997Sjasper			[ {-$-}{#whlist[*]} = 0 ] && whlist[0]="&& chgrp wheel"
190449c2895Sotto			whlist[{-$-}{#whlist[*]}]="$1"
191449c2895Sotto		;;
192449c2895Sotto		operator)
193c68ed997Sjasper			[ {-$-}{#oplist[*]} = 0 ] && oplist[0]="&& chgrp operator"
194449c2895Sotto			oplist[{-$-}{#oplist[*]}]="$1"
195449c2895Sotto		;;
196449c2895Sotto		*)
197c68ed997Sjasper			MKlist[{-$-}{#MKlist[*]}]="&& chgrp $G $1";
198a5e63cf5Stodd		esac
199a5e63cf5Stodd	}
200a5e63cf5Stodd	return 0
201a5e63cf5Stodd}
202a5e63cf5Stodddivert(7)dnl
203a5e63cf5Stodddnl
204a5e63cf5Stodddnl there is no blank line at the end of etc.arch/MAKEDEV.md files, so add one
205a5e63cf5Stodddnl on the following line:
206a5e63cf5Stodd
207a5e63cf5Stoddshow_devs()dnl
208a5e63cf5Stodddnl
209a5e63cf5Stodddivert(9)dnl
210a5e63cf5Stodd*)
211a5e63cf5Stodd	echo $i: unknown device
212a5e63cf5Stodd	;;
213a5e63cf5Stoddesac
214a5e63cf5Stodddone
215a5e63cf5Stodd}
216a5e63cf5Stodd_recurse "$@"
217449c2895Sotto{
218449c2895Sottoecho -n ${RMlist[*]}
219449c2895Sottoecho -n ${mklist[*]}
220449c2895Sottoecho -n ${MKlist[*]}
221449c2895Sottoecho -n ${whlist[*]}
222449c2895Sottoecho ${oplist[*]}
223449c2895Sotto} | if [ "$eo" = "echo" ]; then
224449c2895Sotto	cat
225a5e63cf5Stoddelse
226449c2895Sotto	sh
227a5e63cf5Stoddfi
228a5e63cf5Stodddivert(3)dnl
229a5e63cf5Stodddnl
230ee7baf74Sderaadt
231a5e63cf5StoddR() {
232f4a88671Stodd[ "$DEBUG" ] && set -x
233a5e63cf5Stoddfor i in "$@"
234a5e63cf5Stodddo
235a5e63cf5StoddU=`unt $i`
236a5e63cf5Stodd[ "$U" ] || U=0
237a5e63cf5Stodd
238a5e63cf5Stoddcase $i in
239a5e63cf5Stodddnl
240