xref: /original-bsd/etc/etc.i386/MAKEDEV (revision 93ab02a6)
1#!/bin/sh -
2#
3# Copyright (c) 1991 The Regents of the University of California.
4# All rights reserved.
5#
6# %sccs.include.redist.sh%
7#
8#	@(#)MAKEDEV	5.1 (Berkeley) 03/22/91
9#
10
11# Device "make" file.  Valid arguments:
12#	std	standard devices
13#	local	configuration specific devices
14#
15# Tapes:
16#	wt*	QIC-interfaced (e.g. not SCSI) 3M cartridge tape
17#
18# Disks:
19#	wd*	"winchester" disk drives (ST506,IDE,ESDI,RLL,...)
20#	fd*	"floppy" disk drives (3 1/2", 5 1/4")
21#
22# Terminal ports:
23#	com*	standard PC COM ports
24#
25# Pseudo terminals:
26#	pty*	set of 16 master and slave pseudo terminals
27#
28# Printers:
29#
30# Call units:
31#
32# Special purpose devices:
33#	flog*	kernel logging device
34#
35
36PATH=/sbin:/bin/:/usr/bin
37umask 77
38for i
39do
40case $i in
41
42std)
43	mknod console		c 0 0
44	mknod drum		c 4 0	; chmod 640 drum ; chgrp kmem drum
45	mknod kmem		c 2 1	; chmod 640 kmem ; chgrp kmem kmem
46	mknod mem		c 2 0	; chmod 640 mem ; chgrp kmem mem
47	mknod null		c 2 2	; chmod 666 null
48	mknod tty		c 1 0	; chmod 666 tty
49	mknod klog		c 7 0	; chmod 600 klog
50	mknod stdin		c 53 0	; chmod 666 stdin
51	mknod stdout		c 53 1	; chmod 666 stdout
52	mknod stderr		c 53 2	; chmod 666 stderr
53	mkdir fd > /dev/null 2>&1
54	(cd fd && eval `echo "" | awk ' BEGIN { \
55		for (i = 0; i < 64; i++) \
56			printf("mknod %d c 53 %d;", i, i)}'`)
57	chown -R bin.bin fd
58	chmod 555 fd
59	chmod 666 fd/*
60	;;
61
62wt*)
63	umask 0 ; unit=`expr $i : '..\(.*\)'`
64	case $i in
65	wt*) blk=3; chr=10;;
66	esac
67	case $unit in
68	0)
69		four=`expr $unit + 4` ; eight=`expr $unit + 8`
70		twelve=`expr $unit + 12`; twenty=`expr $unit + 20`
71		#
72		# block devices don't work so don't make them
73		#mknod wt$unit	b $blk $unit
74		#mknod wt$four	b $blk $four
75		#mknod wt$eight	b $blk $eight
76		#mknod wt$twelve	b $blk $twelve
77		#mknod nwt$unit	b $blk $four ;: sanity w/pdp11 v7
78		#mknod nwt$eight	b $blk $twelve ;: ditto
79		#
80		mknod rwt$unit	c $chr $unit
81		mknod rwt$four	c $chr $four
82		mknod rwt$eight	c $chr $eight
83		mknod rwt$twelve	c $chr $twelve
84		ln rwt$four nrwt$unit ;: sanity w/pdp11 v7
85		ln rwt$twelve nrwt$eight ;: ditto
86		;;
87	*)
88		echo bad unit for tape in: $1
89		;;
90	esac
91	umask 77
92	;;
93
94fd*|wd*)
95	umask 2 ; unit=`expr $i : '..\(.*\)'`
96	case $i in
97	fd*) name=fd; blk=2; chr=9;;
98	wd*) name=wd; blk=0; chr=3;;
99	esac
100	case $unit in
101	0|1)
102		mknod ${name}${unit}a	b $blk `expr $unit '*' 8 + 0`
103		mknod ${name}${unit}b	b $blk `expr $unit '*' 8 + 1`
104		mknod ${name}${unit}c	b $blk `expr $unit '*' 8 + 2`
105		mknod ${name}${unit}d	b $blk `expr $unit '*' 8 + 3`
106		mknod ${name}${unit}e	b $blk `expr $unit '*' 8 + 4`
107		mknod ${name}${unit}f	b $blk `expr $unit '*' 8 + 5`
108		mknod ${name}${unit}g	b $blk `expr $unit '*' 8 + 6`
109		mknod ${name}${unit}h	b $blk `expr $unit '*' 8 + 7`
110		mknod r${name}${unit}a	c $chr `expr $unit '*' 8 + 0`
111		mknod r${name}${unit}b	c $chr `expr $unit '*' 8 + 1`
112		mknod r${name}${unit}c	c $chr `expr $unit '*' 8 + 2`
113		mknod r${name}${unit}d	c $chr `expr $unit '*' 8 + 3`
114		mknod r${name}${unit}e	c $chr `expr $unit '*' 8 + 4`
115		mknod r${name}${unit}f	c $chr `expr $unit '*' 8 + 5`
116		mknod r${name}${unit}g	c $chr `expr $unit '*' 8 + 6`
117		mknod r${name}${unit}h	c $chr `expr $unit '*' 8 + 7`
118		chgrp operator ${name}${unit}[a-h] r${name}${unit}[a-h]
119		chmod 640 ${name}${unit}[a-h] r${name}${unit}[a-h]
120		;;
121	*)
122		echo bad unit for disk in: $i
123		;;
124	esac
125	umask 77
126	;;
127
128com*)
129	unit=`expr $i : 'dca\(.*\)'`
130	case $unit in
131	1)
132		mknod com1 c 8 0
133		;;
134	2)
135		mknod com1 c 8 1
136		;;
137	*)
138		echo bad unit for com in: $i
139		;;
140	esac
141	;;
142
143pty*)
144	class=`expr $i : 'pty\(.*\)'`
145	case $class in
146	0) offset=0 name=p;;
147	1) offset=16 name=q;;
148	2) offset=32 name=r;;
149	3) offset=48 name=s;;
150# Note that telnetd, rlogind, and xterm (at least) only look at p-s.
151	4) offset=64 name=t;;
152	*) echo bad unit for pty in: $i;;
153	esac
154	case $class in
155	0|1|2|3|4)
156		umask 0
157		eval `echo $offset $name | awk ' { b=$1; n=$2 } END {
158			for (i = 0; i < 16; i++)
159				printf("mknod tty%s%x c 4 %d; \
160					mknod pty%s%x c 5 %d; ", \
161					n, i, b+i, n, i, b+i); }'`
162		umask 77
163		if [ $class = 1 ]; then
164			mv ttyqf ttyv0; mv ptyqf ptyv0
165		fi
166		;;
167	esac
168	;;
169
170local)
171	umask 0
172	sh MAKEDEV.local
173	;;
174
175esac
176done
177