1#!/bin/sh - 2# 3# THIS FILE AUTOMATICALLY GENERATED. DO NOT EDIT. 4# generated from: 5# 6# OpenBSD: etc.arm64/MAKEDEV.md,v 1.13 2021/11/11 09:47:32 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# 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# drm* Direct Rendering Manager 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 322drm*) 323 M drm$U c 87 $U 600 324 r=$(($U+128)) 325 M drmR$r c 87 $r 600 326 ;; 327 328dri) 329 RMlist[${#RMlist[*]}]=";mkdir -p dri;rm -f" 330 n=0 331 while [ $n -lt 4 ] 332 do 333 M dri/card$n c 87 $n 600 334 r=$(($n+128)) 335 M dri/renderD$r c 87 $r 600 336 n=$(($n+1)) 337 done 338 MKlist[${#MKlist[*]}]=";chmod 555 dri" 339 ;; 340 341diskmap) 342 M diskmap c 90 0 640 operator 343 ;; 344 345dt) 346 M dt c 30 0 600 347 ;; 348 349bpf) 350 M bpf c 23 0 600 351 M bpf0 c 23 0 600 352 ;; 353 354bktr*) 355 M bktr$U c 49 $U 644 356 ;; 357 358bio) 359 M bio c 79 0 600 360 ;; 361 362audio*) 363 M audio$U c 42 $U 660 _sndiop 364 M audioctl$U c 42 $(($U+192)) 660 _sndiop 365 ;; 366 367apm*) 368 M apm c 83 0 644 369 M apmctl c 83 8 644 370 ;; 371 372usb*) 373 [ "$i" = "usb" ] && u= || u=$U 374 M usb$u c 61 $U 640 375 ;; 376 377ulpt*) 378 M ulpt$U c 64 $U 600 379 ;; 380 381ujoy) 382 RMlist[${#RMlist[*]}]=";mkdir -p ujoy;rm -f" n=0 383 while [ $n -lt 4 ];do M ujoy/$n c 100 $n 444;n=$(($n+1));done 384 MKlist[${#MKlist[*]}]=";chmod 555 ujoy" 385 ;; 386 387fido) 388 RMlist[${#RMlist[*]}]=";mkdir -p fido;rm -f" n=0 389 while [ $n -lt 4 ];do M fido/$n c 98 $n 666;n=$(($n+1));done 390 MKlist[${#MKlist[*]}]=";chmod 555 fido" 391 ;; 392 393uhid*) 394 M uhid$U c 62 $U 600 395 ;; 396 397ugen*) 398 n=$(($U*16)) 399 for j in 0{0,1,2,3,4,5,6,7,8,9} 1{0,1,2,3,4,5} 400 do 401 M ugen$U.$j c 63 $(($n+10#$j)) 600 402 done 403 ;; 404 405uall) 406 R ttyU0 ttyU1 ttyU2 ttyU3 ugen0 ugen1 ugen2 ugen3 ugen4 ugen5 407 R ugen6 ugen7 ulpt0 ulpt1 ujoy fido uhid0 uhid1 uhid2 uhid3 408 R uhid4 uhid5 uhid6 uhid7 usb0 usb1 usb2 usb3 usb4 usb5 usb6 409 R usb7 410 ;; 411 412ttyU[0-9a-zA-Z]) 413 U=${i#ttyU*} 414 o=$(alph2d $U) 415 M ttyU$U c 66 $o 660 dialer root 416 M cuaU$U c 66 $(($o+128)) 660 dialer root 417 ;; 418 419wsmouse[0-9]*) 420 M wsmouse$U c 68 $U 600 421 ;; 422 423wsmux|wsmouse|wskbd) 424 M wsmouse c 69 0 600 425 M wskbd c 69 1 600 426 ;; 427 428wskbd[0-9]*) 429 M wskbd$U c 67 $U 600 430 ;; 431 432wscons) 433 R wsmouse0 wsmouse1 wsmouse2 wsmouse3 wsmouse4 wsmouse5 434 R wsmouse6 wsmouse7 wsmouse8 wsmouse9 wskbd0 wskbd1 wskbd2 435 R wskbd3 wsmux ttyCcfg ttyC0 ttyC1 ttyC2 ttyC3 ttyC4 ttyC5 436 R ttyC6 ttyC7 ttyC8 ttyC9 ttyCa ttyCb 437 ;; 438 439tty[C-J]*) 440 U=${i##tty[C-J]} 441 case $i in 442 ttyC*) n=C m=0;; 443 ttyD*) n=D m=256;; 444 ttyE*) n=E m=512;; 445 ttyF*) n=F m=768;; 446 ttyG*) n=G m=1024;; 447 ttyH*) n=H m=1280;; 448 ttyI*) n=I m=1536;; 449 ttyJ*) n=J m=1792;; 450 esac 451 case $U in 452 [0-9a-f]) M tty$n$U c 12 $((16#$U+$m)) 600;; 453 cfg) M tty${n}cfg c 12 $((255+$m)) 600;; 454 *) echo bad unit $U for $i; exit 1;; 455 esac 456 ;; 457 458pty*) 459 if [ $U -gt 15 ]; then 460 echo bad unit for pty in: $i 461 continue 462 fi 463 set -A letters p q r s t u v w x y z P Q R S T 464 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 \ 465 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 \ 466 Y Z 467 468 name=${letters[$U]} 469 n=0 470 while [ $n -lt 62 ] 471 do 472 nam=$name${suffixes[$n]} 473 off=$(($U*62)) 474 M tty$nam c 5 $(($off+$n)) 475 M pty$nam c 6 $(($off+$n)) 476 n=$(($n+1)) 477 done 478 ;; 479 480ptm) 481 M ptm c 81 0 666 482 ;; 483 484tty[0-7][0-9a-f]) 485 U=${i#tty*} 486 o=$(h2d $U) 487 M tty$U c 8 $o 660 dialer root 488 M cua$U c 8 $(($o+128)) 660 dialer root 489 ;; 490 491ch*) 492 M ch$U c 17 $U 660 operator 493 ;; 494 495vnd*) 496 dodisk vnd $U 14 41 $U 0 497 ;; 498 499rd*) 500 dodisk2 rd $U 17 47 $U 0 501 ;; 502 503cd*) 504 dodisk2 cd $U 6 15 $U 0 505 ;; 506 507local) 508 test -s $T.local && sh $T.local 509 ;; 510 511all) 512 R ipmi0 drm0 drm1 drm2 drm3 dri gpio0 gpio1 gpio2 bktr0 vnd0 513 R vnd1 vnd2 vnd3 sd0 sd1 sd2 sd3 sd4 sd5 sd6 sd7 sd8 sd9 cd0 514 R cd1 rd0 tap0 tap1 tap2 tap3 tun0 tun1 tun2 tun3 bio pty0 515 R diskmap vscsi0 ch0 audio0 audio1 audio2 audio3 kstat dt bpf 516 R fuse pppac pppx hotplug ptm local wscons pci0 pci1 pci2 pci3 517 R uall rmidi0 rmidi1 rmidi2 rmidi3 rmidi4 rmidi5 rmidi6 rmidi7 518 R tuner0 radio0 video0 video1 uk0 random tty00 tty01 tty02 519 R tty03 tty04 tty05 tty06 tty07 tty08 tty09 tty0a tty0b apm pf 520 R wd0 wd1 wd2 wd3 std fd 521 ;; 522 523wd*|sd*) 524 case $i in 525 wd*) dodisk wd $U 0 3 $U 0;; 526 sd*) dodisk sd $U 4 13 $U 0;; 527 esac 528 ;; 529 530*) 531 echo $i: unknown device 532 ;; 533esac 534done 535} 536R "$@" 537{ 538echo -n ${RMlist[*]} 539echo -n ${mklist[*]} 540echo -n ${MKlist[*]} 541echo -n ${whlist[*]} 542echo ${oplist[*]} 543} | if [ "$eo" = "echo" ]; then 544 cat 545else 546 sh 547fi 548