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.

341 lines
9.4 KiB

  1. #!/bin/sh -
  2. #
  3. # Copyright (c) 1990 The Regents of the University of California.
  4. # All rights reserved.
  5. #
  6. # Redistribution and use in source and binary forms, with or without
  7. # modification, are permitted provided that the following conditions
  8. # are met:
  9. # 1. Redistributions of source code must retain the above copyright
  10. # notice, this list of conditions and the following disclaimer.
  11. # 2. Redistributions in binary form must reproduce the above copyright
  12. # notice, this list of conditions and the following disclaimer in the
  13. # documentation and/or other materials provided with the distribution.
  14. # 3. All advertising materials mentioning features or use of this software
  15. # must display the following acknowledgement:
  16. # This product includes software developed by the University of
  17. # California, Berkeley and its contributors.
  18. # 4. Neither the name of the University nor the names of its contributors
  19. # may be used to endorse or promote products derived from this software
  20. # without specific prior written permission.
  21. #
  22. # THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  23. # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  24. # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  25. # ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  26. # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  27. # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  28. # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  29. # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  30. # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  31. # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  32. # SUCH DAMAGE.
  33. #
  34. # $Id: MAKEDEV,v 1.1 1995/10/24 14:43:20 deraadt Exp $
  35. #
  36. # from:
  37. # hp300/MAKEDEV (1/15/94), from:
  38. # @(#)MAKEDEV 5.5 (Berkeley) 5/28/91
  39. #
  40. # Device "make" file. Valid arguments:
  41. # all makes all known devices, including local devices,
  42. # Tries to make the ``standard'' number of each.
  43. # fd makes fd/* for the fdescfs.
  44. # std standard devices
  45. # local configuration specific devices
  46. #
  47. # Tapes:
  48. # st* SCSI tapes
  49. #
  50. # Disks:
  51. # fd* Floppy disks
  52. # sd* SCSI disks, includes flopticals
  53. # cd* SCSI cdrom discs
  54. # vnd* "file" pseudo-disks
  55. # ccd* concatenated disk driver
  56. #
  57. # Console ports:
  58. # ttye* ite bitmapped consoles
  59. #
  60. # Terminal ports:
  61. # ttya,b,c,d standard serial port.
  62. # tty0? cl-cd serial ports
  63. #
  64. # Pseudo terminals:
  65. # pty* set of 16 master and slave pseudo terminals
  66. #
  67. # Printers:
  68. # lp0 MVME147 parallel port
  69. # lptwo0 MVME16x parallel port
  70. #
  71. # Special purpose devices:
  72. # lkm loadable kernel modules interface.
  73. # bpf* Berkeley Packet Filter
  74. # tun* network tunnel driver
  75. PATH=/sbin:/bin:/usr/sbin:/usr/bin
  76. umask 77
  77. for i
  78. do
  79. case $i in
  80. all)
  81. sh MAKEDEV std fd st0 ttya ttyb ttyc ttyd
  82. sh MAKEDEV tty00 tty01 tty02 tty03
  83. sh MAKEDEV sd0 sd1 sd2 sd3 sd4 sd5 sd6 sd7 sd8 sd9
  84. sh MAKEDEV vnd0 vnd1 vnd2 vnd3 vnd4 pty0
  85. sh MAKEDEV vnd5 vnd6 cd0 bpf0 bpf1 bpf2 bpf3
  86. #sh MAKEDEV ccd0 ccd1 ccd2 ccd3
  87. sh MAKEDEV tun0 tun1 lp0 lptwo0 lkm local
  88. ;;
  89. floppy)
  90. sh MAKEDEV std st0 ttya ttyb ttyc ttyd tty00 tty01 tty02 tty03
  91. sh MAKEDEV sd0 sd1 sd2 sd3 sd4 sd5 sd6 cd0
  92. ;;
  93. std)
  94. rm -f console drum kmem mem null zero tty
  95. rm -f klog stdin stdout stderr
  96. mknod console c 0 0
  97. mknod drum c 3 0 ; chmod 640 drum ; chgrp kmem drum
  98. mknod kmem c 2 1 ; chmod 640 kmem ; chgrp kmem kmem
  99. mknod mem c 2 0 ; chmod 640 mem ; chgrp kmem mem
  100. mknod zero c 2 12 ; chmod 666 zero
  101. mknod null c 2 2 ; chmod 666 null
  102. mknod tty c 1 0 ; chmod 666 tty
  103. mknod klog c 6 0 ; chmod 600 klog
  104. mknod stdin c 21 0 ; chmod 666 stdin
  105. mknod stdout c 21 1 ; chmod 666 stdout
  106. mknod stderr c 21 2 ; chmod 666 stderr
  107. ;;
  108. st*)
  109. umask 2 ; unit=`expr $i : '..\(.*\)'`
  110. case $i in
  111. st*) name=st; blk=5; chr=20;;
  112. esac
  113. rm -f $name$unit n$name$unit e$name$unit en$name$unit \
  114. r$name$unit nr$name$unit er$name$unit enr$name$unit
  115. case $unit in
  116. 0|1|2|3|4|5|6)
  117. mknod ${name}${unit} b $blk `expr $unit '*' 16 + 0`
  118. mknod n${name}${unit} b $blk `expr $unit '*' 16 + 1`
  119. mknod e${name}${unit} b $blk `expr $unit '*' 16 + 2`
  120. mknod en${name}${unit} b $blk `expr $unit '*' 16 + 3`
  121. mknod r${name}${unit} c $chr `expr $unit '*' 16 + 0`
  122. mknod nr${name}${unit} c $chr `expr $unit '*' 16 + 1`
  123. mknod er${name}${unit} c $chr `expr $unit '*' 16 + 2`
  124. mknod enr${name}${unit} c $chr `expr $unit '*' 16 + 3`
  125. chgrp operator ${name}${unit} n${name}${unit} \
  126. e$name$unit en$name$unit \
  127. r${name}${unit} nr${name}${unit} \
  128. er${name}${unit} enr${name}${unit}
  129. chmod 640 ${name}${unit} n${name}${unit} \
  130. e$name$unit en$name$unit \
  131. r${name}${unit} nr${name}${unit} \
  132. er${name}${unit} enr${name}${unit}
  133. ;;
  134. *)
  135. echo bad unit for tape in: $i
  136. ;;
  137. esac
  138. umask 77
  139. ;;
  140. sd*|vnd*|ccd*)
  141. umask 2 ; unit=`expr $i : '.*[^0-9]\([0-9]*\)'`
  142. case $i in
  143. sd*) name=sd; blk=4; chr=8;;
  144. vnd*) name=vnd; blk=8; chr=19;;
  145. #ccd*) name=ccd; blk=8; chr=7;;
  146. esac
  147. rm -f $name$unit? r$name$unit?
  148. case $unit in
  149. 0|1|2|3|4|5|6|7|8|9|10|11|12|13|14|15)
  150. mknod ${name}${unit}c b $blk `expr $unit '*' 16 + 2`
  151. mknod r${name}${unit}c c $chr `expr $unit '*' 16 + 2`
  152. if [ $name != cd -a $name != vnd ]
  153. then
  154. mknod ${name}${unit}a b $blk `expr $unit '*' 16 + 0`
  155. mknod ${name}${unit}b b $blk `expr $unit '*' 16 + 1`
  156. mknod ${name}${unit}d b $blk `expr $unit '*' 16 + 3`
  157. mknod ${name}${unit}e b $blk `expr $unit '*' 16 + 4`
  158. mknod ${name}${unit}f b $blk `expr $unit '*' 16 + 5`
  159. mknod ${name}${unit}g b $blk `expr $unit '*' 16 + 6`
  160. mknod ${name}${unit}h b $blk `expr $unit '*' 16 + 7`
  161. mknod ${name}${unit}i b $blk `expr $unit '*' 16 + 8`
  162. mknod ${name}${unit}j b $blk `expr $unit '*' 16 + 9`
  163. mknod ${name}${unit}k b $blk `expr $unit '*' 16 + 10`
  164. mknod ${name}${unit}l b $blk `expr $unit '*' 16 + 11`
  165. mknod ${name}${unit}m b $blk `expr $unit '*' 16 + 12`
  166. mknod ${name}${unit}n b $blk `expr $unit '*' 16 + 13`
  167. mknod ${name}${unit}o b $blk `expr $unit '*' 16 + 14`
  168. mknod ${name}${unit}p b $blk `expr $unit '*' 16 + 15`
  169. mknod r${name}${unit}a c $chr `expr $unit '*' 16 + 0`
  170. mknod r${name}${unit}b c $chr `expr $unit '*' 16 + 1`
  171. mknod r${name}${unit}d c $chr `expr $unit '*' 16 + 3`
  172. mknod r${name}${unit}e c $chr `expr $unit '*' 16 + 4`
  173. mknod r${name}${unit}f c $chr `expr $unit '*' 16 + 5`
  174. mknod r${name}${unit}g c $chr `expr $unit '*' 16 + 6`
  175. mknod r${name}${unit}h c $chr `expr $unit '*' 16 + 7`
  176. mknod r${name}${unit}i c $chr `expr $unit '*' 16 + 8`
  177. mknod r${name}${unit}j c $chr `expr $unit '*' 16 + 9`
  178. mknod r${name}${unit}k c $chr `expr $unit '*' 16 + 10`
  179. mknod r${name}${unit}l c $chr `expr $unit '*' 16 + 11`
  180. mknod r${name}${unit}m c $chr `expr $unit '*' 16 + 12`
  181. mknod r${name}${unit}n c $chr `expr $unit '*' 16 + 13`
  182. mknod r${name}${unit}o c $chr `expr $unit '*' 16 + 14`
  183. mknod r${name}${unit}p c $chr `expr $unit '*' 16 + 15`
  184. fi
  185. chgrp operator ${name}${unit}[a-p] r${name}${unit}[a-p]
  186. chmod 640 ${name}${unit}[a-p] r${name}${unit}[a-p]
  187. ;;
  188. *)
  189. echo bad unit for disk in: $i
  190. ;;
  191. esac
  192. umask 77
  193. ;;
  194. cd*)
  195. umask 2 ; unit=`expr $i : '..\(.*\)'`
  196. case $i in
  197. cd*) name=cd; blk=6; chr=9;;
  198. esac
  199. rm -f $name$unit? r$name$unit?
  200. case $unit in
  201. 0|1|2|3|4|5|6)
  202. mknod ${name}${unit}a b $blk `expr $unit '*' 8 + 0`
  203. mknod ${name}${unit}d b $blk `expr $unit '*' 8 + 3`
  204. mknod r${name}${unit}a c $chr `expr $unit '*' 8 + 0`
  205. chgrp operator ${name}${unit}[a-h] r${name}${unit}[a-h]
  206. chmod 640 ${name}${unit}[a-h] r${name}${unit}[a-h]
  207. ;;
  208. *)
  209. echo bad unit for disk in: $i
  210. ;;
  211. esac
  212. umask 77
  213. ;;
  214. tty0*|ttyA*)
  215. type=`expr $i : 'tty\(.\).'`
  216. unit=`expr $i : 'tty.\(.\)'`
  217. rm -f ser${unit} tty0${unit} ttym${unit}
  218. case $type in
  219. 0) case $unit in
  220. 0)
  221. rm -f tty0${unit} ttym${unit}
  222. mknod tty0${unit} c 12 0
  223. mknod ttym${unit} c 12 128
  224. chown uucp:wheel tty0${unit} ttym${unit}
  225. ;;
  226. *)
  227. echo bad unit for tty0 in: $i
  228. ;;
  229. esac
  230. ;;
  231. A) case $unit in
  232. 0|1)
  233. rm -f ttyA${unit} ttyM${unit}
  234. mknod ttyA${unit} c 17 $unit
  235. mknod ttyM${unit} c 17 `expr 128 + $unit`
  236. chown uucp:wheel ttyA${unit} ttyM${unit}
  237. ;;
  238. *)
  239. echo bad unit for ttyA in: $i
  240. ;;
  241. esac
  242. ;;
  243. *)
  244. echo bad type for tty in: $i
  245. ;;
  246. esac
  247. ;;
  248. lp*)
  249. unit=`expr $i : 'par\(.*\)'`
  250. rm -f par${unit}
  251. case $unit in
  252. 0)
  253. mknod par${unit} c 11 ${unit}
  254. ;;
  255. *)
  256. echo bad unit for par in: $i
  257. ;;
  258. esac
  259. ;;
  260. ttye*)
  261. unit=`expr $i : 'ttye\(.*\)'`
  262. rm -f ttye${unit}
  263. rm -f ite*
  264. case $unit in
  265. 0|1|2|3|4)
  266. mknod ttye${unit} c 13 ${unit}
  267. ;;
  268. *)
  269. echo bad unit for ttye in: $i
  270. ;;
  271. esac
  272. ;;
  273. pty*)
  274. class=`expr $i : 'pty\(.*\)'`
  275. case $class in
  276. 0) offset=0 name=p;;
  277. 1) offset=16 name=q;;
  278. 2) offset=32 name=r;;
  279. 3) offset=48 name=s;;
  280. # Note that telnetd, rlogind, and xterm (at least) only look at p-s.
  281. 4) offset=64 name=t;;
  282. *) echo bad unit for pty in: $i;;
  283. esac
  284. case $class in
  285. 0|1|2|3|4)
  286. umask 0
  287. (i=0; while [ $i -lt 16 ]; do
  288. eval `printf "rm -f tty%s%x; mknod tty%s%x c 4 %d; \
  289. rm -f pty%s%x; mknod pty%s%x c 5 %d" $name $i \
  290. $name $i $offset $name $i $name $i $offset`
  291. offset=$(($offset+1))
  292. i=$(($i+1))
  293. done)
  294. umask 77
  295. ;;
  296. esac
  297. ;;
  298. bpf*)
  299. unit=`expr $i : 'bpf\(.*\)'`
  300. rm -f bpf$unit
  301. mknod bpf$unit c 22 $unit
  302. chown root.wheel bpf$unit
  303. ;;
  304. tun*)
  305. unit=`expr $i : 'tun\(.*\)'`
  306. rm -f tun$unit
  307. mknod tun$unit c 40 $unit
  308. chmod 600 tun$unit
  309. chown root.wheel tun$unit
  310. ;;
  311. lkm)
  312. rm -f lkm
  313. mknod lkm c 24 0
  314. chown root:kmem lkm
  315. chmod 640 lkm
  316. ;;
  317. local)
  318. umask 0
  319. sh MAKEDEV.local
  320. umask 77
  321. ;;
  322. *)
  323. echo $i: unknown device
  324. ;;
  325. esac
  326. done