1#!/bin/sh - 2# 3# THIS FILE AUTOMATICALLY GENERATED. DO NOT EDIT. 4# generated from: 5# 6# OpenBSD: etc.hppa/MAKEDEV.md,v 1.70 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# fd* Floppy disk drives (3 1/2", 5 1/4") 35# sd* SCSI disks, including flopticals 36# rd* "rd" pseudo-disks 37# vnd* "file" pseudo-disk devices 38# wd* "winchester" disk drives (ST506, IDE, ESDI, RLL, ...) 39# Tapes: 40# ch* SCSI media changers 41# st* SCSI tape drives 42# Terminal ports: 43# tty[0-7][0-9a-f] NS16x50 serial ports 44# Pseudo terminals: 45# ptm pty master device 46# pty* Set of 62 master pseudo terminals 47# tty* Set of 62 slave pseudo terminals 48# Console ports: 49# ttyC-J* wscons display devices 50# wscons Minimal wscons devices 51# wskbd* wscons keyboards 52# wsmux wscons keyboard/mouse mux devices 53# Pointing devices: 54# wsmouse* wscons mice 55# Printers: 56# lpt* IEEE 1284 centronics printer 57# USB devices: 58# uall All USB devices 59# usb* Bus control devices used by usbd for attach/detach 60# uhid* Generic HID devices 61# fido fido/* nodes 62# ujoy ujoy/* nodes 63# ugen* Generic USB devices 64# ulpt* Printer devices 65# ttyU* USB serial ports 66# Special purpose devices: 67# audio* Audio devices 68# bio ioctl tunnel pseudo-device 69# bpf Berkeley Packet Filter 70# diskmap Disk mapper 71# dt Dynamic Tracer 72# fd fd/* nodes 73# fuse Userland Filesystem 74# hotplug devices hot plugging 75# pci* PCI bus devices 76# pdc PDC device 77# pf Packet Filter 78# pppx* PPP Multiplexer 79# pppac* PPP Access Concentrator 80# *random In-kernel random data source 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# 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 213ramdisk) 214 R std fd st0 st1 sd0 sd1 sd2 sd3 rd0 random 215 R bpf bio diskmap 216 ;; 217 218std) 219 M console c 0 0 600 220 M tty c 1 0 221 M mem c 2 0 640 kmem 222 M kmem c 2 1 640 kmem 223 M null c 2 2 224 M zero c 2 12 225 M stdin c 16 0 226 M stdout c 16 1 227 M stderr c 16 2 228 M ksyms c 25 0 640 kmem 229 M klog c 6 0 600 230 M pdc c 22 0 640 operator 231 ;; 232 233kstat) 234 M kstat c 51 0 640 235 ;; 236 237vscsi*) 238 M vscsi$U c 54 $U 600 239 ;; 240 241video*) 242 M video$U c 33 $U 600 243 MKlist[${#MKlist[*]}]=";[ -e video ] || ln -s video$U video" 244 ;; 245 246uk*) 247 M uk$U c 15 $U 640 operator 248 ;; 249 250tap*) 251 M tap$U c 59 $U 600 252 ;; 253 254tun*) 255 M tun$U c 18 $U 600 256 ;; 257 258*random) 259 M urandom c 20 0 644 260 RMlist[${#RMlist[*]}]=random 261 MKlist[${#MKlist[*]}]=";ln -s urandom random" 262 ;; 263 264pppac*) 265 M pppac$U c 62 $U 600 266 ;; 267 268pppx*) 269 M pppx$U c 57 $U 600 270 ;; 271 272pf) 273 M pf c 21 0 600 274 ;; 275 276pci*) 277 M pci$U c 31 $U 600 278 MKlist[${#MKlist[*]}]=";[ -h pci ] || ln -sf pci0 pci" 279 ;; 280 281hotplug) 282 M hotplug c 47 $U 400 283 ;; 284 285fuse) 286 M fuse$U c 58 $U 600 287 ;; 288 289fd) 290 RMlist[${#RMlist[*]}]=";mkdir -p fd;rm -f" n=0 291 while [ $n -lt 64 ];do M fd/$n c 16 $n;n=$(($n+1));done 292 MKlist[${#MKlist[*]}]=";chmod 555 fd" 293 ;; 294 295dt) 296 M dt c 32 0 600 297 ;; 298 299diskmap) 300 M diskmap c 56 0 640 operator 301 ;; 302 303bpf) 304 M bpf c 17 0 600 305 M bpf0 c 17 0 600 306 ;; 307 308bio) 309 M bio c 37 0 600 310 ;; 311 312audio*) 313 M audio$U c 35 $U 660 _sndiop 314 M audioctl$U c 35 $(($U+192)) 660 _sndiop 315 ;; 316 317ttyU[0-9a-zA-Z]) 318 U=${i#ttyU*} 319 o=$(alph2d $U) 320 M ttyU$U c 45 $o 660 dialer root 321 M cuaU$U c 45 $(($o+128)) 660 dialer root 322 ;; 323 324ulpt*) 325 M ulpt$U c 43 $U 600 326 ;; 327 328ugen*) 329 n=$(($U*16)) 330 for j in 0{0,1,2,3,4,5,6,7,8,9} 1{0,1,2,3,4,5} 331 do 332 M ugen$U.$j c 42 $(($n+10#$j)) 600 333 done 334 ;; 335 336ujoy) 337 RMlist[${#RMlist[*]}]=";mkdir -p ujoy;rm -f" n=0 338 while [ $n -lt 4 ];do M ujoy/$n c 63 $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 61 $n 666;n=$(($n+1));done 345 MKlist[${#MKlist[*]}]=";chmod 555 fido" 346 ;; 347 348uhid*) 349 M uhid$U c 41 $U 600 350 ;; 351 352usb*) 353 [ "$i" = "usb" ] && u= || u=$U 354 M usb$u c 40 $U 640 355 ;; 356 357uall) 358 R ttyU0 ttyU1 ttyU2 ttyU3 ugen0 ugen1 ugen2 ugen3 ugen4 ugen5 359 R ugen6 ugen7 ulpt0 ulpt1 ujoy fido uhid0 uhid1 uhid2 uhid3 360 R uhid4 uhid5 uhid6 uhid7 usb0 usb1 usb2 usb3 usb4 usb5 usb6 361 R usb7 362 ;; 363 364lpt*|lpa*) 365 case $i in 366 lpt*) n=lpt f=0;; 367 lpa*) n=lpa f=128;; 368 esac 369 M $n$U c 26 $(($U+$f)) 600 370 ;; 371 372wsmouse[0-9]*) 373 M wsmouse$U c 29 $U 600 374 ;; 375 376wsmux|wsmouse|wskbd) 377 M wsmouse c 30 0 600 378 M wskbd c 30 1 600 379 ;; 380 381wskbd[0-9]*) 382 M wskbd$U c 28 $U 600 383 ;; 384 385wscons) 386 R wsmouse0 wsmouse1 wsmouse2 wsmouse3 wsmouse4 wsmouse5 387 R wsmouse6 wsmouse7 wsmouse8 wsmouse9 wskbd0 wskbd1 wskbd2 388 R wskbd3 wskbd4 wskbd5 wskbd6 wskbd7 wskbd8 wskbd9 wsmux 389 R ttyCcfg ttyC0 ttyC1 ttyC2 ttyC3 ttyC4 ttyC5 ttyC6 ttyC7 390 R ttyC8 ttyC9 ttyCa ttyCb 391 ;; 392 393tty[C-J]*) 394 U=${i##tty[C-J]} 395 case $i in 396 ttyC*) n=C m=0;; 397 ttyD*) n=D m=256;; 398 ttyE*) n=E m=512;; 399 ttyF*) n=F m=768;; 400 ttyG*) n=G m=1024;; 401 ttyH*) n=H m=1280;; 402 ttyI*) n=I m=1536;; 403 ttyJ*) n=J m=1792;; 404 esac 405 case $U in 406 [0-9a-f]) M tty$n$U c 27 $((16#$U+$m)) 600;; 407 cfg) M tty${n}cfg c 27 $((255+$m)) 600;; 408 *) echo bad unit $U for $i; exit 1;; 409 esac 410 ;; 411 412pty*) 413 if [ $U -gt 15 ]; then 414 echo bad unit for pty in: $i 415 continue 416 fi 417 set -A letters p q r s t u v w x y z P Q R S T 418 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 \ 419 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 \ 420 Y Z 421 422 name=${letters[$U]} 423 n=0 424 while [ $n -lt 62 ] 425 do 426 nam=$name${suffixes[$n]} 427 off=$(($U*62)) 428 M tty$nam c 4 $(($off+$n)) 429 M pty$nam c 5 $(($off+$n)) 430 n=$(($n+1)) 431 done 432 ;; 433 434ptm) 435 M ptm c 38 0 666 436 ;; 437 438tty[0-7][0-9a-f]) 439 U=${i#tty*} 440 o=$(h2d $U) 441 M tty$U c 23 $o 660 dialer root 442 M cua$U c 23 $(($o+128)) 660 dialer root 443 ;; 444 445st*) 446 n=$(($U*16)) 447 for pre in " " n e en 448 do 449 M ${pre}rst$U c 11 $n 660 operator 450 n=$(($n+1)) 451 done 452 ;; 453 454ch*) 455 M ch$U c 13 $U 660 operator 456 ;; 457 458vnd*) 459 dodisk vnd $U 2 8 $U 0 460 ;; 461 462rd*) 463 dodisk2 rd $U 3 9 $U 0 464 ;; 465 466fd*) 467 typnam=$U${i#fd[01]*} 468 case $typnam in 469 0|1) typnum=0;; # no type specified, assume A 470 *A) typnum=0; typnam=0;; 471 *B) typnum=1;; 472 *C) typnum=2;; 473 *D) typnum=3;; 474 *E) typnum=4;; 475 *F) typnum=5;; 476 *G) typnum=6;; 477 *H) typnum=7;; 478 *) echo bad type $typnam for $i; exit 1;; 479 esac 480 case $U in 481 0|1) blk=7; chr=24;; 482 *) echo bad unit $U for $i; exit 1;; 483 esac 484 nam=fd${typnam} 485 n=$(($(($U*128))+$(($typnum*16)))) 486 M ${nam}a b $blk $n 640 operator 487 M ${nam}b b $blk $(($n+1)) 640 operator 488 M ${nam}c b $blk $(($n+2)) 640 operator 489 M ${nam}i b $blk $(($n+8)) 640 operator 490 M r${nam}a c $chr $n 640 operator 491 M r${nam}b c $chr $(($n+1)) 640 operator 492 M r${nam}c c $chr $(($n+2)) 640 operator 493 M r${nam}i c $chr $(($n+8)) 640 operator 494 ;; 495 496cd*) 497 dodisk2 cd $U 6 12 $U 0 498 ;; 499 500local) 501 test -s $T.local && sh $T.local 502 ;; 503 504all) 505 R vnd0 vnd1 vnd2 vnd3 sd0 sd1 sd2 sd3 sd4 sd5 sd6 sd7 sd8 sd9 506 R cd0 cd1 rd0 tap0 tap1 tap2 tap3 tun0 tun1 tun2 tun3 pty0 fd1 507 R fd1B fd1C fd1D fd1E fd1F fd1G fd1H fd0 fd0B fd0C fd0D fd0E 508 R fd0F fd0G fd0H diskmap vscsi0 bio ch0 audio0 audio1 audio2 509 R audio3 kstat dt bpf fuse pppac pppx hotplug ptm local wscons 510 R pci0 pci1 pci2 pci3 uall video0 video1 uk0 random lpa0 lpa1 511 R lpa2 lpt0 lpt1 lpt2 tty00 tty01 tty02 tty03 tty04 tty05 512 R tty06 tty07 tty08 tty09 tty0a tty0b pf wd0 wd1 wd2 wd3 std 513 R st0 st1 fd 514 ;; 515 516wd*|sd*) 517 case $i in 518 wd*) dodisk wd $U 8 39 $U 0;; 519 sd*) dodisk sd $U 4 10 $U 0;; 520 esac 521 ;; 522 523*) 524 echo $i: unknown device 525 ;; 526esac 527done 528} 529R "$@" 530{ 531echo -n ${RMlist[*]} 532echo -n ${mklist[*]} 533echo -n ${MKlist[*]} 534echo -n ${whlist[*]} 535echo ${oplist[*]} 536} | if [ "$eo" = "echo" ]; then 537 cat 538else 539 sh 540fi 541