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