1#!/bin/sh - 2# 3# THIS FILE AUTOMATICALLY GENERATED. DO NOT EDIT. 4# generated from: 5# 6# OpenBSD: etc.luna88k/MAKEDEV.md,v 1.27 2016/04/25 20:38:11 tedu Exp 7# OpenBSD: MAKEDEV.common,v 1.86 2016/04/25 20:39:42 tedu Exp 8# OpenBSD: MAKEDEV.mi,v 1.82 2016/03/12 17:58:59 espie Exp 9# OpenBSD: MAKEDEV.sub,v 1.14 2005/02/07 06:14:18 david Exp 10# 11# 12# Copyright (c) 2001-2004 Todd T. Fries <todd@OpenBSD.org> 13# 14# Permission to use, copy, modify, and distribute this software for any 15# purpose with or without fee is hereby granted, provided that the above 16# copyright notice and this permission notice appear in all copies. 17# 18# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 19# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 20# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 21# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 22# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 23# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 24# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 25# 26# Device "make" file. Valid arguments: 27# all makes all known devices, including local devices. 28# Tries to make the ``standard'' number of each type. 29# ramdisk Ramdisk kernel devices 30# std Standard devices 31# local Configuration specific devices 32# Disks: 33# cd* ATAPI and SCSI CD-ROM drives 34# rd* "rd" pseudo-disks 35# sd* SCSI disks, including flopticals 36# vnd* "file" pseudo-disk devices 37# wd* "winchester" disk drives (ST506, IDE, ESDI, RLL, ...) 38# Tapes: 39# ch* SCSI media changers 40# st* SCSI tape drives 41# Terminal ports: 42# ttya On-board serial console port 43# tty[0-7][0-9a-f] NS16x50 serial ports 44# Pseudo terminals: 45# ptm pty master device 46# pty* Set of 62 master pseudo terminals 47# tty* Set of 62 slave pseudo terminals 48# Console ports: 49# ttyC-J* wscons display devices 50# wscons Minimal wscons devices 51# wskbd* wscons keyboards 52# wsmux wscons keyboard/mouse mux devices 53# Pointing devices: 54# wsmouse* wscons mice 55# Special purpose devices: 56# audio* Audio devices 57# bio ioctl tunnel pseudo-device 58# bpf Berkeley Packet Filter 59# diskmap Disk mapper 60# fd fd/* nodes 61# fuse Userland Filesystem 62# lcd front panel LCD display 63# pcex* PC-9801 extension board slot 64# pf* Packet Filter 65# pppx* PPP Multiplexer 66# *random In-kernel random data source 67# tun* Network tunnel driver 68# tap* Ethernet tunnel driver 69# uk* Unknown SCSI devices 70# vscsi* Virtual SCSI controller 71PATH=/sbin:/usr/sbin:/bin:/usr/bin 72T=$0 73 74# set this to echo for Echo-Only debugging 75[ "$eo" ] || eo= 76 77hex() 78{ 79 case $1 in 80 [0-9]) echo -n $1;; 81 10) echo -n a;; 82 11) echo -n b;; 83 12) echo -n c;; 84 13) echo -n d;; 85 14) echo -n e;; 86 15) echo -n f;; 87 esac 88} 89 90alph2d() 91{ 92 local t="$1" 93 local p="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" 94 local sub=${p%${t}*} 95 echo ${#sub} 96} 97 98h2d() 99{ 100 local s="$1" 101 local f=${s%*[0-9a-f]} n=${s#[0-9a-f]*} 102 103 echo $(($(_h2d $f)*16+ $(_h2d $n) )) 104} 105 106_h2d() 107{ 108 case $1 in 109 [0-9]) echo -n $1;; 110 a) echo -n 10;; 111 b) echo -n 11;; 112 c) echo -n 12;; 113 d) echo -n 13;; 114 e) echo -n 14;; 115 f) echo -n 15;; 116 esac 117} 118 119unt() 120{ 121 # XXX pdksh can't seem to deal with locally scoped variables 122 # in ${foo#$bar} expansions 123 arg="$1" 124 tmp="${arg#[a-zA-Z]*}" 125 tmp="${tmp%*[a-zA-Z]}" 126 while [ "$tmp" != "$arg" ] 127 do 128 arg=$tmp 129 tmp="${arg#[a-zA-Z]*}" 130 tmp="${tmp%*[a-zA-Z]}" 131 done 132 echo $arg 133} 134 135dodisk() 136{ 137 [ "$DEBUG" ] && set -x 138 n=$(($((${5}*${7:-16}))+${6})) count=0 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 141 do 142 M $1$2$d b $3 $(($n+$count)) 640 operator 143 M r$1$2$d c $4 $(($n+$count)) 640 operator 144 let count=count+1 145 done 146} 147 148dodisk2() 149{ 150 n=$(($(($5*${7:-16}))+$6)) 151 M $1$2a b $3 $n 640 operator 152 M r$1$2a c $4 $n 640 operator 153 n=$(($n+2)) 154 M $1$2c b $3 $n 640 operator 155 M r$1$2c c $4 $n 640 operator 156} 157 158# M name b/c major minor [mode] [group] 159RMlist[0]="rm -f" 160 161mkl() { 162 : ${mklist[0]:=";mknod"} 163 mklist[${#mklist[*]}]=" -m $1 $2 $3 $4 $5" 164} 165 166M() { 167 RMlist[${#RMlist[*]}]=$1 168 mkl ${5-666} $1 $2 $3 $4 169 G=${6:-wheel} 170 [ "$7" ] && { 171 MKlist[${#MKlist[*]}]="&& chown $7:$G $1" 172 } || { 173 case $G in 174 wheel) 175 [ ${#whlist[*]} = 0 ] && whlist[0]="&& chgrp wheel" 176 whlist[${#whlist[*]}]="$1" 177 ;; 178 operator) 179 [ ${#oplist[*]} = 0 ] && oplist[0]="&& chgrp operator" 180 oplist[${#oplist[*]}]="$1" 181 ;; 182 *) 183 MKlist[${#MKlist[*]}]="&& chgrp $G $1"; 184 esac 185 } 186 return 0 187} 188 189R() { 190[ "$DEBUG" ] && set -x 191for i in "$@" 192do 193U=`unt $i` 194[ "$U" ] || U=0 195 196case $i in 197std) 198 M console c 0 0 600 199 M tty c 1 0 200 M mem c 2 0 640 kmem 201 M kmem c 2 1 640 kmem 202 M null c 2 2 203 M zero c 2 12 204 M stdin c 21 0 205 M stdout c 21 1 206 M stderr c 21 2 207 M ksyms c 43 0 640 kmem 208 M klog c 6 0 600 209 ;; 210 211 212vscsi*) 213 M vscsi$U c 53 $U 600 214 ;; 215 216uk*) 217 M uk$U c 41 $U 640 operator 218 ;; 219 220tap*) 221 M tap$U c 56 $U 600 222 ;; 223 224tun*) 225 M tun$U c 23 $U 600 226 ;; 227 228*random) 229 n=0 230 for pre in " " s u a 231 do 232 M ${pre}random c 40 $n 644 233 n=$(($n+1)) 234 done 235 ;; 236 237pppx*) 238 M pppx$U c 55 $U 600 239 ;; 240 241pf*) 242 M pf c 39 0 600 243 ;; 244 245pcex) 246 M pcexmem c 25 0 660 247 M pcexio c 25 1 660 248 ;; 249 250lcd) 251 M lcd c 10 0 644 252 ;; 253 254fuse) 255 M fuse$U c 45 $U 600 256 ;; 257 258fd) 259 RMlist[${#RMlist[*]}]=";mkdir -p fd;rm -f" n=0 260 while [ $n -lt 64 ];do M fd/$n c 21 $n;n=$(($n+1));done 261 MKlist[${#MKlist[*]}]=";chmod 555 fd" 262 ;; 263 264diskmap) 265 M diskmap c 54 0 640 operator 266 ;; 267 268bpf) 269 M bpf c 22 0 600 270 M bpf0 c 22 0 600 271 ;; 272 273bio) 274 M bio c 49 0 600 275 ;; 276 277audio*) 278 M sound$U c 26 $U 279 M mixer$U c 26 $(($U+16)) 280 M audio$U c 26 $(($U+128)) 281 M audioctl$U c 26 $(($U+192)) 282 MKlist[${#MKlist[*]}]=";[ -e audio ] || ln -s audio$U audio" 283 MKlist[${#MKlist[*]}]=";[ -e mixer ] || ln -s mixer$U mixer" 284 MKlist[${#MKlist[*]}]=";[ -e sound ] || ln -s sound$U sound" 285 MKlist[${#MKlist[*]}]=";[ -e audioctl ] || ln -s audioctl$U audioctl" 286 ;; 287 288wsmouse[0-9]*) 289 M wsmouse$U c 15 $U 600 290 ;; 291 292wsmux|wsmouse|wskbd) 293 M wsmouse c 16 0 600 294 M wskbd c 16 1 600 295 ;; 296 297wskbd[0-9]*) 298 M wskbd$U c 14 $U 600 299 ;; 300 301wscons) 302 R wsmouse0 wsmouse1 wsmouse2 wsmouse3 wskbd0 wskbd1 wskbd2 303 R wskbd3 wsmux ttyCcfg ttyC0 ttyC1 ttyC2 ttyC3 ttyC4 ttyC5 304 R ttyC6 ttyC7 ttyC8 ttyC9 ttyCa ttyCb 305 ;; 306 307tty[C-J]*) 308 U=${i##tty[C-J]} 309 case $i in 310 ttyC*) n=C m=0;; 311 ttyD*) n=D m=256;; 312 ttyE*) n=E m=512;; 313 ttyF*) n=F m=768;; 314 ttyG*) n=G m=1024;; 315 ttyH*) n=H m=1280;; 316 ttyI*) n=I m=1536;; 317 ttyJ*) n=J m=1792;; 318 esac 319 case $U in 320 [0-9a-f]) M tty$n$U c 13 $((16#$U+$m)) 600;; 321 cfg) M tty${n}cfg c 13 $((255+$m)) 600;; 322 *) echo bad unit $U for $i; exit 1;; 323 esac 324 ;; 325 326pty*) 327 if [ $U -gt 15 ]; then 328 echo bad unit for pty in: $i 329 continue 330 fi 331 set -A letters p q r s t u v w x y z P Q R S T 332 set -A suffixes 0 1 2 3 4 5 6 7 8 9 a b c d e f g h i j k l m n o p q \ 333 r s t u v w x y z A B C D E F G H I J K L M N O P Q R S T U V W X \ 334 Y Z 335 336 name=${letters[$U]} 337 n=0 338 while [ $n -lt 62 ] 339 do 340 nam=$name${suffixes[$n]} 341 off=$(($U*62)) 342 M tty$nam c 4 $(($off+$n)) 343 M pty$nam c 5 $(($off+$n)) 344 n=$(($n+1)) 345 done 346 ;; 347 348ptm) 349 M ptm c 52 0 666 350 ;; 351 352tty[0-7][0-9a-f]) 353 U=${i#tty*} 354 o=$(h2d $U) 355 M tty$U c 27 $o 660 dialer uucp 356 M cua$U c 27 $(($o+128)) 660 dialer uucp 357 ;; 358 359ttya) 360 M ttya c 12 0 660 dialer uucp 361 M cuaa c 12 128 660 dialer uucp 362 ;; 363 364st*) 365 n=$(($U*16)) 366 for pre in " " n e en 367 do 368 M ${pre}st$U b 5 $n 660 operator 369 M ${pre}rst$U c 20 $n 660 operator 370 n=$(($n+1)) 371 done 372 ;; 373 374ch*) 375 M ch$U c 44 $U 660 operator 376 ;; 377 378vnd*) 379 dodisk vnd $U 8 19 $U 0 380 ;; 381 382rd*) 383 dodisk2 rd $U 7 18 $U 0 384 ;; 385 386cd*) 387 dodisk2 cd $U 6 9 $U 0 388 ;; 389 390local) 391 test -s $T.local && sh $T.local 392 ;; 393 394ramdisk) 395 R diskmap bio pty0 ttya rd0 cd0 cd1 st0 st1 wd0 wd1 wd2 wd3 396 R wd4 sd0 sd1 sd2 sd3 sd4 tty00 tty01 bpf std 397 ;; 398 399all) 400 R pcex audio0 lcd ttya vnd0 vnd1 vnd2 vnd3 sd0 sd1 sd2 sd3 401 R sd4 cd0 cd1 rd0 tap0 tap1 tap2 tap3 tun0 tun1 tun2 tun3 bio 402 R pty0 diskmap vscsi0 ch0 bpf fuse pppx ptm local wscons uk0 403 R random tty00 tty01 tty02 tty03 tty04 tty05 tty06 tty07 tty08 404 R tty09 tty0a tty0b pf wd0 wd1 wd2 wd3 std st0 st1 fd 405 ;; 406 407wd*|sd*) 408 case $i in 409 wd*) dodisk wd $U 9 28 $U 0;; 410 sd*) dodisk sd $U 4 8 $U 0;; 411 esac 412 ;; 413 414*) 415 echo $i: unknown device 416 ;; 417esac 418done 419} 420R "$@" 421{ 422echo -n ${RMlist[*]} 423echo -n ${mklist[*]} 424echo -n ${MKlist[*]} 425echo -n ${whlist[*]} 426echo ${oplist[*]} 427} | if [ "$eo" = "echo" ]; then 428 cat 429else 430 sh 431fi 432