1#!/bin/sh - 2# 3# THIS FILE AUTOMATICALLY GENERATED. DO NOT EDIT. 4# generated from: 5# 6# OpenBSD: etc.macppc/MAKEDEV.md,v 1.63 2014/12/11 19:48:03 tedu Exp 7# OpenBSD: MAKEDEV.common,v 1.78 2014/12/11 19:46:15 tedu Exp 8# OpenBSD: MAKEDEV.mi,v 1.81 2012/11/05 08:07:09 jasper 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# cua[a-z]* Zilog 8530 serial ports 43# tty[0-7][0-9a-f] NS16x50 serial ports 44# tty[a-z]* Zilog 8530 serial ports 45# Pseudo terminals: 46# ptm pty master device 47# pty* Set of 62 master pseudo terminals 48# tty* Set of 62 slave pseudo terminals 49# Console ports: 50# wscons Minimal wscons devices 51# ttyC-J* wscons display devices 52# wskbd* wscons keyboards 53# wsmux wscons keyboard/mouse mux devices 54# Pointing devices: 55# wsmouse* wscons mice 56# USB devices: 57# uall All USB devices 58# ttyU* USB serial ports 59# ugen* Generic USB devices 60# uhid* Generic HID devices 61# ulpt* Printer devices 62# usb* Bus control devices used by usbd for attach/detach 63# Special purpose devices: 64# apm Power management device 65# audio* Audio devices 66# bio ioctl tunnel pseudo-device 67# bktr* Video frame grabbers 68# bpf* Berkeley Packet Filter 69# diskmap Disk mapper 70# drm* Direct Rendering Manager 71# fd fd/* nodes 72# fuse Userland Filesystem 73# gpio* General Purpose Input/Output 74# hotplug devices hot plugging 75# pci* PCI bus devices 76# pf* Packet Filter 77# pppx* PPP Multiplexer 78# radio* FM tuner devices 79# *random In-kernel random data source 80# rmidi* Raw MIDI devices 81# systrace* System call tracing device 82# tun* Network tunnel driver 83# tuner* Tuner devices 84# uk* Unknown SCSI devices 85# video* Video V4L2 devices 86# vscsi* Virtual SCSI controller 87PATH=/sbin:/usr/sbin:/bin:/usr/bin 88T=$0 89 90# set this to echo for Echo-Only debugging 91[ "$eo" ] || eo= 92 93hex() 94{ 95 case $1 in 96 [0-9]) echo -n $1;; 97 10) echo -n a;; 98 11) echo -n b;; 99 12) echo -n c;; 100 13) echo -n d;; 101 14) echo -n e;; 102 15) echo -n f;; 103 esac 104} 105 106alph2d() 107{ 108 local t="$1" 109 local p="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" 110 local sub=${p%${t}*} 111 echo ${#sub} 112} 113 114h2d() 115{ 116 local s="$1" 117 local f=${s%*[0-9a-f]} n=${s#[0-9a-f]*} 118 119 echo $(($(_h2d $f)*16+ $(_h2d $n) )) 120} 121 122_h2d() 123{ 124 case $1 in 125 [0-9]) echo -n $1;; 126 a) echo -n 10;; 127 b) echo -n 11;; 128 c) echo -n 12;; 129 d) echo -n 13;; 130 e) echo -n 14;; 131 f) echo -n 15;; 132 esac 133} 134 135unt() 136{ 137 # XXX pdksh can't seem to deal with locally scoped variables 138 # in ${foo#$bar} expansions 139 arg="$1" 140 tmp="${arg#[a-zA-Z]*}" 141 tmp="${tmp%*[a-zA-Z]}" 142 while [ "$tmp" != "$arg" ] 143 do 144 arg=$tmp 145 tmp="${arg#[a-zA-Z]*}" 146 tmp="${tmp%*[a-zA-Z]}" 147 done 148 echo $arg 149} 150 151dodisk() 152{ 153 [ "$DEBUG" ] && set -x 154 n=$(($((${5}*${7:-16}))+${6})) count=0 155 [ 0$7 -ne 8 ] && l="i j k l m n o p" 156 for d in a b c d e f g h $l 157 do 158 M $1$2$d b $3 $(($n+$count)) 640 operator 159 M r$1$2$d c $4 $(($n+$count)) 640 operator 160 let count=count+1 161 done 162} 163 164dodisk2() 165{ 166 n=$(($(($5*${7:-16}))+$6)) 167 M $1$2a b $3 $n 640 operator 168 M r$1$2a c $4 $n 640 operator 169 n=$(($n+2)) 170 M $1$2c b $3 $n 640 operator 171 M r$1$2c c $4 $n 640 operator 172} 173 174# M name b/c major minor [mode] [group] 175RMlist[0]="rm -f" 176 177mkl() { 178 mklist[${#mklist[*]}]=";mknod -m $1 $2 $3 $4 $5" 179} 180 181M() { 182 RMlist[${#RMlist[*]}]=$1 183 mkl ${5-666} $1 $2 $3 $4 184 G=${6:-wheel} 185 [ "$7" ] && { 186 MKlist[${#MKlist[*]}]="&& chown $7:$G $1" 187 } || { 188 case $G in 189 wheel) 190 [ ${#whlist[*]} = 0 ] && whlist[0]="&& chgrp wheel" 191 whlist[${#whlist[*]}]="$1" 192 ;; 193 operator) 194 [ ${#oplist[*]} = 0 ] && oplist[0]="&& chgrp operator" 195 oplist[${#oplist[*]}]="$1" 196 ;; 197 *) 198 MKlist[${#MKlist[*]}]="&& chgrp $G $1"; 199 esac 200 } 201 return 0 202} 203 204R() { 205[ "$DEBUG" ] && set -x 206for i in "$@" 207do 208U=`unt $i` 209[ "$U" ] || U=0 210 211case $i in 212std) 213 M console c 0 0 600 214 M tty c 1 0 215 M mem c 2 0 640 kmem 216 M kmem c 2 1 640 kmem 217 M null c 2 2 218 M zero c 2 12 219 M stdin c 21 0 220 M stdout c 21 1 221 M stderr c 21 2 222 M ksyms c 43 0 640 kmem 223 M klog c 6 0 600 224 M xf86 c 2 4 600 225 M openprom c 82 0 600 226 ;; 227 228 229vscsi*) 230 M vscsi$U c 83 $U 600 231 ;; 232 233video*) 234 M video$U c 45 $U 235 MKlist[${#MKlist[*]}]=";[ -e video ] || ln -s video$U video" 236 ;; 237 238uk*) 239 M uk$U c 41 $U 640 operator 240 ;; 241 242tuner*) 243 M tuner$U c 75 $(($(($U*2))+16)) 644 244 ;; 245 246tun*) 247 M tun$U c 23 $U 600 248 ;; 249 250systrace) 251 M systrace c 50 0 644 252 ;; 253 254rmidi*) 255 M rmidi$U c 52 $U 666 256 ;; 257 258*random) 259 n=0 260 for pre in " " s u a 261 do 262 M ${pre}random c 40 $n 644 263 n=$(($n+1)) 264 done 265 ;; 266 267radio*) 268 M radio$U c 76 $U 269 MKlist[${#MKlist[*]}]=";[ -e radio ] || ln -s radio$U radio" 270 ;; 271 272pppx*) 273 M pppx$U c 85 $U 600 274 ;; 275 276pf*) 277 M pf c 39 0 600 278 ;; 279 280pci*) 281 M pci$U c 71 $U 600 282 MKlist[${#MKlist[*]}]=";[ -h pci ] || ln -sf pci0 pci" 283 ;; 284 285hotplug) 286 M hotplug c 78 $U 400 287 ;; 288 289gpio*) 290 M gpio$U c 79 $U 600 291 ;; 292 293fuse) 294 M fuse$U c 88 $U 600 295 ;; 296 297fd) 298 RMlist[${#RMlist[*]}]=";mkdir -p fd;rm -f" n=0 299 while [ $n -lt 64 ];do M fd/$n c 21 $n;n=$(($n+1));done 300 MKlist[${#MKlist[*]}]=";chmod 555 fd" 301 ;; 302 303drm*) 304 M drm$U c 87 $U 600 305 ;; 306 307diskmap) 308 M diskmap c 84 0 640 operator 309 ;; 310 311bpf*) 312 M bpf$U c 22 $U 600 313 ;; 314 315bktr*) 316 M bktr$U c 75 $U 644 317 ;; 318 319bio) 320 M bio c 80 0 600 321 ;; 322 323audio*) 324 M sound$U c 44 $U 325 M mixer$U c 44 $(($U+16)) 326 M audio$U c 44 $(($U+128)) 327 M audioctl$U c 44 $(($U+192)) 328 MKlist[${#MKlist[*]}]=";[ -e audio ] || ln -s audio$U audio" 329 MKlist[${#MKlist[*]}]=";[ -e mixer ] || ln -s mixer$U mixer" 330 MKlist[${#MKlist[*]}]=";[ -e sound ] || ln -s sound$U sound" 331 MKlist[${#MKlist[*]}]=";[ -e audioctl ] || ln -s audioctl$U audioctl" 332 ;; 333 334apm*) 335 M apm c 25 0 644 336 M apmctl c 25 8 644 337 ;; 338 339usb*) 340 [ "$i" = "usb" ] && u= || u=$U 341 M usb$u c 61 $U 660 342 ;; 343 344ulpt*) 345 M ulpt$U c 64 $U 660 346 ;; 347 348uhid*) 349 M uhid$U c 62 $U 660 350 ;; 351 352ugen*) 353 n=$(($U*16)) 354 for j in 0{0,1,2,3,4,5,6,7,8,9} 1{0,1,2,3,4,5} 355 do 356 M ugen$U.$j c 63 $(($n+10#$j)) 660 357 done 358 ;; 359 360ttyU[0-9a-zA-Z]) 361 U=${i#ttyU*} 362 o=$(alph2d $U) 363 M ttyU$U c 66 $o 660 dialer uucp 364 M cuaU$U c 66 $(($o+128)) 660 dialer uucp 365 ;; 366 367uall) 368 R ttyU0 ttyU1 ttyU2 ttyU3 ugen0 ugen1 ugen2 ugen3 ugen4 ugen5 369 R ugen6 ugen7 ulpt0 ulpt1 uhid0 uhid1 uhid2 uhid3 usb0 usb1 370 R usb2 usb3 usb4 usb5 usb6 usb7 371 ;; 372 373wsmouse[0-9]*) 374 M wsmouse$U c 69 $U 600 375 ;; 376 377wsmux|wsmouse|wskbd) 378 M wsmouse c 70 0 600 379 M wskbd c 70 1 600 380 ;; 381 382wskbd[0-9]*) 383 M wskbd$U c 68 $U 600 384 ;; 385 386tty[C-J]*) 387 U=${i##tty[C-J]} 388 case $i in 389 ttyC*) n=C m=0;; 390 ttyD*) n=D m=256;; 391 ttyE*) n=E m=512;; 392 ttyF*) n=F m=768;; 393 ttyG*) n=G m=1024;; 394 ttyH*) n=H m=1280;; 395 ttyI*) n=I m=1536;; 396 ttyJ*) n=J m=1792;; 397 esac 398 case $U in 399 [0-9a-f]) M tty$n$U c 67 $((16#$U+$m)) 600;; 400 cfg) M tty${n}cfg c 67 $((255+$m)) 600;; 401 *) echo bad unit $U for $i; exit 1;; 402 esac 403 ;; 404 405wscons) 406 R wsmouse0 wsmouse1 wsmouse2 wsmouse3 wskbd0 wskbd1 wskbd2 407 R wskbd3 wsmux ttyCcfg ttyC0 ttyC1 ttyC2 ttyC3 ttyC4 ttyC5 408 R ttyC6 ttyC7 ttyC8 ttyC9 ttyCa ttyCb 409 ;; 410 411pty*) 412 if [ $U -gt 15 ]; then 413 echo bad unit for pty in: $i 414 continue 415 fi 416 set -A letters p q r s t u v w x y z P Q R S T 417 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 \ 418 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 \ 419 Y Z 420 421 name=${letters[$U]} 422 n=0 423 while [ $n -lt 62 ] 424 do 425 nam=$name${suffixes[$n]} 426 off=$(($U*62)) 427 M tty$nam c 4 $(($off+$n)) 428 M pty$nam c 5 $(($off+$n)) 429 n=$(($n+1)) 430 done 431 ;; 432 433ptm) 434 M ptm c 77 0 666 435 ;; 436 437tty[a-z]) 438 u=${i#tty*} 439 case $u in 440 a) n=0 ;; 441 b) n=1 ;; 442 *) echo unknown tty device $i ;; 443 esac 444 M tty$u c 7 $n 660 dialer uucp 445 ;; 446 447tty[0-7][0-9a-f]) 448 U=${i#tty*} 449 o=$(h2d $U) 450 M tty$U c 26 $o 660 dialer uucp 451 M cua$U c 26 $(($o+128)) 660 dialer uucp 452 ;; 453 454cua[a-z]) 455 u=${i#cua*} 456 case $u in 457 a) n=0 ;; 458 b) n=1 ;; 459 *) echo unknown cua device $i ;; 460 esac 461 M cua$u c 7 $(($n+128)) 660 dialer uucp 462 ;; 463 464st*) 465 n=$(($U*16)) 466 for pre in " " n e en 467 do 468 M ${pre}st$U b 5 $n 660 operator 469 M ${pre}rst$U c 20 $n 660 operator 470 n=$(($n+1)) 471 done 472 ;; 473 474ch*) 475 M ch$U c 10 $U 660 operator 476 ;; 477 478vnd*) 479 dodisk vnd $U 14 19 $U 0 480 ;; 481 482rd*) 483 dodisk2 rd $U 17 17 $U 0 484 ;; 485 486cd*) 487 dodisk2 cd $U 3 9 $U 0 488 ;; 489 490local) 491 test -s $T.local && sh $T.local 492 ;; 493 494ramdisk) 495 R diskmap bio pty0 rd0 cd0 cd1 st0 st1 wd0 wd1 wd2 wd3 wd4 496 R sd0 sd1 sd2 sd3 sd4 tty00 tty01 bpf0 std 497 ;; 498 499all) 500 R drm0 drm1 drm2 drm3 bio gpio0 gpio1 gpio2 vnd0 vnd1 vnd2 501 R vnd3 sd0 sd1 sd2 sd3 sd4 sd5 sd6 sd7 sd8 sd9 cd0 cd1 rd0 502 R tun0 tun1 tun2 tun3 bpf0 bpf1 bpf2 bpf3 bpf4 bpf5 bpf6 bpf7 503 R bpf8 bpf9 pty0 diskmap vscsi0 ch0 cuaa cuab ttya ttyb audio0 504 R audio1 audio2 fuse pppx hotplug ptm local wscons pci0 pci1 505 R pci2 pci3 uall rmidi0 rmidi1 rmidi2 rmidi3 rmidi4 rmidi5 506 R rmidi6 rmidi7 tuner0 radio0 video0 video1 uk0 random tty00 507 R tty01 tty02 tty03 tty04 tty05 tty06 tty07 tty08 tty09 tty0a 508 R tty0b apm pf systrace wd0 wd1 wd2 wd3 std st0 st1 fd 509 ;; 510 511wd*|sd*) 512 case $i in 513 wd*) dodisk wd $U 0 11 $U 0;; 514 sd*) dodisk sd $U 2 8 $U 0;; 515 esac 516 ;; 517 518*) 519 echo $i: unknown device 520 ;; 521esac 522done 523} 524R "$@" 525{ 526echo -n ${RMlist[*]} 527echo -n ${mklist[*]} 528echo -n ${MKlist[*]} 529echo -n ${whlist[*]} 530echo ${oplist[*]} 531} | if [ "$eo" = "echo" ]; then 532 cat 533else 534 sh 535fi 536