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