MAKEDEV: Add mtree output, and ramdisk set.
Change-Id: I36cb7e9451960189a33a04a5c2e3ddb19c7be75e
This commit is contained in:
parent
45783c536a
commit
4c87adc85c
6 changed files with 494 additions and 356 deletions
57
commands/MAKEDEV/MAKEDEV.8
Normal file
57
commands/MAKEDEV/MAKEDEV.8
Normal file
|
@ -0,0 +1,57 @@
|
|||
.Dd October 4, 2013
|
||||
.Dt MAKEDEV 8
|
||||
.Os
|
||||
.Sh NAME
|
||||
.Nm MAKEDEV, DESCRIBE
|
||||
.Nd make/describe device files
|
||||
.Sh SYNOPSIS
|
||||
.Nm MAKEDEV
|
||||
.Op Fl n | Fl m
|
||||
.Op Fl r | Fl s
|
||||
.Op key ...
|
||||
.Nm DESCRIBE
|
||||
.Op device ...
|
||||
.Sh DESCRIPTION
|
||||
.Nm MAKEDEV
|
||||
may be used to create the device files normally found in the /dev directory.
|
||||
.Nm MAKEDEV
|
||||
knows about all supported devices and will create them in the current
|
||||
directory with the proper owner and mode. For many devices
|
||||
.Nm MAKEDEV
|
||||
will not only create the device you want, but also the devices related
|
||||
to it that you will probably want too. Naming one floppy device will
|
||||
create all floppy devices for the same drive for instance.
|
||||
.Pp
|
||||
The options are as follows:
|
||||
.Bl -tag -width Xxxexcludexfilexx
|
||||
.It Fl n
|
||||
echo the commands it would execute when you call it without that flag.
|
||||
.It Fl m
|
||||
echo
|
||||
.Nm mtree(8)
|
||||
formatted lines instead of creating the device nodes.
|
||||
.It Fl r
|
||||
Restricted set of devices. This set is used when generating the ramdisk.
|
||||
.It Fl s
|
||||
Standard set of devices. This set is used when popluating /dev.
|
||||
.El
|
||||
.Pp
|
||||
.Ar key
|
||||
arguments are simply the names of the devices you want to create. Call
|
||||
.Nm MAKEDEV
|
||||
without arguments to see a list of keys that it understands.
|
||||
.Pp
|
||||
The command
|
||||
.Nm DESCRIBE
|
||||
will give you a one-line description of a given device. By default It
|
||||
will list all devices in /dev.
|
||||
.Sh "SEE ALSO"
|
||||
.Xr dev 4 ,
|
||||
.Xr mknod 8
|
||||
.Sh BUGS
|
||||
The eagerness of
|
||||
.Nm MAKEDEV
|
||||
to create devices may cause many "File exists" errors from
|
||||
.Nm mknod .
|
||||
.Sh AUTHORS
|
||||
Written by Kees J. Bot (kjb@cs.vu.nl) and Lionel A. Sambuc (lionel@minix3.org)
|
733
commands/MAKEDEV/MAKEDEV.sh
Normal file → Executable file
733
commands/MAKEDEV/MAKEDEV.sh
Normal file → Executable file
|
@ -1,43 +1,115 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# MAKEDEV 3.3 - Make special devices. Author: Kees J. Bot
|
||||
# 3.4 - Rewritten to allow mtree line to be printed, Lionel A. Sambuc
|
||||
# also use getopt for argument parsing
|
||||
umask 077
|
||||
|
||||
case $1 in
|
||||
-n) e=echo; shift ;; # Just echo when -n is given.
|
||||
*) e=
|
||||
esac
|
||||
MTREE=false
|
||||
STD=false
|
||||
RAMDISK=false
|
||||
ECHO=
|
||||
EXIT=0
|
||||
|
||||
case $#:$1 in
|
||||
1:std) # Standard devices.
|
||||
set -$- mem fd0 fd1 fd0p0 fd1p0 \
|
||||
c0d0 c0d0p0 c0d0p0s0 c0d1 c0d1p0 c0d1p0s0 \
|
||||
c0d2 c0d2p0 c0d2p0s0 c0d3 c0d3p0 c0d3p0s0 \
|
||||
c0d4 c0d4p0 c0d4p0s0 c0d5 c0d5p0 c0d5p0s0 \
|
||||
c0d6 c0d6p0 c0d6p0s0 c0d7 c0d7p0 c0d7p0s0 \
|
||||
c1d0 c1d0p0 c1d0p0s0 c1d1 c1d1p0 c1d1p0s0 \
|
||||
c1d2 c1d2p0 c1d2p0s0 c1d3 c1d3p0 c1d3p0s0 \
|
||||
c1d4 c1d4p0 c1d4p0s0 c1d5 c1d5p0 c1d5p0s0 \
|
||||
c1d6 c1d6p0 c1d6p0s0 c1d7 c1d7p0 c1d7p0s0 \
|
||||
tty ttyc1 ttyc2 ttyc3 tty00 tty01 tty02 tty03 \
|
||||
ttyp0 ttyp1 ttyp2 ttyp3 ttyp4 ttyp5 ttyp6 ttyp7 ttyp8 ttyp9 \
|
||||
ttypa ttypb ttypc ttypd ttype ttypf \
|
||||
ttyq0 ttyq1 ttyq2 ttyq3 ttyq4 ttyq5 ttyq6 ttyq7 ttyq8 ttyq9 \
|
||||
ttyqa ttyqb ttyqc ttyqd ttyqe ttyqf \
|
||||
eth klog random uds filter fbd hello fb0 \
|
||||
i2c-1 i2c-2 i2c-3 \
|
||||
eepromb1s50 eepromb1s51 eepromb1s52 eepromb1s53 \
|
||||
eepromb1s54 eepromb1s55 eepromb1s56 eepromb1s57 \
|
||||
eepromb2s50 eepromb2s51 eepromb2s52 eepromb2s53 \
|
||||
eepromb2s54 eepromb2s55 eepromb2s56 eepromb2s57 \
|
||||
eepromb3s50 eepromb3s51 eepromb3s52 eepromb3s53 \
|
||||
eepromb3s54 eepromb3s55 eepromb3s56 eepromb3s57 \
|
||||
tsl2550b1s39 tsl2550b2s39 tsl2550b3s39 \
|
||||
sht21b1s40 sht21b2s40 sht21b3s40 \
|
||||
# console => lp tty log
|
||||
# boot => kmem mem null ram zero
|
||||
RAMDISK_DEVICES="
|
||||
boot
|
||||
console
|
||||
input
|
||||
c0d0 c0d0p0 c0d0p0s0 c0d1 c0d1p0 c0d1p0s0
|
||||
c0d2 c0d2p0 c0d2p0s0 c0d3 c0d3p0 c0d3p0s0
|
||||
c0d4 c0d4p0 c0d4p0s0 c0d5 c0d5p0 c0d5p0s0
|
||||
c0d6 c0d6p0 c0d6p0s0 c0d7 c0d7p0 c0d7p0s0
|
||||
c1d0 c1d0p0 c1d0p0s0 c1d1 c1d1p0 c1d1p0s0
|
||||
c1d2 c1d2p0 c1d2p0s0 c1d3 c1d3p0 c1d3p0s0
|
||||
c1d4 c1d4p0 c1d4p0s0 c1d5 c1d5p0 c1d5p0s0
|
||||
c1d6 c1d6p0 c1d6p0s0 c1d7 c1d7p0 c1d7p0s0
|
||||
fd0 fd1 fd0p0 fd1p0
|
||||
ttyc1 ttyc2 ttyc3 tty00 tty01 tty02 tty03
|
||||
ttyp0 ttyp1 ttyp2 ttyp3 ttyp4 ttyp5 ttyp6 ttyp7 ttyp8 ttyp9
|
||||
ttypa ttypb ttypc ttypd ttype ttypf
|
||||
ttyq0 ttyq1 ttyq2 ttyq3 ttyq4 ttyq5 ttyq6 ttyq7 ttyq8 ttyq9
|
||||
ttyqa ttyqb ttyqc ttyqd ttyqe ttyqf
|
||||
"
|
||||
|
||||
#eth => ip tcp udp
|
||||
STD_DEVICES="
|
||||
${RAMDISK_DEVICES}
|
||||
bmp085b1s77 bmp085b2s77 bmp085b3s77
|
||||
;;
|
||||
0:|1:-\?)
|
||||
cat >&2 <<EOF
|
||||
Usage: $0 [-n] key ...
|
||||
eepromb1s50 eepromb1s51 eepromb1s52 eepromb1s53
|
||||
eepromb1s54 eepromb1s55 eepromb1s56 eepromb1s57
|
||||
eepromb2s50 eepromb2s51 eepromb2s52 eepromb2s53
|
||||
eepromb2s54 eepromb2s55 eepromb2s56 eepromb2s57
|
||||
eepromb3s50 eepromb3s51 eepromb3s52 eepromb3s53
|
||||
eepromb3s54 eepromb3s55 eepromb3s56 eepromb3s57
|
||||
eth fb0 fbd filter hello
|
||||
i2c-1 i2c-2 i2c-3
|
||||
klog random
|
||||
sht21b1s40 sht21b2s40 sht21b3s40
|
||||
tsl2550b1s39 tsl2550b2s39 tsl2550b3s39
|
||||
uds
|
||||
vnd0 vnd0p0 vnd0p0s0 vnd1 vnd1p0 vnd1p0s0
|
||||
vnd2 vnd3 vnd4 vnd5 vnd6 vnd7
|
||||
"
|
||||
|
||||
#makedev ${dev} $type ${major} ${minor} ${uname} ${gname} ${permissions} [link_target]
|
||||
#When called for a link, major and minor are ignored
|
||||
makedev()
|
||||
{
|
||||
# Check that all the arguments are there, we trust the caller to put
|
||||
# values which make sens.
|
||||
[ $# -eq 7 ] || [ $# -eq 8 ] || return 1;
|
||||
|
||||
local _dev=$1
|
||||
local __type=$2
|
||||
local _major=$3
|
||||
local _minor=$4
|
||||
local _uname=$5
|
||||
local _gname=$6
|
||||
local _mode=$7
|
||||
|
||||
case ${__type} in
|
||||
b)_type=block;;
|
||||
c) _type=char;;
|
||||
l) _type=link; _target=$8;;
|
||||
*) return 2;;
|
||||
esac
|
||||
|
||||
if [ ${MTREE} = "yes" ]
|
||||
then
|
||||
if [ ${_type} = "link" ]
|
||||
then
|
||||
echo ./dev/${_dev} type=${_type} \
|
||||
uname=${_uname} gname=${_gname} mode=${_mode} \
|
||||
link=${_target}
|
||||
else
|
||||
echo ./dev/${_dev} type=${_type} \
|
||||
uname=${_uname} gname=${_gname} mode=${_mode} \
|
||||
device=native,${_major},${_minor}
|
||||
fi
|
||||
else
|
||||
if [ ${_type} = "link" ]
|
||||
then
|
||||
${ECHO} ln -f ${_target} ${_dev}
|
||||
else
|
||||
${ECHO} mknod ${_dev} ${__type} ${_major} ${_minor}
|
||||
${ECHO} chmod ${_mode} ${_dev}
|
||||
${ECHO} chown ${_uname}:${_gname} ${_dev}
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
# no_return usage()
|
||||
usage()
|
||||
{
|
||||
cat >&2 <<EOF
|
||||
Usage: $0 [-n|-m] [-s|-r] key ...
|
||||
-n: print the commands instead of executing them
|
||||
-m: print mtree(8) line
|
||||
-s: standard set of devices
|
||||
-r: reduced for ramdisk set of devices
|
||||
|
||||
Where key is one of the following:
|
||||
ram mem kmem null boot zero # One of these makes all these memory devices
|
||||
fb0 # Make /dev/fb0
|
||||
|
@ -67,274 +139,337 @@ Where key is one of the following:
|
|||
fbd # Make /dev/fbd
|
||||
hello # Make /dev/hello
|
||||
video # Make /dev/video
|
||||
std # All standard devices
|
||||
vnd0 vnd0p0 vnd0p0s0 .. # Make vnode disks /dev/vnd[0-7] and (sub)partitions
|
||||
input # Make /dev/kbdmux, /dev/kbd[0-3], idem /dev/mouse~
|
||||
EOF
|
||||
exit 1
|
||||
esac
|
||||
exit 1
|
||||
}
|
||||
|
||||
umask 077
|
||||
ex=0
|
||||
|
||||
for dev
|
||||
# Parse options
|
||||
while getopts "nmrs" arg
|
||||
do
|
||||
case $dev in # One of the controllers? Precompute major device nr.
|
||||
c0*) maj=3 ;;
|
||||
c1*) maj=8 ;;
|
||||
c2*) maj=10 ;;
|
||||
c3*) maj=12 ;;
|
||||
esac
|
||||
|
||||
case $dev in
|
||||
ram|mem|kmem|null|boot|zero|imgrd)
|
||||
# Memory devices.
|
||||
#
|
||||
$e mknod ram b 1 0; $e chmod 600 ram
|
||||
$e mknod mem c 1 1; $e chmod 640 mem
|
||||
$e mknod kmem c 1 2; $e chmod 640 kmem
|
||||
$e mknod null c 1 3; $e chmod 666 null
|
||||
$e mknod boot b 1 4; $e chmod 600 ram
|
||||
$e mknod zero c 1 5; $e chmod 644 zero
|
||||
$e mknod imgrd b 1 6; $e chmod 644 zero
|
||||
for n in 0 1 2 3 4 5
|
||||
do $e mknod ram$n b 1 $((7+$n)); $e chmod 600 ram$n
|
||||
done
|
||||
$e chgrp kmem ram* mem kmem null boot zero imgrd
|
||||
;;
|
||||
fd[0-3])
|
||||
# Floppy disk drive n.
|
||||
#
|
||||
d=`expr $dev : '.*\\(.\\)'` # Drive number.
|
||||
$e mknod $dev b 2 $d
|
||||
$e chmod 666 $dev
|
||||
;;
|
||||
pc[0-3]|at[0-3]|qd[0-3]|ps[0-3]|pat[0-3]|qh[0-3]|PS[0-3])
|
||||
# Obsolete density locked floppy disk drive n.
|
||||
#
|
||||
d=`expr $dev : '.*\\(.\\)'` # Drive number.
|
||||
m=$d # Minor device number.
|
||||
|
||||
$e mknod pc$d b 2 $m; m=`expr $m + 4`
|
||||
$e mknod at$d b 2 $m; m=`expr $m + 4`
|
||||
$e mknod qd$d b 2 $m; m=`expr $m + 4`
|
||||
$e mknod ps$d b 2 $m; m=`expr $m + 4`
|
||||
$e mknod pat$d b 2 $m; m=`expr $m + 4`
|
||||
$e mknod qh$d b 2 $m; m=`expr $m + 4`
|
||||
$e mknod PS$d b 2 $m; m=`expr $m + 4`
|
||||
|
||||
$e chmod 666 pc$d at$d qd$d ps$d pat$d qh$d PS$d
|
||||
;;
|
||||
fd[0-3]p[0-3])
|
||||
# Floppy disk partitions.
|
||||
#
|
||||
n=`expr $dev : '\\(.*\\)..'` # Name prefix.
|
||||
d=`expr $dev : '..\\(.\\)'` # Drive number.
|
||||
m=`expr 112 + $d` # Minor of partition 0.
|
||||
alldev=
|
||||
|
||||
for p in 0 1 2 3
|
||||
do
|
||||
m=`expr 112 + $d + $p '*' 4` # Minor of partition $p.
|
||||
$e mknod ${n}p${p} b 2 $m # Make e.g. fd0p0 - fd0p3
|
||||
alldev="$alldev ${n}p${p}"
|
||||
done
|
||||
$e chmod 666 $alldev
|
||||
;;
|
||||
c[0-3]d[0-7])
|
||||
# Whole disk devices.
|
||||
d=`expr $dev : '...\\(.\\)'` # Disk number.
|
||||
m=`expr $d '*' 5` # Minor device number.
|
||||
$e mknod $dev b $maj $m
|
||||
$e chmod 600 $dev
|
||||
;;
|
||||
c[0-3]d[0-7]p[0-3])
|
||||
# Disk primary partitions.
|
||||
n=`expr $dev : '\\(.*\\).'` # Name prefix.
|
||||
d=`expr $dev : '...\\(.\\)'` # Disk number.
|
||||
alldev=
|
||||
|
||||
for p in 0 1 2 3
|
||||
do
|
||||
m=`expr $d '*' 5 + 1 + $p` # Minor device number.
|
||||
$e mknod $n$p b $maj $m
|
||||
alldev="$alldev $n$p"
|
||||
done
|
||||
echo $alldev | xargs $e chmod 600
|
||||
;;
|
||||
c[0-3]d[0-7]p[0-3]s[0-3])
|
||||
# Disk subpartition.
|
||||
n=`expr $dev : '\\(.*\\)...'` # Name prefix.
|
||||
d=`expr $dev : '...\\(.\\)'` # Disk number.
|
||||
alldev=
|
||||
|
||||
for p in 0 1 2 3
|
||||
do
|
||||
for s in 0 1 2 3
|
||||
do
|
||||
m=`expr 128 + $d '*' 16 + $p '*' 4 + $s` # Minor device nr.
|
||||
$e mknod ${n}${p}s${s} b $maj $m
|
||||
alldev="$alldev ${n}${p}s${s}"
|
||||
done
|
||||
done
|
||||
echo $alldev | xargs $e chmod 600
|
||||
;;
|
||||
c[0-3]t[0-7]|c[0-3]t[0-7]n)
|
||||
# Tape devices.
|
||||
n=`expr $dev : '\\(....\\)'` # Name prefix.
|
||||
t=`expr $dev : '...\\(.\\)'` # Tape number.
|
||||
m=`expr 64 + $t '*' 2` # Minor device number.
|
||||
$e mknod ${n}n c $maj $m
|
||||
$e mknod ${n} c $maj `expr $m + 1`
|
||||
$e chmod 660 ${n}n ${n}
|
||||
;;
|
||||
console|lp|tty|log|kbd|kbdaux|video)
|
||||
# Console, line printer, anonymous tty, diagnostics device,
|
||||
# raw keyboard, ps/2 mouse, video.
|
||||
$e mknod console c 4 0
|
||||
$e chmod 600 console
|
||||
$e chgrp tty console
|
||||
$e mknod tty c 5 0
|
||||
$e chmod 666 tty
|
||||
$e mknod lp c 6 0
|
||||
$e chown daemon lp
|
||||
$e chgrp daemon lp
|
||||
$e chmod 200 lp
|
||||
$e mknod log c 4 15
|
||||
$e chmod 222 log
|
||||
$e mknod kbd c 4 127
|
||||
$e mknod kbdaux c 4 126
|
||||
$e chmod 660 kbd kbdaux
|
||||
$e chgrp operator kbd kbdaux
|
||||
$e mknod video c 4 125
|
||||
$e chmod 600 video
|
||||
$e chgrp operator video
|
||||
;;
|
||||
ttyc[1-7])
|
||||
# Virtual consoles.
|
||||
#
|
||||
m=`expr $dev : '....\\(.*\\)'` # Minor device number.
|
||||
$e mknod $dev c 4 $m
|
||||
$e chgrp tty $dev
|
||||
$e chmod 600 $dev
|
||||
;;
|
||||
tty0[0-3])
|
||||
# Serial lines.
|
||||
#
|
||||
n=`expr $dev : '.*\\(.\\)'`
|
||||
$e mknod $dev c 4 `expr $n + 16`
|
||||
$e chmod 666 $dev
|
||||
$e chgrp tty $dev
|
||||
;;
|
||||
tty[p-s][0-9a-f]|pty[p-s][0-9a-f])
|
||||
# Pseudo ttys.
|
||||
#
|
||||
dev=`expr $dev : '...\\(..\\)'`
|
||||
g=`expr $dev : '\\(.\\)'` # Which group.
|
||||
g=`echo $g | tr 'pqrs' '0123'`
|
||||
n=`expr $dev : '.\\(.\\)'` # Which pty in the group.
|
||||
case $n in
|
||||
[a-f]) n=1`/bin/echo $n | tr 'abcdef' '012345'`
|
||||
case "$arg" in
|
||||
n)
|
||||
ECHO=echo
|
||||
;;
|
||||
m)
|
||||
MTREE=yes
|
||||
;;
|
||||
r)
|
||||
RAMDISK=yes
|
||||
;;
|
||||
s)
|
||||
STD=yes
|
||||
;;
|
||||
h|\?)
|
||||
usage
|
||||
;;
|
||||
esac
|
||||
|
||||
$e mknod tty$dev c 4 `expr $g '*' 16 + $n + 128`
|
||||
$e mknod pty$dev c 4 `expr $g '*' 16 + $n + 192`
|
||||
$e chgrp tty tty$dev pty$dev
|
||||
$e chmod 666 tty$dev pty$dev
|
||||
;;
|
||||
eth|ip|tcp|udp|eth0|ip0|tcp0|udp0)
|
||||
# TCP/IP devices.
|
||||
#
|
||||
$e mknod eth0 c 7 0 # Network 0 (Ethernet)
|
||||
$e mknod ip0 c 7 1
|
||||
$e mknod tcp0 c 7 2
|
||||
$e mknod udp0 c 7 3
|
||||
$e chmod 600 eth0 ip0
|
||||
$e chmod 666 tcp0 udp0
|
||||
$e ln -f eth0 eth # Default interface
|
||||
$e ln -f ip0 ip
|
||||
$e ln -f tcp0 tcp
|
||||
$e ln -f udp0 udp
|
||||
;;
|
||||
audio|mixer)
|
||||
# Audio devices.
|
||||
#
|
||||
$e mknod audio c 13 0
|
||||
$e mknod mixer c 13 1
|
||||
$e chmod 666 audio mixer
|
||||
;;
|
||||
random|urandom)
|
||||
# random data generator.
|
||||
$e mknod random c 16 0; $e chmod 644 random
|
||||
$e mknod urandom c 16 0; $e chmod 644 urandom
|
||||
$e chgrp operator random urandom
|
||||
;;
|
||||
uds)
|
||||
# unix domain sockets device
|
||||
$e mknod uds c 18 0;
|
||||
$e chgrp operator uds
|
||||
$e chmod 666 uds
|
||||
;;
|
||||
klog)
|
||||
# logging device.
|
||||
$e mknod klog c 15 0
|
||||
$e chmod 600 klog
|
||||
;;
|
||||
filter)
|
||||
# filter driver
|
||||
$e mknod filter b 11 0
|
||||
$e chmod 600 filter
|
||||
;;
|
||||
fbd)
|
||||
# faulty block device driver
|
||||
$e mknod fbd b 14 0
|
||||
$e chmod 600 fbd
|
||||
;;
|
||||
hello)
|
||||
# hello driver
|
||||
$e mknod hello c 17 0
|
||||
$e chmod 644 hello
|
||||
;;
|
||||
fb0)
|
||||
# framebuffer driver
|
||||
$e mknod fb0 c 19 0
|
||||
$e chmod 644 fb0
|
||||
;;
|
||||
i2c-[1-3])
|
||||
# i2c driver
|
||||
b=`expr $dev : '....\\(.*\\)'` # bus number
|
||||
m=`expr $dev : '....\\(.*\\)' - 1` # least significant digit of major
|
||||
$e mknod i2c-${b} c 2${m} 0
|
||||
$e chmod 600 i2c-${b}
|
||||
;;
|
||||
eepromb[1-3]s5[0-7])
|
||||
# cat24c256 driver
|
||||
b=`expr $dev : 'eepromb\\(.*\\)s'` # bus number
|
||||
s=`expr $dev : 'eepromb.s5\\(.*\\)'` # configurable part of slave addr
|
||||
m=`expr ${b} \* 8 + ${s} + 17`
|
||||
$e mknod eepromb${b}s5${s} b ${m} 0
|
||||
$e chmod 600 eepromb${b}s5${s}
|
||||
;;
|
||||
tsl2550b[1-3]s39)
|
||||
b=`expr $dev : 'tsl2550b\\(.*\\)s39'` #bus number
|
||||
m=`expr ${b} + 46`
|
||||
$e mknod tsl2550b${b}s39 c ${m} 0
|
||||
$e chmod 444 tsl2550b${b}s39
|
||||
;;
|
||||
sht21b[1-3]s40)
|
||||
b=`expr $dev : 'sht21b\\(.*\\)s40'` #bus number
|
||||
m=`expr ${b} + 49`
|
||||
$e mknod sht21b${b}s40 c ${m} 0
|
||||
$e chmod 444 sht21b${b}s40
|
||||
;;
|
||||
bmp085b[1-3]s77)
|
||||
b=`expr $dev : 'bmp085b\\(.*\\)s77'` #bus number
|
||||
m=`expr ${b} + 52`
|
||||
$e mknod bmp085b${b}s77 c ${m} 0
|
||||
$e chmod 444 bmp085b${b}s77
|
||||
;;
|
||||
*)
|
||||
echo "$0: don't know about $dev" >&2
|
||||
ex=1
|
||||
esac
|
||||
done
|
||||
|
||||
exit $ex
|
||||
if [ ${STD} = "yes" ]
|
||||
then
|
||||
DEVICES=${STD_DEVICES}
|
||||
elif [ ${RAMDISK} = "yes" ]
|
||||
then
|
||||
DEVICES=${RAMDISK_DEVICES}
|
||||
else
|
||||
while [ $OPTIND -gt 1 ]
|
||||
do
|
||||
shift
|
||||
OPTIND=$((${OPTIND} - 1))
|
||||
done
|
||||
while [ ! -z "$1" ]
|
||||
do
|
||||
DEVICES="${DEVICES} $1"
|
||||
shift
|
||||
done
|
||||
fi
|
||||
|
||||
for dev in ${DEVICES}
|
||||
do
|
||||
# Reset the defaults
|
||||
uname=root
|
||||
gname=operator
|
||||
permissions=600
|
||||
|
||||
case ${dev} in
|
||||
c0*) major=3 ;;
|
||||
c1*) major=8 ;;
|
||||
c2*) major=10 ;;
|
||||
c3*) major=12 ;;
|
||||
vnd*) # Whole vnode disk devices.
|
||||
disk=`expr ${dev} : '...\\(.\\)'`
|
||||
major=`expr ${disk} + 56`
|
||||
;;
|
||||
esac
|
||||
|
||||
# The following is lexicographicaly ordered
|
||||
case ${dev} in
|
||||
audio|mixer)
|
||||
# Audio devices.
|
||||
makedev audio c 13 0 ${uname} ${gname} 666
|
||||
makedev mixer c 13 1 ${uname} ${gname} 666
|
||||
;;
|
||||
bmp085b[1-3]s77)
|
||||
# Weather Cape: temperature & pressure sensor
|
||||
bus=`expr ${dev} : 'bmp085b\\(.*\\)s77'` #bus number
|
||||
major=`expr ${bus} + 52`
|
||||
|
||||
makedev bmp085b${bus}s77 c ${major} 0 ${uname} ${gname} 444
|
||||
;;
|
||||
c[0-3]d[0-7])
|
||||
# Whole disk devices.
|
||||
disk=`expr ${dev} : '...\\(.\\)'`
|
||||
minor=`expr ${disk} '*' 5`
|
||||
|
||||
makedev ${dev} b ${major} ${minor} ${uname} ${gname} ${permissions}
|
||||
;;
|
||||
c[0-3]d[0-7]p[0-3])
|
||||
# Disk primary partitions.
|
||||
prefix=`expr ${dev} : '\\(.*\\).'`
|
||||
disk=`expr ${dev} : '...\\(.\\)'`
|
||||
|
||||
for p in 0 1 2 3
|
||||
do
|
||||
minor=`expr ${disk} '*' 5 + 1 + ${p}`
|
||||
makedev ${prefix}${p} b ${major} ${minor} \
|
||||
${uname} ${gname} ${permissions}
|
||||
done
|
||||
;;
|
||||
c[0-3]d[0-7]p[0-3]s[0-3])
|
||||
# Disk subpartition.
|
||||
prefix=`expr ${dev} : '\\(.*\\)...'`
|
||||
disk=`expr ${dev} : '...\\(.\\)'`
|
||||
|
||||
for p in 0 1 2 3
|
||||
do
|
||||
for s in 0 1 2 3
|
||||
do
|
||||
minor=`expr 128 + ${disk} '*' 16 + ${p} '*' 4 + ${s}`
|
||||
makedev ${prefix}${p}s${s} b ${major} ${minor} \
|
||||
${uname} ${gname} ${permissions}
|
||||
done
|
||||
done
|
||||
;;
|
||||
c[0-3]t[0-7]|c[0-3]t[0-7]n)
|
||||
# Tape devices.
|
||||
prefix=`expr ${dev} : '\\(....\\)'`
|
||||
tape=`expr ${dev} : '...\\(.\\)'`
|
||||
minor=`expr 64 + ${tape} '*' 2`
|
||||
|
||||
makedev ${prefix}n c ${major} ${minor} ${uname} ${gname} 660
|
||||
makedev ${prefix} c ${major} `expr ${minor} + 1` ${uname} ${gname} 660
|
||||
;;
|
||||
console|lp|tty|log|video)
|
||||
# Console, line printer, anonymous tty, diagnostics device, video.
|
||||
makedev console c 4 0 ${uname} tty ${permissions}
|
||||
makedev tty c 5 0 ${uname} ${gname} 666
|
||||
makedev lp c 6 0 daemon daemon 200
|
||||
makedev log c 4 15 ${uname} ${gname} 222
|
||||
makedev video c 4 125 ${uname} ${gname} ${permissions}
|
||||
;;
|
||||
eepromb[1-3]s5[0-7])
|
||||
# cat24c256 driver
|
||||
bus=`expr ${dev} : 'eepromb\\(.*\\)s'`
|
||||
# configurable part of slave addr
|
||||
slave_low=`expr ${dev} : 'eepromb.s5\\(.*\\)'`
|
||||
major=`expr ${bus} '*' 8 + ${slave_low} + 17`
|
||||
|
||||
makedev eepromb${bus}s5${slave_low} b ${major} 0 ${uname} ${gname} ${permissions}
|
||||
;;
|
||||
eth|ip|tcp|udp|eth0|ip0|tcp0|udp0)
|
||||
# TCP/IP devices.
|
||||
makedev ipstat c 7 0 ${uname} ${gname} 666
|
||||
makedev eth0 c 7 1 ${uname} ${gname} ${permissions}
|
||||
makedev ip0 c 7 2 ${uname} ${gname} ${permissions}
|
||||
makedev tcp0 c 7 3 ${uname} ${gname} 666
|
||||
makedev udp0 c 7 4 ${uname} ${gname} 666
|
||||
|
||||
# Default interface
|
||||
makedev eth c 7 1 ${uname} ${gname} ${permissions}
|
||||
makedev ip c 7 2 ${uname} ${gname} ${permissions}
|
||||
makedev tcp c 7 3 ${uname} ${gname} 666
|
||||
makedev udp c 7 4 ${uname} ${gname} 666
|
||||
;;
|
||||
fb0)
|
||||
# Framebuffer driver
|
||||
makedev ${dev} c 19 0 ${uname} ${gname} 644
|
||||
;;
|
||||
fbd)
|
||||
# Faulty block device driver
|
||||
makedev ${dev} b 14 0 ${uname} ${gname} ${permissions}
|
||||
;;
|
||||
fd[0-3])
|
||||
# Floppy disk drive N has minor N.
|
||||
minor=`expr ${dev} : '..\\(.\\)'`
|
||||
|
||||
makedev ${dev} b 2 ${minor} ${uname} ${gname} 666
|
||||
;;
|
||||
fd[0-3]p[0-3])
|
||||
# Floppy disk partitions.
|
||||
prefix=`expr ${dev} : '\\(.*\\).'`
|
||||
drive=`expr ${dev} : '..\\(.\\)'`
|
||||
|
||||
for p in 0 1 2 3
|
||||
do
|
||||
minor=`expr 112 + ${drive} + ${p} '*' 4`
|
||||
makedev ${prefix}${p} b 2 ${minor} \
|
||||
${uname} ${gname} 666
|
||||
done
|
||||
;;
|
||||
filter)
|
||||
# Filter driver
|
||||
makedev ${dev} b 11 0 ${uname} ${gname} ${permissions}
|
||||
;;
|
||||
hello)
|
||||
# Hello driver
|
||||
makedev ${dev} c 17 0 ${uname} ${gname} 644
|
||||
;;
|
||||
i2c-[1-3])
|
||||
# i2c driver
|
||||
bus=`expr ${dev} : '....\\(.*\\)'` # bus number
|
||||
# least significant digit of major
|
||||
major_low=`expr ${dev} : '....\\(.*\\)'`
|
||||
major_low=`expr ${major_low} - 1`
|
||||
|
||||
makedev "i2c-${bus}" c 2${major_low} 0 ${uname} ${gname} ${permissions}
|
||||
;;
|
||||
input)
|
||||
# Input server
|
||||
makedev kbdmux c 64 0 ${uname} ${gname} ${permissions}
|
||||
makedev mousemux c 64 64 ${uname} ${gname} ${permissions}
|
||||
|
||||
for n in 0 1 2 3
|
||||
do
|
||||
minor_keyboard=`expr ${n} + 1`
|
||||
minor_mouse=`expr ${n} + 65`
|
||||
|
||||
makedev kbd${n} c 64 ${minor_keyboard} ${uname} ${gname} ${permissions}
|
||||
makedev mouse${n} c 64 ${minor_mouse} ${uname} ${gname} ${permissions}
|
||||
done
|
||||
;;
|
||||
klog)
|
||||
# Logging device.
|
||||
makedev ${dev} c 15 0 ${uname} ${gname} ${permissions}
|
||||
;;
|
||||
pc[0-3]|at[0-3]|qd[0-3]|ps[0-3]|pat[0-3]|qh[0-3]|PS[0-3])
|
||||
# Obsolete density locked floppy disk drive n.
|
||||
drive=`expr ${dev} : '.*\\(.\\)'`
|
||||
minor=${drive}
|
||||
|
||||
for prefix in pc at qd ps pat qh PS
|
||||
do
|
||||
makedev ${prefix}${drive} b 2 ${minor} \
|
||||
${uname} ${gname} 666
|
||||
minor=`expr ${minor} + 4`
|
||||
done
|
||||
;;
|
||||
ram|mem|kmem|null|boot|zero|imgrd)
|
||||
# Memory devices.
|
||||
makedev ram b 1 0 ${uname} kmem ${permissions}
|
||||
makedev mem c 1 1 ${uname} kmem 640
|
||||
makedev kmem c 1 2 ${uname} kmem 640
|
||||
makedev null c 1 3 ${uname} kmem 666
|
||||
makedev boot b 1 4 ${uname} kmem ${permissions}
|
||||
makedev zero c 1 5 ${uname} kmem 644
|
||||
makedev imgrd b 1 6 ${uname} kmem ${permissions}
|
||||
|
||||
for n in 0 1 2 3 4 5
|
||||
do
|
||||
minor=`expr ${n} + 7`
|
||||
|
||||
makedev ram${n} b 1 ${minor} ${uname} kmem ${permissions}
|
||||
done
|
||||
;;
|
||||
random|urandom)
|
||||
# Random data generator.
|
||||
makedev random c 16 0 ${uname} ${gname} 644
|
||||
makedev urandom c 16 0 ${uname} ${gname} 644
|
||||
;;
|
||||
sht21b[1-3]s40)
|
||||
# Weather Cape: relative humidity & temperature sensor
|
||||
bus=`expr ${dev} : 'sht21b\\(.*\\)s40'`
|
||||
major=`expr ${bus} + 49`
|
||||
|
||||
makedev sht21b${bus}s40 c ${major} 0 ${uname} ${gname} 444
|
||||
;;
|
||||
tsl2550b[1-3]s39)
|
||||
# Weather Cape: ambient light sensor
|
||||
bus=`expr ${dev} : 'tsl2550b\\(.*\\)s39'`
|
||||
major=`expr ${bus} + 46`
|
||||
|
||||
makedev tsl2550b${bus}s39 c ${major} 0 ${uname} ${gname} 444
|
||||
;;
|
||||
tty0[0-3])
|
||||
# Serial lines.
|
||||
line=`expr ${dev} : '.*\\(.\\)'`
|
||||
minor=`expr ${line} + 16`
|
||||
|
||||
makedev ${dev} c 4 ${minor} ${uname} tty 666
|
||||
;;
|
||||
tty[p-s][0-9a-f]|pty[p-s][0-9a-f])
|
||||
# Pseudo ttys.
|
||||
dev=`expr ${dev} : '...\\(..\\)'`
|
||||
group=`expr ${dev} : '\\(.\\)'`
|
||||
group=`echo ${group} | tr 'pqrs' '0123'`
|
||||
pty=`expr ${dev} : '.\\(.\\)'`
|
||||
case ${pty} in
|
||||
[a-f]) pty=1`/bin/echo ${pty} | tr 'abcdef' '012345'`
|
||||
esac
|
||||
minor_tty=`expr ${group} '*' 16 + ${pty} + 128`
|
||||
minor_pty=`expr ${group} '*' 16 + ${pty} + 192`
|
||||
|
||||
makedev tty${dev} c 4 ${minor_tty} ${uname} tty 666
|
||||
makedev pty${dev} c 4 ${minor_pty} ${uname} tty 666
|
||||
;;
|
||||
ttyc[1-7])
|
||||
# Virtual consoles.
|
||||
minor=`expr ${dev} : '....\\(.*\\)'`
|
||||
|
||||
makedev ${dev} c 4 ${minor} ${uname} tty ${permissions}
|
||||
;;
|
||||
uds)
|
||||
# Unix domain sockets device
|
||||
makedev ${dev} c 18 0 ${uname} ${gname} 666
|
||||
;;
|
||||
vnd[0-7])
|
||||
# Whole vnode disk devices.
|
||||
makedev ${dev} b ${major} 0 ${uname} ${gname} ${permissions}
|
||||
;;
|
||||
vnd[0-7]p[0-3])
|
||||
# Vnode disk primary partitions.
|
||||
prefix=`expr ${dev} : '\\(.*\\).'`
|
||||
disk=`expr ${dev} : '...\\(.\\)'`
|
||||
|
||||
for p in 0 1 2 3
|
||||
do
|
||||
minor=`expr 1 + ${p}`
|
||||
|
||||
makedev ${prefix}${p} b ${major} ${minor} \
|
||||
${uname} ${gname} ${permissions}
|
||||
done
|
||||
;;
|
||||
vnd[0-7]p[0-3]s[0-3])
|
||||
# Vnode disk subpartition.
|
||||
prefix=`expr ${dev} : '\\(.*\\)...'`
|
||||
disk=`expr ${dev} : '...\\(.\\)'`
|
||||
|
||||
for p in 0 1 2 3
|
||||
do
|
||||
for s in 0 1 2 3
|
||||
do
|
||||
minor=`expr 128 + ${p} '*' 4 + ${s}`
|
||||
|
||||
makedev ${prefix}${p}s${s} b ${major} ${minor} \
|
||||
${uname} ${gname} ${permissions}
|
||||
done
|
||||
done
|
||||
;;
|
||||
*)
|
||||
echo "$0: don't know about ${dev}" >&2
|
||||
EXIT=1
|
||||
esac
|
||||
done
|
||||
|
||||
exit $EXIT
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
SCRIPTS= MAKEDEV.sh
|
||||
MAN=
|
||||
MAN= MAKEDEV.8
|
||||
|
||||
.include <bsd.prog.mk>
|
||||
|
|
|
@ -196,8 +196,7 @@ MAKEDEV: ${.CURDIR}/MAKEDEV.awk ${.CURDIR}/MAKEDEV.tmpl \
|
|||
.else
|
||||
MAKEDEV:
|
||||
if [ ${MKUNPRIVED} != "yes" ]; then \
|
||||
cd ${DESTDIR}/dev && sh ${NETBSDSRCDIR}/commands/MAKEDEV/MAKEDEV.sh null ;\
|
||||
cd ${DESTDIR}/dev && sh ${NETBSDSRCDIR}/commands/MAKEDEV/MAKEDEV.sh std 2>/dev/null ;\
|
||||
cd ${DESTDIR}/dev && sh ${NETBSDSRCDIR}/commands/MAKEDEV/MAKEDEV.sh -s 2>/dev/null ;\
|
||||
fi
|
||||
.endif # !defined(__MINIX)
|
||||
|
||||
|
|
|
@ -1,53 +0,0 @@
|
|||
.TH MAKEDEV 8
|
||||
.SH NAME
|
||||
MAKEDEV, DESCRIBE \- make/describe device files
|
||||
.SH SYNOPSIS
|
||||
.B MAKEDEV
|
||||
.RB [ \-n ]
|
||||
.IR key " ..."
|
||||
.br
|
||||
.B DESCRIBE
|
||||
.RI [ device "] ..."
|
||||
.SH DESCRIPTION
|
||||
.B MAKEDEV
|
||||
may be used to create the device files normally found in the
|
||||
.B /dev
|
||||
directory. The
|
||||
.I key
|
||||
arguments are simply the names of the devices you want.
|
||||
.B MAKEDEV
|
||||
knows about all supported devices and will create them in the current
|
||||
directory with the proper owner and mode. For many devices
|
||||
.B MAKEDEV
|
||||
will not only create the device you want, but also the devices related
|
||||
to it that you will probably want too. Naming one floppy device will
|
||||
create all floppy devices for the same drive for instance.
|
||||
.PP
|
||||
Call
|
||||
.B MAKEDEV
|
||||
without arguments to see a list of keys that it understands. Then use
|
||||
the
|
||||
.B \-n
|
||||
flag to make the script echo the commands it will execute the next time
|
||||
when you call it without that flag.
|
||||
.PP
|
||||
The special key
|
||||
.B std
|
||||
must be given alone to
|
||||
.BR MAKEDEV .
|
||||
This key will create all standard devices.
|
||||
.PP
|
||||
The command
|
||||
.B DESCRIBE
|
||||
will give you a one-line description of a given device. It will by
|
||||
default list all devices in
|
||||
.BR /dev .
|
||||
.SH "SEE ALSO"
|
||||
.BR dev (4),
|
||||
.BR mknod (8).
|
||||
.SH BUGS
|
||||
.BR MAKEDEV "'s"
|
||||
eagerness to create devices may cause many "File exists" errors from
|
||||
.BR mknod .
|
||||
.SH AUTHOR
|
||||
Kees J. Bot (kjb@cs.vu.nl)
|
|
@ -2,7 +2,7 @@ MAN= add_route.8 backup.8 boot.8 btrace.8 \
|
|||
cdprobe.8 chown.8 cleantmp.8 config.8 cron.8 \
|
||||
dhcpd.8 diskctl.8 fbdctl.8 fdisk.8 \
|
||||
getty.8 halt.8 hgfs.8 httpd.8 ifconfig.8 inet.8 init.8 \
|
||||
intr.8 irdpd.8 loadramdisk.8 MAKEDEV.8 \
|
||||
intr.8 irdpd.8 loadramdisk.8 \
|
||||
netconf.8 newroot.8 nonamed.8 \
|
||||
ossdevlinks.8 part.8 partition.8 \
|
||||
poweroff.8 printroot.8 pr_routes.8 pwdauth.8 rarpd.8 \
|
||||
|
|
Loading…
Reference in a new issue