Source code pulled from OpenBSD for OpenNTPD. The place to contribute to this code is via the OpenBSD CVS tree.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

305 lines
8.3 KiB

28 years ago
28 years ago
28 years ago
28 years ago
28 years ago
28 years ago
  1. #!/bin/sh -
  2. # $OpenBSD: MAKEDEV,v 1.7 1996/07/23 06:15:13 etheisen Exp $
  3. # $NetBSD: MAKEDEV,v 1.8.4.1 1996/06/18 00:41:56 cgd Exp $
  4. #
  5. # Copyright (c) 1990 The Regents of the University of California.
  6. # All rights reserved.
  7. #
  8. # Redistribution and use in source and binary forms, with or without
  9. # modification, are permitted provided that the following conditions
  10. # are met:
  11. # 1. Redistributions of source code must retain the above copyright
  12. # notice, this list of conditions and the following disclaimer.
  13. # 2. Redistributions in binary form must reproduce the above copyright
  14. # notice, this list of conditions and the following disclaimer in the
  15. # documentation and/or other materials provided with the distribution.
  16. # 3. All advertising materials mentioning features or use of this software
  17. # must display the following acknowledgement:
  18. # This product includes software developed by the University of
  19. # California, Berkeley and its contributors.
  20. # 4. Neither the name of the University nor the names of its contributors
  21. # may be used to endorse or promote products derived from this software
  22. # without specific prior written permission.
  23. #
  24. # THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  25. # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  26. # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  27. # ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  28. # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  29. # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  30. # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  31. # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  32. # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  33. # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  34. # SUCH DAMAGE.
  35. #
  36. # Device "make" file. Valid arguments:
  37. # all makes all known devices, including local devices.
  38. # Tries to make the 'standard' number of each type.
  39. # std standard devices
  40. # local configuration specific devices
  41. #
  42. # Tapes:
  43. # st* SCSI tape
  44. #
  45. # Disks:
  46. # sd* SCSI disks
  47. # cd* SCSI CD-ROM
  48. # vnd* "file" pseudo-disks
  49. # ccd* concatenated disk driver
  50. #
  51. # Terminals:
  52. # ttyB? DEC 3000 ZS8530 ("scc") serial ports
  53. # ttyC? AlphaStation NS16550 ("com") serial ports
  54. # ttyE? Workstation console (framebuffer & keyboard) tty emulators
  55. #
  56. # Pseudo terminals:
  57. # pty* set of 16 master and slave pseudo terminals
  58. #
  59. # Printers:
  60. # lpt* stock lp
  61. # lpa* interruptless lp
  62. #
  63. # Special purpose devices:
  64. # ch* SCSI media changer
  65. # bpf* packet filter
  66. # fd file descriptors
  67. # lkm loadable kernel modules interface
  68. # tun* network tunnel driver
  69. # mmclock memory mapped clock
  70. # kbd keyboard (provides events, for X11)
  71. # mouse mouse (provides events, for X11)
  72. # *rnd inkernel random number generator
  73. # uk* unknown SCSI
  74. PATH=/sbin:/usr/sbin:/bin:/usr/bin
  75. umask 77
  76. for i
  77. do
  78. case $i in
  79. all)
  80. sh MAKEDEV std fd sd0 sd1 sd2 sd3 sd4 pty0 pty1
  81. sh MAKEDEV st0 st1 ch0 cd0 cd1 vnd0 vnd1 vnd2 vnd3
  82. sh MAKEDEV ccd0 ccd1 ccd2 ccd3
  83. sh MAKEDEV bpf0 bpf1 bpf2 bpf3 tun0 tun1 tun2 tun3
  84. sh MAKEDEV ttyB0 ttyB1 ttyC0 ttyC1 ttyE0 ttyE1 lkm
  85. sh MAKEDEV mmclock kbd mouse lpa0 lpt0 rnd
  86. sh MAKEDEV local
  87. ;;
  88. std)
  89. rm -f console drum mem kmem null zero io tty klog stdin stdout stderr
  90. mknod console c 0 0
  91. mknod drum c 3 0 ; chmod 640 drum ; chgrp kmem drum
  92. mknod kmem c 2 1 ; chmod 640 kmem ; chgrp kmem kmem
  93. mknod mem c 2 0 ; chmod 640 mem ; chgrp kmem mem
  94. mknod null c 2 2 ; chmod 666 null
  95. mknod zero c 2 12 ; chmod 666 zero
  96. mknod tty c 1 0 ; chmod 666 tty
  97. mknod klog c 6 0 ; chmod 600 klog
  98. mknod stdin c 10 0 ; chmod 666 stdin
  99. mknod stdout c 10 1 ; chmod 666 stdout
  100. mknod stderr c 10 2 ; chmod 666 stderr
  101. ;;
  102. fd)
  103. rm -f fd/*
  104. mkdir fd > /dev/null 2>&1
  105. (cd fd && eval `echo "" | awk ' BEGIN { \
  106. for (i = 0; i < 64; i++) \
  107. printf("mknod %d c 10 %d;", i, i)}'`)
  108. chown -R bin.bin fd
  109. chmod 555 fd
  110. chmod 666 fd/*
  111. ;;
  112. cd*|sd*|vnd*|ccd*)
  113. umask 2 ; unit=`expr $i : '.*d\(.*\)'`
  114. case $i in
  115. cd*) name=cd; blk=3; chr=13;;
  116. sd*) name=sd; blk=8; chr=8;;
  117. vnd*) name=vnd; blk=9; chr=9;;
  118. ccd*) name=ccd; blk=7; chr=27;;
  119. esac
  120. rm -f $name$unit? r$name$unit?
  121. mknod ${name}${unit}a b $blk `expr $unit '*' 8 + 0`
  122. mknod ${name}${unit}b b $blk `expr $unit '*' 8 + 1`
  123. mknod ${name}${unit}c b $blk `expr $unit '*' 8 + 2`
  124. mknod ${name}${unit}d b $blk `expr $unit '*' 8 + 3`
  125. mknod ${name}${unit}e b $blk `expr $unit '*' 8 + 4`
  126. mknod ${name}${unit}f b $blk `expr $unit '*' 8 + 5`
  127. mknod ${name}${unit}g b $blk `expr $unit '*' 8 + 6`
  128. mknod ${name}${unit}h b $blk `expr $unit '*' 8 + 7`
  129. mknod r${name}${unit}a c $chr `expr $unit '*' 8 + 0`
  130. mknod r${name}${unit}b c $chr `expr $unit '*' 8 + 1`
  131. mknod r${name}${unit}c c $chr `expr $unit '*' 8 + 2`
  132. mknod r${name}${unit}d c $chr `expr $unit '*' 8 + 3`
  133. mknod r${name}${unit}e c $chr `expr $unit '*' 8 + 4`
  134. mknod r${name}${unit}f c $chr `expr $unit '*' 8 + 5`
  135. mknod r${name}${unit}g c $chr `expr $unit '*' 8 + 6`
  136. mknod r${name}${unit}h c $chr `expr $unit '*' 8 + 7`
  137. chgrp operator ${name}${unit}[a-h] r${name}${unit}[a-h]
  138. chmod 640 ${name}${unit}[a-h] r${name}${unit}[a-h]
  139. umask 77
  140. ;;
  141. ttyB*|ttyC*|ttyE*)
  142. type=`expr $i : 'tty\(.\).'`
  143. unit=`expr $i : 'tty.\(.\)'`
  144. case $type in
  145. B) major=15; minor=`expr $unit \* 2` ;;
  146. C) major=26; minor=$unit ;;
  147. E) major=25; minor=$unit ;;
  148. esac
  149. rm -f tty$type$unit
  150. mknod tty$type$unit c $major $minor
  151. chown uucp.wheel tty$type$unit
  152. ;;
  153. pty*)
  154. class=`expr $i : 'pty\(.*\)'`
  155. case $class in
  156. 0) offset=0 name=p;;
  157. 1) offset=16 name=q;;
  158. 2) offset=32 name=r;;
  159. 3) offset=48 name=s;;
  160. # Note that telnetd, rlogind, and xterm (at least) only look at p-s.
  161. 4) offset=64 name=t;;
  162. *) echo bad unit for pty in: $i;;
  163. esac
  164. case $class in
  165. 0|1|2|3|4)
  166. umask 0
  167. eval `echo $offset $name | awk ' { b=$1; n=$2 } END {
  168. for (i = 0; i < 16; i++)
  169. printf("rm -f tty%s%x; mknod tty%s%x c 4 %d;" \
  170. "rm -f pty%s%x; mknod pty%s%x c 5 %d; ", \
  171. n, i, n, i, b+i, n, i, n, i, b+i); }'`
  172. umask 77
  173. if [ $class = 1 ]; then
  174. mv ttyqf ttyv0; mv ptyqf ptyv0
  175. fi
  176. ;;
  177. esac
  178. ;;
  179. st*)
  180. umask 2 ; unit=`expr $i : '..\(.*\)'`
  181. case $i in
  182. st*) name=st; blk=2; chr=12;;
  183. esac
  184. rm -f $name$unit n$name$unit e$name$unit en$name$unit \
  185. r$name$unit nr$name$unit er$name$unit enr$name$unit
  186. mknod ${name}${unit} b $blk `expr $unit '*' 16 + 0`
  187. mknod n${name}${unit} b $blk `expr $unit '*' 16 + 1`
  188. mknod e${name}${unit} b $blk `expr $unit '*' 16 + 2`
  189. mknod en${name}${unit} b $blk `expr $unit '*' 16 + 3`
  190. mknod r${name}${unit} c $chr `expr $unit '*' 16 + 0`
  191. mknod nr${name}${unit} c $chr `expr $unit '*' 16 + 1`
  192. mknod er${name}${unit} c $chr `expr $unit '*' 16 + 2`
  193. mknod enr${name}${unit} c $chr `expr $unit '*' 16 + 3`
  194. chgrp operator ${name}${unit} n${name}${unit} \
  195. e$name$unit en$name$unit \
  196. r${name}${unit} nr${name}${unit} \
  197. er${name}${unit} enr${name}${unit}
  198. chmod 640 ${name}${unit} n${name}${unit} \
  199. e$name$unit en$name$unit \
  200. r${name}${unit} nr${name}${unit} \
  201. er${name}${unit} enr${name}${unit}
  202. umask 77
  203. ;;
  204. ch*)
  205. umask 2 ; unit=`expr $i : '..\(.*\)'`
  206. case $i in
  207. ch*) name=ch; chr=14;;
  208. esac
  209. rm -f $name$unit
  210. mknod ${name}${unit} c $chr `expr $unit '*' 16 + 0`
  211. chgrp operator ${name}${unit}
  212. chmod 640 ${name}${unit}
  213. umask 77
  214. ;;
  215. bpf*)
  216. unit=`expr $i : 'bpf\(.*\)'`
  217. rm -f bpf$unit
  218. mknod bpf$unit c 11 $unit
  219. chmod 600 bpf$unit
  220. chown root.wheel bpf$unit
  221. ;;
  222. tun*)
  223. unit=`expr $i : 'tun\(.*\)'`
  224. rm -f tun$unit
  225. mknod tun$unit c 7 $unit
  226. chmod 600 tun$unit
  227. chown root.wheel tun$unit
  228. ;;
  229. lkm)
  230. rm -f lkm
  231. mknod lkm c 16 0
  232. chown root.kmem lkm
  233. chmod 640 lkm
  234. ;;
  235. mmclock)
  236. rm -f mmclock
  237. mknod mmclock c 28 0
  238. chmod 444 mmclock
  239. ;;
  240. kbd)
  241. rm -f kbd
  242. mknod kbd c 29 0
  243. chmod 666 kbd
  244. ;;
  245. mouse)
  246. rm -f mouse
  247. mknod mouse c 30 0
  248. chmod 666 mouse
  249. ;;
  250. lpt*|lpa*)
  251. unit=`expr $i : '...\(.*\)'`
  252. case $i in
  253. lpt*) name=lpt; flags=0;;
  254. lpa*) name=lpa; flags=128;;
  255. esac
  256. rm -f $name$unit
  257. mknod $name$unit c 31 `expr $unit + $flags`
  258. chown root.wheel $name$unit
  259. ;;
  260. rnd|srnd|urnd|prnd)
  261. rm -f rnd urnd srnd prnd
  262. mknod rnd c 33 0
  263. mknod srnd c 33 1
  264. mknod urnd c 33 2
  265. mknod prnd c 33 3
  266. chown root.wheel rnd srnd urnd prnd
  267. chmod 644 rnd srnd urnd prnd
  268. ;;
  269. uk*)
  270. unit=`expr $i : 'uk\(.*\)'`
  271. rm -f uk$unit
  272. mknod uk$unit c 32 $unit
  273. chown root.operator uk$unit
  274. chmod 640 uk$unit
  275. ;;
  276. local)
  277. umask 0
  278. sh MAKEDEV.local
  279. ;;
  280. *)
  281. echo $i: unknown device
  282. ;;
  283. esac
  284. done