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