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