1#!/bin/sh - 2# 3# THIS FILE AUTOMATICALLY GENERATED. DO NOT EDIT. 4# generated from: 5# 6# OpenBSD: etc.alpha/MAKEDEV.md,v 1.78 2021/11/11 09:47:32 claudio Exp 7# OpenBSD: MAKEDEV.common,v 1.120 2023/01/28 11:04:47 phessler Exp 8# OpenBSD: MAKEDEV.mi,v 1.83 2016/09/11 03:06:31 deraadt 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# fd* Floppy disk drives (3 1/2", 5 1/4") 35# rd* "rd" pseudo-disks 36# sd* SCSI disks, including flopticals 37# vnd* "file" pseudo-disk devices 38# wd* "winchester" disk drives (ST506, IDE, ESDI, RLL, ...) 39# Tapes: 40# ch* SCSI media changers 41# st* SCSI tape drives 42# Terminal ports: 43# tty[0-7][0-9a-f] NS16x50 serial ports 44# ttyc* Cyclades serial ports 45# ttyB* DEC 3000 serial ports 46# Pseudo terminals: 47# ptm pty master device 48# pty* Set of 62 master pseudo terminals 49# tty* Set of 62 slave pseudo terminals 50# Console ports: 51# ttyC-J* wscons display devices 52# wscons Minimal wscons devices 53# wskbd* wscons keyboards 54# wsmux wscons keyboard/mouse mux devices 55# Pointing devices: 56# wsmouse* wscons mice 57# Printers: 58# lpa* Polled printer port 59# lpt* IEEE 1284 centronics printer 60# USB devices: 61# ttyU* USB serial ports 62# uall All USB devices 63# ugen* Generic USB devices 64# uhid* Generic HID devices 65# fido fido/* nodes 66# ujoy ujoy/* nodes 67# ulpt* Printer devices 68# usb* Bus control devices used by usbd for attach/detach 69# Special purpose devices: 70# audio* Audio devices 71# bio ioctl tunnel pseudo-device 72# bktr* Video frame grabbers 73# bpf Berkeley Packet Filter 74# diskmap Disk mapper 75# dt Dynamic Tracer 76# fd fd/* nodes 77# fuse Userland Filesystem 78# hotplug devices hot plugging 79# pci* PCI bus devices 80# pf Packet Filter 81# pppx* PPP Multiplexer 82# pppac* PPP Access Concentrator 83# radio* FM tuner devices 84# *random In-kernel random data source 85# rmidi* Raw MIDI devices 86# speaker PC speaker 87# tun* Network tunnel driver 88# tap* Ethernet tunnel driver 89# tuner* Tuner devices 90# uk* Unknown SCSI devices 91# video* Video V4L2 devices 92# vscsi* Virtual SCSI controller 93# kstat Kernel Statistics 94PATH=/sbin:/usr/sbin:/bin:/usr/bin 95T=$0 96 97# set this to echo for Echo-Only debugging 98[ "$eo" ] || eo= 99 100hex() 101{ 102 case $1 in 103 [0-9]) echo -n $1;; 104 10) echo -n a;; 105 11) echo -n b;; 106 12) echo -n c;; 107 13) echo -n d;; 108 14) echo -n e;; 109 15) echo -n f;; 110 esac 111} 112 113alph2d() 114{ 115 local t="$1" 116 local p="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" 117 local sub=${p%${t}*} 118 echo ${#sub} 119} 120 121h2d() 122{ 123 local s="$1" 124 local f=${s%*[0-9a-f]} n=${s#[0-9a-f]*} 125 126 echo $(($(_h2d $f)*16+ $(_h2d $n) )) 127} 128 129_h2d() 130{ 131 case $1 in 132 [0-9]) echo -n $1;; 133 a) echo -n 10;; 134 b) echo -n 11;; 135 c) echo -n 12;; 136 d) echo -n 13;; 137 e) echo -n 14;; 138 f) echo -n 15;; 139 esac 140} 141 142unt() 143{ 144 # XXX pdksh can't seem to deal with locally scoped variables 145 # in ${foo#$bar} expansions 146 arg="$1" 147 tmp="${arg#[a-zA-Z]*}" 148 tmp="${tmp%*[a-zA-Z]}" 149 while [ "$tmp" != "$arg" ] 150 do 151 arg=$tmp 152 tmp="${arg#[a-zA-Z]*}" 153 tmp="${tmp%*[a-zA-Z]}" 154 done 155 echo $arg 156} 157 158dodisk() 159{ 160 [ "$DEBUG" ] && set -x 161 n=$(($((${5}*${7:-16}))+${6})) count=0 162 [ 0$7 -ne 8 ] && l="i j k l m n o p" 163 for d in a b c d e f g h $l 164 do 165 M $1$2$d b $3 $(($n+$count)) 640 operator 166 M r$1$2$d c $4 $(($n+$count)) 640 operator 167 let count=count+1 168 done 169} 170 171dodisk2() 172{ 173 n=$(($(($5*${7:-16}))+$6)) 174 M $1$2a b $3 $n 640 operator 175 M r$1$2a c $4 $n 640 operator 176 n=$(($n+2)) 177 M $1$2c b $3 $n 640 operator 178 M r$1$2c c $4 $n 640 operator 179} 180 181# M name b/c major minor [mode] [group] 182RMlist[0]="rm -f" 183 184mkl() { 185 : ${mklist[0]:=";mknod"} 186 mklist[${#mklist[*]}]=" -m $1 $2 $3 $4 $5" 187} 188 189M() { 190 RMlist[${#RMlist[*]}]=$1 191 mkl ${5-666} $1 $2 $3 $4 192 G=${6:-wheel} 193 [ "$7" ] && { 194 MKlist[${#MKlist[*]}]="&& chown $7:$G $1" 195 } || { 196 case $G in 197 wheel) 198 [ ${#whlist[*]} = 0 ] && whlist[0]="&& chgrp wheel" 199 whlist[${#whlist[*]}]="$1" 200 ;; 201 operator) 202 [ ${#oplist[*]} = 0 ] && oplist[0]="&& chgrp operator" 203 oplist[${#oplist[*]}]="$1" 204 ;; 205 *) 206 MKlist[${#MKlist[*]}]="&& chgrp $G $1"; 207 esac 208 } 209 return 0 210} 211 212R() { 213[ "$DEBUG" ] && set -x 214for i in "$@" 215do 216U=`unt $i` 217[ "$U" ] || U=0 218 219case $i in 220ramdisk) 221 R std fd0 wd0 wd1 wd2 sd0 sd1 sd2 bpf 222 R st0 cd0 ttyC0 rd0 bio diskmap random 223 ;; 224 225std) 226 M console c 0 0 600 227 M tty c 1 0 228 M mem c 2 0 640 kmem 229 M kmem c 2 1 640 kmem 230 M null c 2 2 231 M zero c 2 12 232 M stdin c 10 0 233 M stdout c 10 1 234 M stderr c 10 2 235 M ksyms c 39 0 640 kmem 236 M klog c 6 0 600 237 M xf86 c 2 4 600 238 ;; 239 240ttyB*|ttyc*) 241 U=${i##tty?} 242 case $i in 243 ttyB*) type=B major=15 minor=$U;; 244 ttyc*) type=c major=38 minor=$U;; 245 esac 246 M tty$type$U c $major $minor 660 dialer root 247 M cua$type$U c $major $(($minor+128)) 660 dialer root 248 ;; 249 250kstat) 251 M kstat c 51 0 640 252 ;; 253 254vscsi*) 255 M vscsi$U c 61 $U 600 256 ;; 257 258video*) 259 M video$U c 44 $U 600 260 MKlist[${#MKlist[*]}]=";[ -e video ] || ln -s video$U video" 261 ;; 262 263uk*) 264 M uk$U c 33 $U 640 operator 265 ;; 266 267tuner*) 268 M tuner$U c 58 $(($(($U*2))+16)) 644 269 ;; 270 271tap*) 272 M tap$U c 68 $U 600 273 ;; 274 275tun*) 276 M tun$U c 7 $U 600 277 ;; 278 279speaker) 280 M speaker c 40 0 600 281 ;; 282 283rmidi*) 284 M rmidi$U c 41 $U 660 _sndiop 285 ;; 286 287*random) 288 M urandom c 34 0 644 289 RMlist[${#RMlist[*]}]=random 290 MKlist[${#MKlist[*]}]=";ln -s urandom random" 291 ;; 292 293radio*) 294 M radio$U c 59 $U 295 MKlist[${#MKlist[*]}]=";[ -e radio ] || ln -s radio$U radio" 296 ;; 297 298pppac*) 299 M pppac$U c 71 $U 600 300 ;; 301 302pppx*) 303 M pppx$U c 64 $U 600 304 ;; 305 306pf) 307 M pf c 35 0 600 308 ;; 309 310pci*) 311 M pci$U c 52 $U 600 312 MKlist[${#MKlist[*]}]=";[ -h pci ] || ln -sf pci0 pci" 313 ;; 314 315hotplug) 316 M hotplug c 56 $U 400 317 ;; 318 319fuse) 320 M fuse$U c 67 $U 600 321 ;; 322 323fd) 324 RMlist[${#RMlist[*]}]=";mkdir -p fd;rm -f" n=0 325 while [ $n -lt 64 ];do M fd/$n c 10 $n;n=$(($n+1));done 326 MKlist[${#MKlist[*]}]=";chmod 555 fd" 327 ;; 328 329dt) 330 M dt c 32 0 600 331 ;; 332 333diskmap) 334 M diskmap c 63 0 640 operator 335 ;; 336 337bpf) 338 M bpf c 11 0 600 339 M bpf0 c 11 0 600 340 ;; 341 342bktr*) 343 M bktr$U c 58 $U 644 344 ;; 345 346bio) 347 M bio c 53 0 600 348 ;; 349 350audio*) 351 M audio$U c 24 $U 660 _sndiop 352 M audioctl$U c 24 $(($U+192)) 660 _sndiop 353 ;; 354 355usb*) 356 [ "$i" = "usb" ] && u= || u=$U 357 M usb$u c 45 $U 640 358 ;; 359 360ulpt*) 361 M ulpt$U c 47 $U 600 362 ;; 363 364ujoy) 365 RMlist[${#RMlist[*]}]=";mkdir -p ujoy;rm -f" n=0 366 while [ $n -lt 4 ];do M ujoy/$n c 72 $n 444;n=$(($n+1));done 367 MKlist[${#MKlist[*]}]=";chmod 555 ujoy" 368 ;; 369 370fido) 371 RMlist[${#RMlist[*]}]=";mkdir -p fido;rm -f" n=0 372 while [ $n -lt 4 ];do M fido/$n c 70 $n 666;n=$(($n+1));done 373 MKlist[${#MKlist[*]}]=";chmod 555 fido" 374 ;; 375 376uhid*) 377 M uhid$U c 46 $U 600 378 ;; 379 380ugen*) 381 n=$(($U*16)) 382 for j in 0{0,1,2,3,4,5,6,7,8,9} 1{0,1,2,3,4,5} 383 do 384 M ugen$U.$j c 48 $(($n+10#$j)) 600 385 done 386 ;; 387 388uall) 389 R ttyU0 ttyU1 ttyU2 ttyU3 ugen0 ugen1 ugen2 ugen3 ugen4 ugen5 390 R ugen6 ugen7 ulpt0 ulpt1 ujoy fido uhid0 uhid1 uhid2 uhid3 391 R uhid4 uhid5 uhid6 uhid7 usb0 usb1 usb2 usb3 usb4 usb5 usb6 392 R usb7 393 ;; 394 395ttyU[0-9a-zA-Z]) 396 U=${i#ttyU*} 397 o=$(alph2d $U) 398 M ttyU$U c 49 $o 660 dialer root 399 M cuaU$U c 49 $(($o+128)) 660 dialer root 400 ;; 401 402lpt*|lpa*) 403 case $i in 404 lpt*) n=lpt f=0;; 405 lpa*) n=lpa f=128;; 406 esac 407 M $n$U c 31 $(($U+$f)) 600 408 ;; 409 410wsmouse[0-9]*) 411 M wsmouse$U c 30 $U 600 412 ;; 413 414wsmux|wsmouse|wskbd) 415 M wsmouse c 60 0 600 416 M wskbd c 60 1 600 417 ;; 418 419wskbd[0-9]*) 420 M wskbd$U c 29 $U 600 421 ;; 422 423wscons) 424 R wsmouse0 wsmouse1 wsmouse2 wsmouse3 wsmouse4 wsmouse5 425 R wsmouse6 wsmouse7 wsmouse8 wsmouse9 wskbd0 wskbd1 wskbd2 426 R wskbd3 wskbd4 wskbd5 wskbd6 wskbd7 wskbd8 wskbd9 wsmux 427 R ttyCcfg ttyC0 ttyC1 ttyC2 ttyC3 ttyC4 ttyC5 ttyC6 ttyC7 428 R ttyC8 ttyC9 ttyCa ttyCb 429 ;; 430 431tty[C-J]*) 432 U=${i##tty[C-J]} 433 case $i in 434 ttyC*) n=C m=0;; 435 ttyD*) n=D m=256;; 436 ttyE*) n=E m=512;; 437 ttyF*) n=F m=768;; 438 ttyG*) n=G m=1024;; 439 ttyH*) n=H m=1280;; 440 ttyI*) n=I m=1536;; 441 ttyJ*) n=J m=1792;; 442 esac 443 case $U in 444 [0-9a-f]) M tty$n$U c 25 $((16#$U+$m)) 600;; 445 cfg) M tty${n}cfg c 25 $((255+$m)) 600;; 446 *) echo bad unit $U for $i; exit 1;; 447 esac 448 ;; 449 450pty*) 451 if [ $U -gt 15 ]; then 452 echo bad unit for pty in: $i 453 continue 454 fi 455 set -A letters p q r s t u v w x y z P Q R S T 456 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 \ 457 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 \ 458 Y Z 459 460 name=${letters[$U]} 461 n=0 462 while [ $n -lt 62 ] 463 do 464 nam=$name${suffixes[$n]} 465 off=$(($U*62)) 466 M tty$nam c 4 $(($off+$n)) 467 M pty$nam c 5 $(($off+$n)) 468 n=$(($n+1)) 469 done 470 ;; 471 472ptm) 473 M ptm c 55 0 666 474 ;; 475 476tty[0-7][0-9a-f]) 477 U=${i#tty*} 478 o=$(h2d $U) 479 M tty$U c 26 $o 660 dialer root 480 M cua$U c 26 $(($o+128)) 660 dialer root 481 ;; 482 483st*) 484 n=$(($U*16)) 485 for pre in " " n e en 486 do 487 M ${pre}rst$U c 12 $n 660 operator 488 n=$(($n+1)) 489 done 490 ;; 491 492ch*) 493 M ch$U c 14 $U 660 operator 494 ;; 495 496vnd*) 497 dodisk vnd $U 9 9 $U 0 498 ;; 499 500rd*) 501 dodisk2 rd $U 6 28 $U 0 502 ;; 503 504fd*) 505 typnam=$U${i#fd[01]*} 506 case $typnam in 507 0|1) typnum=0;; # no type specified, assume A 508 *A) typnum=0; typnam=0;; 509 *B) typnum=1;; 510 *C) typnum=2;; 511 *D) typnum=3;; 512 *E) typnum=4;; 513 *F) typnum=5;; 514 *G) typnum=6;; 515 *H) typnum=7;; 516 *) echo bad type $typnam for $i; exit 1;; 517 esac 518 case $U in 519 0|1) blk=4; chr=37;; 520 *) echo bad unit $U for $i; exit 1;; 521 esac 522 nam=fd${typnam} 523 n=$(($(($U*128))+$(($typnum*16)))) 524 M ${nam}a b $blk $n 640 operator 525 M ${nam}b b $blk $(($n+1)) 640 operator 526 M ${nam}c b $blk $(($n+2)) 640 operator 527 M ${nam}i b $blk $(($n+8)) 640 operator 528 M r${nam}a c $chr $n 640 operator 529 M r${nam}b c $chr $(($n+1)) 640 operator 530 M r${nam}c c $chr $(($n+2)) 640 operator 531 M r${nam}i c $chr $(($n+8)) 640 operator 532 ;; 533 534cd*) 535 dodisk2 cd $U 3 13 $U 0 536 ;; 537 538local) 539 test -s $T.local && sh $T.local 540 ;; 541 542all) 543 R vnd0 vnd1 vnd2 vnd3 sd0 sd1 sd2 sd3 sd4 sd5 sd6 sd7 sd8 sd9 544 R cd0 cd1 rd0 ttyB0 ttyB1 tap0 tap1 tap2 tap3 tun0 tun1 tun2 545 R tun3 pty0 fd1 fd1B fd1C fd1D fd1E fd1F fd1G fd1H fd0 fd0B 546 R fd0C fd0D fd0E fd0F fd0G fd0H diskmap vscsi0 ch0 bio audio0 547 R audio1 audio2 audio3 kstat dt bpf fuse pppac pppx hotplug 548 R ptm local wscons pci0 pci1 pci2 pci3 uall rmidi0 rmidi1 549 R rmidi2 rmidi3 rmidi4 rmidi5 rmidi6 rmidi7 tuner0 radio0 550 R speaker video0 video1 uk0 random lpa0 lpa1 lpa2 lpt0 lpt1 551 R lpt2 tty00 tty01 tty02 tty03 tty04 tty05 tty06 tty07 tty08 552 R tty09 tty0a tty0b ttyc0 ttyc1 ttyc2 ttyc3 ttyc4 ttyc5 ttyc6 553 R ttyc7 pf wd0 wd1 wd2 wd3 std st0 st1 fd 554 ;; 555 556wd*|sd*) 557 case $i in 558 wd*) dodisk wd $U 0 36 $U 0;; 559 sd*) dodisk sd $U 8 8 $U 0;; 560 esac 561 ;; 562 563*) 564 echo $i: unknown device 565 ;; 566esac 567done 568} 569R "$@" 570{ 571echo -n ${RMlist[*]} 572echo -n ${mklist[*]} 573echo -n ${MKlist[*]} 574echo -n ${whlist[*]} 575echo ${oplist[*]} 576} | if [ "$eo" = "echo" ]; then 577 cat 578else 579 sh 580fi 581