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