NetBSD/etc/etc.hp700/MAKEDEV

278 lines
6.6 KiB
Bash

#!/bin/sh -
#
# $NetBSD: MAKEDEV,v 1.13 2003/07/27 14:18:03 itojun Exp $
#
# Copyright (c) 1990 The Regents of the University of California.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# 3. All advertising materials mentioning features or use of this software
# must display the following acknowledgement:
# This product includes software developed by the University of
# California, Berkeley and its contributors.
# 4. Neither the name of the University nor the names of its contributors
# may be used to endorse or promote products derived from this software
# without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
# @(#)MAKEDEV 5.5 (Berkeley) 5/28/91
#
###########################################################################
#
# PLEASE RUN "cd ../share/man/man8 ; make makedevs"
# AFTER CHANGING THIS FILE, AND COMMIT THE UPDATED MANPAGE!
#
###########################################################################
#
# Device "make" file. Valid arguments:
# std standard devices
# local configuration specific devices
# Tapes:
# st* SCSI tape
# Disks:
# sd* SCSI disks
# vnd* "file" pseudo-disks
# ccd* concatenated disk driver
# cgd* cryptographic disk driver
# raid* RAIDframe disk driver
# md* memory pseudo-disk devices
# Pseudo terminals:
# pty* set of 16 master and slave pseudo terminals
# Special purpose devices:
# bpf* packet filter
# lkm loadable kernel modules interface
# tun* network tunnel driver
# random Random number generator
# scsibus* SCSI busses, see scsi(4), scsictl(8)
# systrace syscall tracer
# pf PF packet filter
PATH=/sbin:/bin:/usr/sbin:/usr/bin
umask 77
# Check if we have fdesc mounted
if [ -d fd ]; then
case "`df fd`" in
*fdesc*) nofdesc=false;;
*) nofdesc=true;;
esac
else
nofdesc=true
fi
# set this to echo for Echo-Only debugging
eo=
# mk name b/c major minor [mode] [group]
mk() {
$eo rm -f $1
$eo mknod $1 $2 $3 $4
$eo chmod ${5-666} $1
test -n "$6" && $eo chgrp $6 $1
return 0
}
makedev()
{
for arg
do
unit=`expr $arg : '[a-z][a-z]*\([0-9][0-9]*\)'`
[ "$unit" ] || unit=0
case $arg in
init|all)
makedev std pty0 pty1 pty2 pty3
makedev raid0 raid1 raid2 raid3
makedev sd0 sd1 sd2 sd3 sd4 sd5 sd6
makedev cd0 cd1 st0 st1 st2 md0 md1
makedev vnd0 vnd1 vnd2 vnd3 ccd0 ccd1 ccd2 ccd3
makedev cgd0 cgd1 cgd2 cgd3
makedev bpf0 bpf1 bpf2 bpf3 bpf4 bpf5 bpf6 bpf7
makedev tun0 tun1
makedev lkm random
makedev scsibus0 scsibus1 scsibus2 scsibus3
makedev local
makedev systrace
;;
std)
mk console c 0 0 622
mk tty c 1 0
mk mem c 2 0 640 kmem
mk kmem c 2 1 640 kmem
mk null c 2 2
mk zero c 2 12
mk drum c 3 0 640 kmem
mk klog c 6 0 600
mk stdin c 16 0
mk stdout c 16 1
mk stderr c 16 2
mk ksyms c 36 0 444
;;
bpf*)
mk bpf$unit c 17 $unit 600
;;
tun*)
mk tun$unit c 18 $unit 600
;;
pty*)
class=${i#pty}
name=`echo pqrstuvwxyzPQRST | dd bs=1 count=1 skip=$class 2>/dev/null`
case $name in
v) echo "$0: $i: pty unit conflicts with console ttyv0 device."
continue;;
?) ;;
*) echo "$0: $i: pty unit must be between 0 and 15"
continue ;;
esac
rm -f tty$name[0-9a-zA-Z] pty$name[0-9a-zA-Z]
jn=0
while [ $jn -lt 62 ]
do
j=`echo 0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ | dd bs=1 count=1 skip=$jn 2>/dev/null`
skip=0
if [ $jn -ge 16 ]; then
skip=$(($class * 30 + 256 - 16))
fi
unit=$(($class * 62 + $jn + $skip))
mknod tty$name$j c 4 $unit
mknod pty$name$j c 5 $unit
jn=$(($jn + 1))
done
chmod 666 tty$name[0-9a-zA-Z] pty$name[0-9a-zA-Z]
;;
raid*)
# XXX fredette - need to re-enable raid below, re-add to case arm:
;;
ccd*|cgd*|cd*|fd*|sd*|vnd*)
case $arg in
ccd*) name=ccd; blk=1; chr=7;;
cgd*) name=cgd; blk=8; chr=35;;
cd*) name=cd; blk=6; chr=12;;
fd*) name=fd; blk=7; chr=24;;
# raid*) name=raid; blk=25; chr=82;;
sd*) name=sd; blk=4; chr=10;;
vnd*) name=vnd; blk=2; chr=8;;
esac
case $unit in
[0-7]) offset=$(($unit * 16));;
*) echo bad unit for $name in: $arg;;
esac
for part in a.0 b.1 c.2 d.3 e.4 f.5 g.6 h.7 i.8 j.9 k.10 l.11 m.12 n.13 o.14 p.15
do
(
tmp="$IFS" ; IFS="$IFS."
set -- $part
IFS="$tmp" ; unset tmp
minor=$(($offset + $2))
mk $name$unit$1 b $blk $minor 640 operator
mk r$name$unit$1 c $chr $minor 640 operator
)
done
;;
st*)
name=st; blk=5; chr=11
mk r$name$unit c $chr $(($unit * 16 + 0)) 660 operator
mk nr$name$unit c $chr $(($unit * 16 + 1)) 660 operator
mk er$name$unit c $chr $(($unit * 16 + 2)) 660 operator
mk enr$name$unit c $chr $(($unit * 16 + 3)) 660 operator
;;
fd)
if $nofdesc; then
rm -f fd/*
mkdir fd 2>/dev/null
n=0
while [ $n -lt 64 ]; do
mknod fd/$n c 16 $n
n=$(($n + 1))
done
chmod 755 fd
chmod 666 fd/*
fi
;;
# XXX fredette - MD devices could go here:
md*)
# XXX fredette - need to put in MD:
# name=md; blk=13; chr=52
# mk md${unit}a b $blk $(($unit * 16 + 0)) 640 operator
# mk md${unit}c b $blk $(($unit * 16 + 2)) 640 operator
## mk rmd${unit}a c $chr $(($unit * 16 + 0)) 640 operator
## mk rmd${unit}c c $chr $(($unit * 16 + 2)) 640 operator
;;
lkm)
mk lkm c 19 0 640 kmem
;;
random)
mk random c 20 0 444
mk urandom c 20 1
;;
scsibus*)
# XXX fredette - need to put in scsibus:
# mk scsibus${unit} c 81 $unit 644
;;
systrace)
rm -f systrace
mknod systrace c 34 0
chmod 644 systrace
;;
pf)
rm -f pf
mknod pf c 37 0
chmod 600 pf
;;
local)
if [ -f "$0.local" ]; then
umask 0
sh $0.local all
umask 77
fi
;;
*)
echo $arg: unknown device
;;
esac
done
}
makedev $*