MAKEDEV revision 1.36
1#!/bin/sh - 2# 3# THIS FILE AUTOMATICALLY GENERATED. DO NOT EDIT. 4# generated from: 5# 6# OpenBSD: etc.armv7/MAKEDEV.md,v 1.19 2021/01/23 05:08:33 thfr Exp 7# OpenBSD: MAKEDEV.common,v 1.112 2021/01/23 05:08:33 thfr 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# ch* SCSI media changers 35# rd* "rd" pseudo-disks 36# sd* SCSI disks, including flopticals 37# vnd* "file" pseudo-disk devices 38# wd* "winchester" disk drives (ST506, IDE, ESDI, RLL, ...) 39# Tapes: 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# wsmouse* wscons mice 52# wsmux wscons keyboard/mouse mux devices 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# ujoy ujoy/* nodes 60# ulpt* Printer devices 61# usb* Bus control devices used by usbd for attach/detach 62# Special purpose devices: 63# apm Power management device 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# fd fd/* nodes 71# fuse Userland Filesystem 72# gpio* General Purpose Input/Output 73# hotplug devices hot plugging 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# tuner* Tuner devices 85# video* Video V4L2 devices 86# vscsi* Virtual SCSI controller 87# switch* Switch driver 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 wd1 sd0 tty00 rd0 wsmouse 217 R st0 ttyC0 wskbd0 apm bio diskmap 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 7 0 228 M stdout c 7 1 229 M stderr c 7 2 230 M ksyms c 8 0 640 kmem 231 M klog c 6 0 600 232 M openprom c 82 0 600 233 ;; 234 235kstat) 236 M kstat c 51 0 640 237 ;; 238 239switch*) 240 M switch$U c 105 $U 600 241 ;; 242 243vscsi*) 244 M vscsi$U c 100 $U 600 245 ;; 246 247video*) 248 M video$U c 38 $U 600 249 MKlist[${#MKlist[*]}]=";[ -e video ] || ln -s video$U video" 250 ;; 251 252tuner*) 253 M tuner$U c 75 $(($(($U*2))+16)) 644 254 ;; 255 256uk*) 257 M uk$U c 28 $U 640 operator 258 ;; 259 260tap*) 261 M tap$U c 104 $U 600 262 ;; 263 264tun*) 265 M tun$U c 33 $U 600 266 ;; 267 268rmidi*) 269 M rmidi$U c 57 $U 660 _sndiop 270 ;; 271 272*random) 273 M urandom c 40 0 644 274 RMlist[${#RMlist[*]}]=random 275 MKlist[${#MKlist[*]}]=";ln -s urandom random" 276 ;; 277 278radio*) 279 M radio$U c 97 $U 280 MKlist[${#MKlist[*]}]=";[ -e radio ] || ln -s radio$U radio" 281 ;; 282 283pppac*) 284 M pppac$U c 107 $U 600 285 ;; 286 287pppx*) 288 M pppx$U c 103 $U 600 289 ;; 290 291pf*) 292 M pf c 46 0 600 293 ;; 294 295pci*) 296 M pci$U c 88 $U 600 297 MKlist[${#MKlist[*]}]=";[ -h pci ] || ln -sf pci0 pci" 298 ;; 299 300hotplug) 301 M hotplug c 37 $U 400 302 ;; 303 304gpio*) 305 M gpio$U c 13 $U 600 306 ;; 307 308fuse) 309 M fuse$U c 77 $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 7 $n;n=$(($n+1));done 315 MKlist[${#MKlist[*]}]=";chmod 555 fd" 316 ;; 317 318diskmap) 319 M diskmap c 102 0 640 operator 320 ;; 321 322dt) 323 M dt c 30 0 600 324 ;; 325 326bpf) 327 M bpf c 22 0 600 328 M bpf0 c 22 0 600 329 ;; 330 331bktr*) 332 M bktr$U c 75 $U 644 333 ;; 334 335bio) 336 M bio c 52 0 600 337 ;; 338 339audio*) 340 M audio$U c 36 $U 660 _sndiop 341 M audioctl$U c 36 $(($U+192)) 660 _sndiop 342 ;; 343 344apm*) 345 M apm c 34 0 644 346 M apmctl c 34 8 644 347 ;; 348 349usb*) 350 [ "$i" = "usb" ] && u= || u=$U 351 M usb$u c 64 $U 640 352 ;; 353 354ulpt*) 355 M ulpt$U c 66 $U 600 356 ;; 357 358ujoy) 359 RMlist[${#RMlist[*]}]=";mkdir -p ujoy;rm -f" n=0 360 while [ $n -lt 4 ];do M ujoy/$n c 108 $n 444;n=$(($n+1));done 361 MKlist[${#MKlist[*]}]=";chmod 555 ujoy" 362 ;; 363 364fido) 365 RMlist[${#RMlist[*]}]=";mkdir -p fido;rm -f" n=0 366 while [ $n -lt 4 ];do M fido/$n c 106 $n 666;n=$(($n+1));done 367 MKlist[${#MKlist[*]}]=";chmod 555 fido" 368 ;; 369 370uhid*) 371 M uhid$U c 65 $U 600 372 ;; 373 374ugen*) 375 n=$(($U*16)) 376 for j in 0{0,1,2,3,4,5,6,7,8,9} 1{0,1,2,3,4,5} 377 do 378 M ugen$U.$j c 70 $(($n+10#$j)) 600 379 done 380 ;; 381 382uall) 383 R ttyU0 ttyU1 ttyU2 ttyU3 ugen0 ugen1 ugen2 ugen3 ugen4 ugen5 384 R ugen6 ugen7 ulpt0 ulpt1 ujoy fido uhid0 uhid1 uhid2 uhid3 385 R uhid4 uhid5 uhid6 uhid7 usb0 usb1 usb2 usb3 usb4 usb5 usb6 386 R usb7 387 ;; 388 389ttyU[0-9a-zA-Z]) 390 U=${i#ttyU*} 391 o=$(alph2d $U) 392 M ttyU$U c 68 $o 660 dialer root 393 M cuaU$U c 68 $(($o+128)) 660 dialer root 394 ;; 395 396wsmux|wsmouse|wskbd) 397 M wsmouse c 63 0 600 398 M wskbd c 63 1 600 399 ;; 400 401wsmouse[0-9]*) 402 M wsmouse$U c 62 $U 600 403 ;; 404 405wskbd[0-9]*) 406 M wskbd$U c 61 $U 600 407 ;; 408 409wscons) 410 R wsmouse0 wsmouse1 wsmouse2 wsmouse3 wsmouse4 wsmouse5 411 R wsmouse6 wsmouse7 wsmouse8 wsmouse9 wskbd0 wskbd1 wskbd2 412 R wskbd3 wsmux ttyCcfg ttyC0 ttyC1 ttyC2 ttyC3 ttyC4 ttyC5 413 R ttyC6 ttyC7 ttyC8 ttyC9 ttyCa ttyCb 414 ;; 415 416tty[C-J]*) 417 U=${i##tty[C-J]} 418 case $i in 419 ttyC*) n=C m=0;; 420 ttyD*) n=D m=256;; 421 ttyE*) n=E m=512;; 422 ttyF*) n=F m=768;; 423 ttyG*) n=G m=1024;; 424 ttyH*) n=H m=1280;; 425 ttyI*) n=I m=1536;; 426 ttyJ*) n=J m=1792;; 427 esac 428 case $U in 429 [0-9a-f]) M tty$n$U c 60 $((16#$U+$m)) 600;; 430 cfg) M tty${n}cfg c 60 $((255+$m)) 600;; 431 *) echo bad unit $U for $i; exit 1;; 432 esac 433 ;; 434 435pty*) 436 if [ $U -gt 15 ]; then 437 echo bad unit for pty in: $i 438 continue 439 fi 440 set -A letters p q r s t u v w x y z P Q R S T 441 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 \ 442 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 \ 443 Y Z 444 445 name=${letters[$U]} 446 n=0 447 while [ $n -lt 62 ] 448 do 449 nam=$name${suffixes[$n]} 450 off=$(($U*62)) 451 M tty$nam c 4 $(($off+$n)) 452 M pty$nam c 5 $(($off+$n)) 453 n=$(($n+1)) 454 done 455 ;; 456 457ptm) 458 M ptm c 98 0 666 459 ;; 460 461tty[0-7][0-9a-f]) 462 U=${i#tty*} 463 o=$(h2d $U) 464 M tty$U c 12 $o 660 dialer root 465 M cua$U c 12 $(($o+128)) 660 dialer root 466 ;; 467 468st*) 469 n=$(($U*16)) 470 for pre in " " n e en 471 do 472 M ${pre}rst$U c 25 $n 660 operator 473 n=$(($n+1)) 474 done 475 ;; 476 477vnd*) 478 dodisk vnd $U 19 19 $U 0 479 ;; 480 481rd*) 482 dodisk2 rd $U 18 18 $U 0 483 ;; 484 485ch*) 486 M ch$U c 27 $U 660 operator 487 ;; 488 489cd*) 490 dodisk2 cd $U 26 26 $U 0 491 ;; 492 493local) 494 test -s $T.local && sh $T.local 495 ;; 496 497all) 498 R gpio0 gpio1 gpio2 gpio3 gpio4 gpio5 gpio6 gpio7 gpio8 499 R switch0 switch1 switch2 switch3 vnd0 vnd1 vnd2 vnd3 sd0 sd1 500 R sd2 sd3 sd4 sd5 sd6 sd7 sd8 sd9 cd0 cd1 rd0 tap0 tap1 tap2 501 R tap3 tun0 tun1 tun2 tun3 bio pty0 diskmap vscsi0 ch0 kstat 502 R dt bpf fuse pppac pppx hotplug ptm local wscons pci0 pci1 503 R pci2 pci3 uall rmidi0 rmidi1 rmidi2 rmidi3 rmidi4 rmidi5 504 R rmidi6 rmidi7 tuner0 radio0 video0 video1 uk0 random tty00 505 R tty01 tty02 tty03 tty04 tty05 tty06 tty07 tty08 tty09 tty0a 506 R tty0b apm pf wd0 wd1 wd2 wd3 std st0 st1 fd 507 ;; 508 509wd*|sd*) 510 case $i in 511 wd*) dodisk wd $U 16 16 $U 0;; 512 sd*) dodisk sd $U 24 24 $U 0;; 513 esac 514 ;; 515 516*) 517 echo $i: unknown device 518 ;; 519esac 520done 521} 522R "$@" 523{ 524echo -n ${RMlist[*]} 525echo -n ${mklist[*]} 526echo -n ${MKlist[*]} 527echo -n ${whlist[*]} 528echo ${oplist[*]} 529} | if [ "$eo" = "echo" ]; then 530 cat 531else 532 sh 533fi 534