xref: /original-bsd/etc/etc.i386/MAKEDEV (revision 6a39c8ab)
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.2 (Berkeley) 10/07/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 zero      	c 2 12  ; chmod 666 zero
49	mknod tty		c 1 0	; chmod 666 tty
50	mknod klog		c 7 0	; chmod 600 klog
51	mknod stdin		c 53 0	; chmod 666 stdin
52	mknod stdout		c 53 1	; chmod 666 stdout
53	mknod stderr		c 53 2	; chmod 666 stderr
54	mkdir fd > /dev/null 2>&1
55	(cd fd && eval `echo "" | awk ' BEGIN { \
56		for (i = 0; i < 64; i++) \
57			printf("mknod %d c 53 %d;", i, i)}'`)
58	chown -R bin.bin fd
59	chmod 555 fd
60	chmod 666 fd/*
61	;;
62
63wt*)
64	umask 0 ; unit=`expr $i : '..\(.*\)'`
65	case $i in
66	wt*) blk=3; chr=10;;
67	esac
68	case $unit in
69	0)
70		four=`expr $unit + 4` ; eight=`expr $unit + 8`
71		twelve=`expr $unit + 12`; twenty=`expr $unit + 20`
72		#
73		# block devices don't work so don't make them
74		#mknod wt$unit	b $blk $unit
75		#mknod wt$four	b $blk $four
76		#mknod wt$eight	b $blk $eight
77		#mknod wt$twelve	b $blk $twelve
78		#mknod nwt$unit	b $blk $four ;: sanity w/pdp11 v7
79		#mknod nwt$eight	b $blk $twelve ;: ditto
80		#
81		mknod rwt$unit	c $chr $unit
82		mknod rwt$four	c $chr $four
83		mknod rwt$eight	c $chr $eight
84		mknod rwt$twelve	c $chr $twelve
85		ln rwt$four nrwt$unit ;: sanity w/pdp11 v7
86		ln rwt$twelve nrwt$eight ;: ditto
87		;;
88	*)
89		echo bad unit for tape in: $1
90		;;
91	esac
92	umask 77
93	;;
94
95fd*|wd*)
96	umask 2 ; unit=`expr $i : '..\(.*\)'`
97	case $i in
98	fd*) name=fd; blk=2; chr=9;;
99	wd*) name=wd; blk=0; chr=3;;
100	esac
101	case $unit in
102	0|1)
103		mknod ${name}${unit}a	b $blk `expr $unit '*' 8 + 0`
104		mknod ${name}${unit}b	b $blk `expr $unit '*' 8 + 1`
105		mknod ${name}${unit}c	b $blk `expr $unit '*' 8 + 2`
106		mknod ${name}${unit}d	b $blk `expr $unit '*' 8 + 3`
107		mknod ${name}${unit}e	b $blk `expr $unit '*' 8 + 4`
108		mknod ${name}${unit}f	b $blk `expr $unit '*' 8 + 5`
109		mknod ${name}${unit}g	b $blk `expr $unit '*' 8 + 6`
110		mknod ${name}${unit}h	b $blk `expr $unit '*' 8 + 7`
111		mknod r${name}${unit}a	c $chr `expr $unit '*' 8 + 0`
112		mknod r${name}${unit}b	c $chr `expr $unit '*' 8 + 1`
113		mknod r${name}${unit}c	c $chr `expr $unit '*' 8 + 2`
114		mknod r${name}${unit}d	c $chr `expr $unit '*' 8 + 3`
115		mknod r${name}${unit}e	c $chr `expr $unit '*' 8 + 4`
116		mknod r${name}${unit}f	c $chr `expr $unit '*' 8 + 5`
117		mknod r${name}${unit}g	c $chr `expr $unit '*' 8 + 6`
118		mknod r${name}${unit}h	c $chr `expr $unit '*' 8 + 7`
119		chgrp operator ${name}${unit}[a-h] r${name}${unit}[a-h]
120		chmod 640 ${name}${unit}[a-h] r${name}${unit}[a-h]
121		;;
122	*)
123		echo bad unit for disk in: $i
124		;;
125	esac
126	umask 77
127	;;
128
129com*)
130	unit=`expr $i : 'dca\(.*\)'`
131	case $unit in
132	1)
133		mknod com1 c 8 0
134		;;
135	2)
136		mknod com1 c 8 1
137		;;
138	*)
139		echo bad unit for com in: $i
140		;;
141	esac
142	;;
143
144pty*)
145	class=`expr $i : 'pty\(.*\)'`
146	case $class in
147	0) offset=0 name=p;;
148	1) offset=16 name=q;;
149	2) offset=32 name=r;;
150	3) offset=48 name=s;;
151# Note that telnetd, rlogind, and xterm (at least) only look at p-s.
152	4) offset=64 name=t;;
153	*) echo bad unit for pty in: $i;;
154	esac
155	case $class in
156	0|1|2|3|4)
157		umask 0
158		eval `echo $offset $name | awk ' { b=$1; n=$2 } END {
159			for (i = 0; i < 16; i++)
160				printf("mknod tty%s%x c 4 %d; \
161					mknod pty%s%x c 5 %d; ", \
162					n, i, b+i, n, i, b+i); }'`
163		umask 77
164		if [ $class = 1 ]; then
165			mv ttyqf ttyv0; mv ptyqf ptyv0
166		fi
167		;;
168	esac
169	;;
170
171local)
172	umask 0
173	sh MAKEDEV.local
174	;;
175
176esac
177done
178