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.

266 lines
7.3 KiB

28 years ago
28 years ago
28 years ago
28 years ago
28 years ago
28 years ago
28 years ago
28 years ago
  1. #!/bin/sh -
  2. #
  3. # $OpenBSD: MAKEDEV,v 1.7 1996/09/18 22:03:45 deraadt Exp $
  4. #
  5. # Copyright (c) 1990 The Regents of the University of California.
  6. # All rights reserved.
  7. #
  8. # Written and contributed by W. Jolitz 12/90
  9. #
  10. # Redistribution and use in source and binary forms are permitted provided
  11. # that: (1) source distributions retain this entire copyright notice and
  12. # comment, and (2) distributions including binaries display the following
  13. # acknowledgement: ``This product includes software developed by the
  14. # University of California, Berkeley and its contributors'' in the
  15. # documentation or other materials provided with the distribution and in
  16. # all advertising materials mentioning features or use of this software.
  17. # Neither the name of the University nor the names of its contributors may
  18. # be used to endorse or promote products derived from this software without
  19. # specific prior written permission.
  20. # THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
  21. # WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
  22. # MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  23. #
  24. # @(#)MAKEDEV 5.2 (Berkeley) 6/22/90
  25. #
  26. # Device "make" file. Valid arguments:
  27. # all makes all known devices, including local devices.
  28. # Tries to make the 'standard' number of each type.
  29. # floppy devices to be put on install floppies
  30. # std standard devices
  31. # local configuration specific devices
  32. #
  33. # Tapes:
  34. # st* SCSI tapes
  35. #
  36. # Disks:
  37. # sd* SCSI disks
  38. # cd* SCSI CD-ROM
  39. # vnd* "file" pseudo-disks
  40. # ccd* concatenated disk driver
  41. #
  42. # Terminal ports:
  43. # tty* rs232 devices
  44. #
  45. # Pseudo terminals:
  46. # pty* set of 16 master and slave pseudo terminals
  47. #
  48. # Printers:
  49. # lpt* Matthias's lp interface
  50. #
  51. # Special purpose devices:
  52. # fd file descriptors
  53. # bpf* packet filter
  54. # lkm loadable kernel modules interface
  55. # tun* network tunnel driver
  56. # *random random data source
  57. #
  58. PATH=/sbin:/usr/sbin:/bin:/usr/bin
  59. umask 77
  60. for i
  61. do
  62. case $i in
  63. all)
  64. sh MAKEDEV std fd sd0 sd1 sd2 st0 st1 cd0 cd1
  65. sh MAKEDEV tty0 tty1 tty2 tty3 tty4 tty5 tty6 tty7
  66. sh MAKEDEV pty0 pty1 vnd0 vnd1 bpf0 bpf1 bpf2 bpf3 ipl
  67. sh MAKEDEV tun0 tun1 tun2 lkm random
  68. sh MAKEDEV ccd0 ccd1 ccd2 ccd3
  69. ;;
  70. floppy)
  71. sh MAKEDEV std sd0 sd1 sd2 tty0 tty1 tty2 tty3
  72. sh MAKEDEV st0 st1 cd0 cd1 rd0
  73. ;;
  74. std)
  75. rm -f console drum mem kmem null zero io tty klog stdin stdout stderr
  76. mknod console c 0 0
  77. mknod drum c 4 0 ; chmod 640 drum ; chown root.kmem drum
  78. mknod kmem c 2 1 ; chmod 640 kmem ; chown root.kmem kmem
  79. mknod mem c 2 0 ; chmod 640 mem ; chown root.kmem mem
  80. mknod null c 2 2 ; chmod 666 null
  81. mknod zero c 2 12 ; chmod 666 zero
  82. mknod tty c 1 0 ; chmod 666 tty
  83. mknod klog c 7 0 ; chmod 600 klog
  84. mknod stdin c 11 0 ; chmod 666 stdin
  85. mknod stdout c 11 1 ; chmod 666 stdout
  86. mknod stderr c 11 2 ; chmod 666 stderr
  87. ;;
  88. fd)
  89. rm -f fd/*
  90. mkdir fd > /dev/null 2>&1
  91. (cd fd && eval `echo "" | awk ' BEGIN { \
  92. for (i = 0; i < 64; i++) \
  93. printf("mknod %d c 11 %d;", i, i)}'`)
  94. chown -R bin.bin fd
  95. chmod 555 fd
  96. chmod 666 fd/*
  97. ;;
  98. rd*)
  99. umask 2 ; unit=`expr $i : '.*d\(.*\)'`
  100. mknod rd${unit} b 3 $unit
  101. mknod rrd${unit} c 9 $unit
  102. chown root.operator rd${unit} rrd${unit}
  103. chmod 640 rd${unit} rrd${unit}
  104. umask 77
  105. ;;
  106. sd*|vnd*|ccd*)
  107. umask 2 ; unit=`expr $i : '.*d\(.*\)'`
  108. case $i in
  109. sd*) name=sd; blk=0; chr=3;;
  110. vnd*) name=vnd; blk=5; chr=13;;
  111. ccd*) name=ccd; blk=6; chr=18;;
  112. esac
  113. rm -f $name$unit? r$name$unit?
  114. mknod ${name}${unit}a b $blk `expr $unit '*' 8 + 0`
  115. mknod ${name}${unit}b b $blk `expr $unit '*' 8 + 1`
  116. mknod ${name}${unit}c b $blk `expr $unit '*' 8 + 2`
  117. mknod ${name}${unit}d b $blk `expr $unit '*' 8 + 3`
  118. mknod ${name}${unit}e b $blk `expr $unit '*' 8 + 4`
  119. mknod ${name}${unit}f b $blk `expr $unit '*' 8 + 5`
  120. mknod ${name}${unit}g b $blk `expr $unit '*' 8 + 6`
  121. mknod ${name}${unit}h b $blk `expr $unit '*' 8 + 7`
  122. mknod r${name}${unit}a c $chr `expr $unit '*' 8 + 0`
  123. mknod r${name}${unit}b c $chr `expr $unit '*' 8 + 1`
  124. mknod r${name}${unit}c c $chr `expr $unit '*' 8 + 2`
  125. mknod r${name}${unit}d c $chr `expr $unit '*' 8 + 3`
  126. mknod r${name}${unit}e c $chr `expr $unit '*' 8 + 4`
  127. mknod r${name}${unit}f c $chr `expr $unit '*' 8 + 5`
  128. mknod r${name}${unit}g c $chr `expr $unit '*' 8 + 6`
  129. mknod r${name}${unit}h c $chr `expr $unit '*' 8 + 7`
  130. chown root.operator ${name}${unit}[a-h] r${name}${unit}[a-h]
  131. chmod 640 ${name}${unit}[a-h] r${name}${unit}[a-h]
  132. umask 77
  133. ;;
  134. tty*)
  135. unit=`expr $i : '...\(.*\)'`
  136. mknod tty0$unit c 8 $unit
  137. chown uucp.wheel tty0$unit
  138. ;;
  139. pty*)
  140. class=`expr $i : 'pty\(.*\)'`
  141. case $class in
  142. 0) offset=0 name=p;;
  143. 1) offset=16 name=q;;
  144. 2) offset=32 name=r;;
  145. 3) offset=48 name=s;;
  146. # Note that telnetd, rlogind, and xterm (at least) only look at p-s.
  147. 4) offset=64 name=t;;
  148. *) echo bad unit for pty in: $i;;
  149. esac
  150. case $class in
  151. 0|1|2|3|4)
  152. umask 0
  153. eval `echo $offset $name | awk ' { b=$1; n=$2 } END {
  154. for (i = 0; i < 16; i++)
  155. printf("rm -f tty%s%x; mknod tty%s%x c 5 %d;" \
  156. "rm -f pty%s%x; mknod pty%s%x c 6 %d; ", \
  157. n, i, n, i, b+i, n, i, n, i, b+i); }'`
  158. umask 77
  159. ;;
  160. esac
  161. ;;
  162. st*)
  163. umask 2 ; unit=`expr $i : '..\(.*\)'`
  164. case $i in
  165. st*) name=st; chr=10; blk=2;;
  166. esac
  167. rm -f $name$unit n$name$unit e$name$unit en$name$unit \
  168. r$name$unit nr$name$unit er$name$unit enr$name$unit
  169. mknod ${name}${unit} b $blk `expr $unit '*' 16 + 0`
  170. mknod n${name}${unit} b $blk `expr $unit '*' 16 + 1`
  171. mknod e${name}${unit} b $blk `expr $unit '*' 16 + 2`
  172. mknod en${name}${unit} b $blk `expr $unit '*' 16 + 3`
  173. mknod r${name}${unit} c $chr `expr $unit '*' 16 + 0`
  174. mknod nr${name}${unit} c $chr `expr $unit '*' 16 + 1`
  175. mknod er${name}${unit} c $chr `expr $unit '*' 16 + 2`
  176. mknod enr${name}${unit} c $chr `expr $unit '*' 16 + 3`
  177. chown root.operator ${name}${unit} n${name}${unit} \
  178. e$name$unit en$name$unit \
  179. r${name}${unit} nr${name}${unit} \
  180. er${name}${unit} enr${name}${unit}
  181. chmod 640 ${name}${unit} n${name}${unit} \
  182. e$name$unit en$name$unit \
  183. r${name}${unit} nr${name}${unit} \
  184. er${name}${unit} enr${name}${unit}
  185. umask 77
  186. ;;
  187. cd*)
  188. umask 2 ; unit=`expr $i : '.*cd\(.*\)'`
  189. case $i in
  190. cd*) name=cd; blk=4; chr=12;;
  191. esac
  192. rm -f $name$unit? r$name$unit?
  193. mknod ${name}${unit}a b $blk `expr $unit '*' 8 + 0`
  194. mknod ${name}${unit}d b $blk `expr $unit '*' 8 + 3`
  195. mknod r${name}${unit}a c $chr `expr $unit '*' 8 + 0`
  196. mknod r${name}${unit}d c $chr `expr $unit '*' 8 + 3`
  197. chown root.operator ${name}${unit}[a-h] r${name}${unit}[a-h]
  198. chmod 640 ${name}${unit}[a-h] r${name}${unit}[a-h]
  199. umask 77
  200. ;;
  201. lpt*)
  202. unit=`expr $i : 'lpt\(.*\)'`
  203. rm -f lpt${unit} lpt${unit}p
  204. mknod lpt${unit} c 17 `expr $unit + 64`
  205. mknod lpt${unit}p c 17 $unit
  206. chmod 0220 lpt${unit} lpt${unit}p
  207. chown root.wheel lpt$unit
  208. ;;
  209. bpf*)
  210. unit=`expr $i : 'bpf\(.*\)'`
  211. rm -f bpf$unit
  212. mknod bpf$unit c 14 $unit
  213. chown root.wheel bpf$unit
  214. ;;
  215. ipl)
  216. mknod ipl c 19 0
  217. chown root.wheel ipl
  218. ;;
  219. tun*)
  220. unit=`expr $i : 'tun\(.*\)'`
  221. rm -f tun$unit
  222. mknod tun$unit c 15 $unit
  223. chmod 600 tun$unit
  224. chown root.wheel tun$unit
  225. ;;
  226. lkm)
  227. rm -f lkm
  228. mknod lkm c 18 0
  229. chown root.kmem lkm
  230. chmod 640 lkm
  231. ;;
  232. random|srandom|urandom|prandom|arandom)
  233. rm -f random urandom srandom prandom arandom
  234. mknod random c 20 0
  235. mknod srandom c 20 1
  236. mknod urandom c 20 2
  237. mknod prandom c 20 3
  238. mknod arandom c 20 4
  239. chown root.wheel random srandom urandom prandom arandom
  240. chmod 644 random srandom urandom prandom arandom
  241. ;;
  242. local)
  243. umask 0
  244. sh MAKEDEV.local
  245. ;;
  246. esac
  247. done