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