1#!/bin/sh - 2# 3# THIS FILE AUTOMATICALLY GENERATED. DO NOT EDIT. 4# generated from: 5# 6# OpenBSD: etc.i386/MAKEDEV.md,v 1.92 2021/01/23 05:08:33 thfr Exp 7# OpenBSD: MAKEDEV.common,v 1.112 2021/01/23 05:08:33 thfr 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# drm* Direct Rendering Manager 78# fd fd/* nodes 79# fuse Userland Filesystem 80# gpio* General Purpose Input/Output 81# hotplug devices hot plugging 82# ipmi* IPMI BMC access 83# joy* Joystick driver 84# kcov Kernel code coverage tracing 85# nvram NVRAM access 86# pci* PCI bus devices 87# pctr* PC Performance Tuning Register access device 88# pf* Packet Filter 89# pppx* PPP Multiplexer 90# pppac* PPP Access Concentrator 91# radio* FM tuner devices 92# *random In-kernel random data source 93# rmidi* Raw MIDI devices 94# speaker PC speaker 95# tun* Network tunnel driver 96# tap* Ethernet tunnel driver 97# tuner* Tuner devices 98# uk* Unknown SCSI devices 99# video* Video V4L2 devices 100# vscsi* Virtual SCSI controller 101# pvbus* paravirtual device tree root 102# switch* Switch driver 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 259switch*) 260 M switch$U c 97 $U 600 261 ;; 262 263pvbus*) 264 M pvbus$U c 95 $U 640 265 ;; 266 267vscsi*) 268 M vscsi$U c 90 $U 600 269 ;; 270 271video*) 272 M video$U c 44 $U 600 273 MKlist[${#MKlist[*]}]=";[ -e video ] || ln -s video$U video" 274 ;; 275 276uk*) 277 M uk$U c 20 $U 640 operator 278 ;; 279 280tuner*) 281 M tuner$U c 49 $(($(($U*2))+16)) 644 282 ;; 283 284tap*) 285 M tap$U c 94 $U 600 286 ;; 287 288tun*) 289 M tun$U c 40 $U 600 290 ;; 291 292speaker) 293 M speaker c 27 0 600 294 ;; 295 296rmidi*) 297 M rmidi$U c 52 $U 660 _sndiop 298 ;; 299 300*random) 301 M urandom c 45 0 644 302 RMlist[${#RMlist[*]}]=random 303 MKlist[${#MKlist[*]}]=";ln -s urandom random" 304 ;; 305 306radio*) 307 M radio$U c 76 $U 308 MKlist[${#MKlist[*]}]=";[ -e radio ] || ln -s radio$U radio" 309 ;; 310 311pppac*) 312 M pppac$U c 99 $U 600 313 ;; 314 315pppx*) 316 M pppx$U c 92 $U 600 317 ;; 318 319pf*) 320 M pf c 73 0 600 321 ;; 322 323pctr) 324 M pctr c 46 0 644 325 ;; 326 327pci*) 328 M pci$U c 72 $U 600 329 MKlist[${#MKlist[*]}]=";[ -h pci ] || ln -sf pci0 pci" 330 ;; 331 332nvram) 333 M nvram c 84 0 440 kmem 334 ;; 335 336kcov) 337 M kcov c 19 0 600 338 ;; 339 340joy*) 341 M joy$U c 26 $U 666 342 ;; 343 344ipmi*) 345 M ipmi$U c 96 $U 600 346 ;; 347 348hotplug) 349 M hotplug c 82 $U 400 350 ;; 351 352gpio*) 353 M gpio$U c 83 $U 600 354 ;; 355 356fuse) 357 M fuse$U c 93 $U 600 358 ;; 359 360fd) 361 RMlist[${#RMlist[*]}]=";mkdir -p fd;rm -f" n=0 362 while [ $n -lt 64 ];do M fd/$n c 22 $n;n=$(($n+1));done 363 MKlist[${#MKlist[*]}]=";chmod 555 fd" 364 ;; 365 366drm*) 367 M drm$U c 88 $U 600 368 r=$(($U+128)) 369 M drmR$r c 88 $r 600 370 ;; 371 372diskmap) 373 M diskmap c 91 0 640 operator 374 ;; 375 376dt) 377 M dt c 30 0 600 378 ;; 379 380bpf) 381 M bpf c 23 0 600 382 M bpf0 c 23 0 600 383 ;; 384 385bktr*) 386 M bktr$U c 49 $U 644 387 ;; 388 389bio) 390 M bio c 79 0 600 391 ;; 392 393audio*) 394 M audio$U c 42 $U 660 _sndiop 395 M audioctl$U c 42 $(($U+192)) 660 _sndiop 396 ;; 397 398apm*) 399 M apm c 21 0 644 400 M apmctl c 21 8 644 401 ;; 402 403amdmsr*) 404 M amdmsr c 89 $U 405 ;; 406 407usb*) 408 [ "$i" = "usb" ] && u= || u=$U 409 M usb$u c 61 $U 640 410 ;; 411 412ulpt*) 413 M ulpt$U c 64 $U 600 414 ;; 415 416ujoy) 417 RMlist[${#RMlist[*]}]=";mkdir -p ujoy;rm -f" n=0 418 while [ $n -lt 4 ];do M ujoy/$n c 100 $n 444;n=$(($n+1));done 419 MKlist[${#MKlist[*]}]=";chmod 555 ujoy" 420 ;; 421 422fido) 423 RMlist[${#RMlist[*]}]=";mkdir -p fido;rm -f" n=0 424 while [ $n -lt 4 ];do M fido/$n c 98 $n 666;n=$(($n+1));done 425 MKlist[${#MKlist[*]}]=";chmod 555 fido" 426 ;; 427 428uhid*) 429 M uhid$U c 62 $U 600 430 ;; 431 432ugen*) 433 n=$(($U*16)) 434 for j in 0{0,1,2,3,4,5,6,7,8,9} 1{0,1,2,3,4,5} 435 do 436 M ugen$U.$j c 63 $(($n+10#$j)) 600 437 done 438 ;; 439 440uall) 441 R ttyU0 ttyU1 ttyU2 ttyU3 ugen0 ugen1 ugen2 ugen3 ugen4 ugen5 442 R ugen6 ugen7 ulpt0 ulpt1 ujoy fido uhid0 uhid1 uhid2 uhid3 443 R uhid4 uhid5 uhid6 uhid7 usb0 usb1 usb2 usb3 usb4 usb5 usb6 444 R usb7 445 ;; 446 447ttyU[0-9a-zA-Z]) 448 U=${i#ttyU*} 449 o=$(alph2d $U) 450 M ttyU$U c 66 $o 660 dialer root 451 M cuaU$U c 66 $(($o+128)) 660 dialer root 452 ;; 453 454lpt*|lpa*) 455 case $i in 456 lpt*) n=lpt f=0;; 457 lpa*) n=lpa f=128;; 458 esac 459 M $n$U c 16 $(($U+$f)) 600 460 ;; 461 462wsmouse[0-9]*) 463 M wsmouse$U c 68 $U 600 464 ;; 465 466wsmux|wsmouse|wskbd) 467 M wsmouse c 69 0 600 468 M wskbd c 69 1 600 469 ;; 470 471wskbd[0-9]*) 472 M wskbd$U c 67 $U 600 473 ;; 474 475wscons) 476 R wsmouse0 wsmouse1 wsmouse2 wsmouse3 wsmouse4 wsmouse5 477 R wsmouse6 wsmouse7 wsmouse8 wsmouse9 wskbd0 wskbd1 wskbd2 478 R wskbd3 wsmux ttyCcfg ttyC0 ttyC1 ttyC2 ttyC3 ttyC4 ttyC5 479 R ttyC6 ttyC7 ttyC8 ttyC9 ttyCa ttyCb 480 ;; 481 482tty[C-J]*) 483 U=${i##tty[C-J]} 484 case $i in 485 ttyC*) n=C m=0;; 486 ttyD*) n=D m=256;; 487 ttyE*) n=E m=512;; 488 ttyF*) n=F m=768;; 489 ttyG*) n=G m=1024;; 490 ttyH*) n=H m=1280;; 491 ttyI*) n=I m=1536;; 492 ttyJ*) n=J m=1792;; 493 esac 494 case $U in 495 [0-9a-f]) M tty$n$U c 12 $((16#$U+$m)) 600;; 496 cfg) M tty${n}cfg c 12 $((255+$m)) 600;; 497 *) echo bad unit $U for $i; exit 1;; 498 esac 499 ;; 500 501pty*) 502 if [ $U -gt 15 ]; then 503 echo bad unit for pty in: $i 504 continue 505 fi 506 set -A letters p q r s t u v w x y z P Q R S T 507 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 \ 508 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 \ 509 Y Z 510 511 name=${letters[$U]} 512 n=0 513 while [ $n -lt 62 ] 514 do 515 nam=$name${suffixes[$n]} 516 off=$(($U*62)) 517 M tty$nam c 5 $(($off+$n)) 518 M pty$nam c 6 $(($off+$n)) 519 n=$(($n+1)) 520 done 521 ;; 522 523ptm) 524 M ptm c 81 0 666 525 ;; 526 527tty[0-7][0-9a-f]) 528 U=${i#tty*} 529 o=$(h2d $U) 530 M tty$U c 8 $o 660 dialer root 531 M cua$U c 8 $(($o+128)) 660 dialer root 532 ;; 533 534st*) 535 n=$(($U*16)) 536 for pre in " " n e en 537 do 538 M ${pre}rst$U c 14 $n 660 operator 539 n=$(($n+1)) 540 done 541 ;; 542 543ch*) 544 M ch$U c 17 $U 660 operator 545 ;; 546 547vnd*) 548 dodisk vnd $U 14 41 $U 0 549 ;; 550 551rd*) 552 dodisk2 rd $U 17 47 $U 0 553 ;; 554 555fd*) 556 typnam=$U${i#fd[01]*} 557 case $typnam in 558 0|1) typnum=0;; # no type specified, assume A 559 *A) typnum=0; typnam=0;; 560 *B) typnum=1;; 561 *C) typnum=2;; 562 *D) typnum=3;; 563 *E) typnum=4;; 564 *F) typnum=5;; 565 *G) typnum=6;; 566 *H) typnum=7;; 567 *) echo bad type $typnam for $i; exit 1;; 568 esac 569 case $U in 570 0|1) blk=2; chr=9;; 571 *) echo bad unit $U for $i; exit 1;; 572 esac 573 nam=fd${typnam} 574 n=$(($(($U*128))+$(($typnum*16)))) 575 M ${nam}a b $blk $n 640 operator 576 M ${nam}b b $blk $(($n+1)) 640 operator 577 M ${nam}c b $blk $(($n+2)) 640 operator 578 M ${nam}i b $blk $(($n+8)) 640 operator 579 M r${nam}a c $chr $n 640 operator 580 M r${nam}b c $chr $(($n+1)) 640 operator 581 M r${nam}c c $chr $(($n+2)) 640 operator 582 M r${nam}i c $chr $(($n+8)) 640 operator 583 ;; 584 585cd*) 586 dodisk2 cd $U 6 15 $U 0 587 ;; 588 589local) 590 test -s $T.local && sh $T.local 591 ;; 592 593all) 594 R switch0 switch1 switch2 switch3 ipmi0 amdmsr drm0 drm1 drm2 595 R drm3 nvram gpio0 gpio1 gpio2 bktr0 vnd0 vnd1 vnd2 vnd3 sd0 596 R sd1 sd2 sd3 sd4 sd5 sd6 sd7 sd8 sd9 cd0 cd1 rd0 tap0 tap1 597 R tap2 tap3 tun0 tun1 tun2 tun3 bio pty0 fd1 fd1B fd1C fd1D 598 R fd1E fd1F fd1G fd1H fd0 fd0B fd0C fd0D fd0E fd0F fd0G fd0H 599 R diskmap vscsi0 ch0 audio0 audio1 audio2 audio3 kstat dt kcov 600 R bpf pvbus0 pvbus1 fuse pppac pppx hotplug ptm local wscons 601 R pci0 pci1 pci2 pci3 uall rmidi0 rmidi1 rmidi2 rmidi3 rmidi4 602 R rmidi5 rmidi6 rmidi7 tuner0 radio0 speaker video0 video1 uk0 603 R random joy0 joy1 lpa0 lpa1 lpa2 lpt0 lpt1 lpt2 tty00 tty01 604 R tty02 tty03 tty04 tty05 tty06 tty07 tty08 tty09 tty0a tty0b 605 R ttyc0 ttyc1 ttyc2 ttyc3 ttyc4 ttyc5 ttyc6 ttyc7 apm pf pctr 606 R wd0 wd1 wd2 wd3 std st0 st1 fd 607 ;; 608 609wd*|sd*) 610 case $i in 611 wd*) dodisk wd $U 0 3 $U 0;; 612 sd*) dodisk sd $U 4 13 $U 0;; 613 esac 614 ;; 615 616*) 617 echo $i: unknown device 618 ;; 619esac 620done 621} 622R "$@" 623{ 624echo -n ${RMlist[*]} 625echo -n ${mklist[*]} 626echo -n ${MKlist[*]} 627echo -n ${whlist[*]} 628echo ${oplist[*]} 629} | if [ "$eo" = "echo" ]; then 630 cat 631else 632 sh 633fi 634