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