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