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