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.

495 lines
14 KiB

27 years ago
28 years ago
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. # $NetBSD: MAKEDEV,v 1.8 1996/03/27 14:27:53 leo 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. # 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. # floppy devices needed for install floppies
  45. # std standard devices
  46. # local configuration specific devices
  47. #
  48. # Tapes:
  49. # st* SCSI tapes
  50. #
  51. # Disks:
  52. # fd* Floppy disks (fdxa: 360Kb, fdxb: 720Kb, fdxc: 1.44Mb)
  53. # sd* SCSI disks, includes flopticals
  54. # cd* SCSI cdrom discs
  55. # vnd* "file" pseudo-disks
  56. # ccd* concatedated disk driver
  57. #
  58. # Console ports:
  59. # ttye* ite bitmapped consoles
  60. #
  61. # Pointing devices:
  62. # mouse* Atari mice
  63. #
  64. # Printer:
  65. # lpt0 centronics printer
  66. #
  67. # Terminal ports:
  68. # ser02 serial2 port (channel A on 8530)
  69. # mdm02 modem2 port (channel B on 8530)
  70. #
  71. # Pseudo terminals:
  72. # pty* set of 16 master and slave pseudo terminals
  73. #
  74. # Special purpose devices:
  75. # grf* Motherboard bitmapped video.
  76. # kbd Atari keyboard.
  77. # view* generic interface to graphic displays.
  78. # aconf autoconfig information (not yet)
  79. # lkm loadable kernel modules interface.
  80. # bpf* Berkeley Packet Filter
  81. # tun* network tunnel driver
  82. # *random random data source
  83. # uk* unknown SCSI
  84. # ss* SCSI scanners
  85. PATH=/sbin:/bin:/usr/sbin:/usr/bin
  86. umask 77
  87. for i
  88. do
  89. case $i in
  90. all)
  91. sh MAKEDEV std fd st0 ttye0 ttye1 ttye2 ttye3 ttye4 ttye5 grf0 grf1
  92. sh MAKEDEV grf2 grf3 grf4 grf5 mouse0 mouse1
  93. sh MAKEDEV kbd sd0 sd1 sd2 sd3 sd4 sd5 sd6 sd7 sd8 sd9 vnd0 vnd1 vnd2
  94. sh MAKEDEV vnd3 vnd4 view00 view01 view02 view03 view04 view05 pty0
  95. sh MAKEDEV vnd5 vnd6 cd0 fd0 fd1 fd2 fd3 ccd0 ccd1 ccd2 ccd3
  96. sh MAKEDEV bpf0 bpf1 bpf2 bpf3 bpf4 bpf5 bpf6 bpf7 bpf8 bpf9
  97. sh MAKEDEV tun0 tun1 lkm ser02 mdm02 lpt0 random uk0 uk1 ss0 local
  98. ;;
  99. floppy)
  100. sh MAKEDEV std st0 ttye0 ttye1 ttye2 grf0 grf1 grf2 kbd tun0 tun1
  101. sh MAKEDEV sd0 sd1 sd2 sd3 sd4 sd5 sd6 cd0 fd0 fd1 rd0
  102. ;;
  103. std)
  104. rm -f console drum kmem mem nvram reload null zero tty
  105. rm -f klog stdin stdout stderr
  106. mknod console c 0 0
  107. mknod drum c 3 0 ; chmod 640 drum ; chown root.kmem drum
  108. mknod kmem c 2 1 ; chmod 640 kmem ; chown root.kmem kmem
  109. mknod mem c 2 0 ; chmod 640 mem ; chown root.kmem mem
  110. mknod nvram c 2 11 ; chmod 640 nvram ; chown root.kmem nvram
  111. mknod reload c 2 20 ; chmod 640 reload ; chown root.kmem reload
  112. mknod zero c 2 12 ; chmod 666 zero
  113. mknod null c 2 2 ; chmod 666 null
  114. mknod tty c 1 0 ; chmod 666 tty
  115. mknod klog c 6 0 ; chmod 600 klog
  116. mknod stdin c 18 0 ; chmod 666 stdin
  117. mknod stdout c 18 1 ; chmod 666 stdout
  118. mknod stderr c 18 2 ; chmod 666 stderr
  119. ;;
  120. fd)
  121. rm -f fd/*
  122. mkdir fd > /dev/null 2>&1
  123. (cd fd && i=0 && while [ $i -lt 64 ]; do
  124. mknod $i c 18 $i
  125. i=$(($i+1))
  126. done)
  127. chown -R root.wheel fd
  128. chmod 555 fd
  129. chmod 666 fd/*
  130. ;;
  131. ser02)
  132. rm -f ser02
  133. mknod ser02 c 7 0
  134. chown uucp.wheel ser02
  135. ;;
  136. mdm02)
  137. rm -f mdm02
  138. mknod mdm02 c 7 16
  139. chown uucp.wheel mdm02
  140. ;;
  141. st*)
  142. umask 2 ; unit=`expr $i : '..\(.*\)'`
  143. case $i in
  144. st*) name=st; blk=5; chr=10;;
  145. esac
  146. rm -f $name$unit n$name$unit e$name$unit en$name$unit \
  147. r$name$unit nr$name$unit er$name$unit enr$name$unit
  148. case $unit in
  149. 0|1|2|3|4|5|6)
  150. mknod ${name}${unit} b $blk `expr $unit '*' 16 + 0`
  151. mknod n${name}${unit} b $blk `expr $unit '*' 16 + 1`
  152. mknod e${name}${unit} b $blk `expr $unit '*' 16 + 2`
  153. mknod en${name}${unit} b $blk `expr $unit '*' 16 + 3`
  154. mknod r${name}${unit} c $chr `expr $unit '*' 16 + 0`
  155. mknod nr${name}${unit} c $chr `expr $unit '*' 16 + 1`
  156. mknod er${name}${unit} c $chr `expr $unit '*' 16 + 2`
  157. mknod enr${name}${unit} c $chr `expr $unit '*' 16 + 3`
  158. chown root.operator ${name}${unit} n${name}${unit} \
  159. e$name$unit en$name$unit \
  160. r${name}${unit} nr${name}${unit} \
  161. er${name}${unit} enr${name}${unit}
  162. chmod 640 ${name}${unit} n${name}${unit} \
  163. e$name$unit en$name$unit \
  164. r${name}${unit} nr${name}${unit} \
  165. er${name}${unit} enr${name}${unit}
  166. ;;
  167. *)
  168. echo bad unit for tape in: $i
  169. ;;
  170. esac
  171. umask 77
  172. ;;
  173. fd*)
  174. umask 2 ; unit=`expr $i : '.*[^0-9]\([0-9]*\)'`
  175. rm -f fd$unit? rfd$unit?
  176. case $unit in
  177. 0|1|2|3)
  178. mknod fd${unit}a b 2 `expr $unit '*' 16`
  179. mknod fd${unit}b b 2 `expr $unit '*' 16 + 1`
  180. mknod fd${unit}c b 2 `expr $unit '*' 16 + 2`
  181. mknod rfd${unit}a c 16 `expr $unit '*' 16`
  182. mknod rfd${unit}b c 16 `expr $unit '*' 16 + 1`
  183. mknod rfd${unit}c c 16 `expr $unit '*' 16 + 2`
  184. chown root.operator fd$unit? rfd$unit?
  185. chmod 640 fd$unit? rfd$unit?
  186. ;;
  187. *)
  188. echo bad unit for floppy disk in: $i
  189. ;;
  190. esac
  191. umask 77
  192. ;;
  193. rd0) # Ramdisk, only usefull for boot-floppy
  194. umask 2; rm -f rd0
  195. mknod rd0 b 1 0
  196. umask 77
  197. ;;
  198. sd*|ccd*)
  199. umask 2 ; unit=`expr $i : '.*[^0-9]\([0-9]*\)'`
  200. case $i in
  201. sd*) name=sd; blk=4; chr=8;;
  202. ccd*) name=ccd; blk=13; chr=27;;
  203. esac
  204. rm -f $name$unit? r$name$unit?
  205. case $unit in
  206. 0|1|2|3|4|5|6|7|8|9|10|11|12|13|14|15)
  207. mknod ${name}${unit}c b $blk `expr $unit '*' 16 + 2`
  208. mknod r${name}${unit}c c $chr `expr $unit '*' 16 + 2`
  209. mknod ${name}${unit}a b $blk `expr $unit '*' 16 + 0`
  210. mknod ${name}${unit}b b $blk `expr $unit '*' 16 + 1`
  211. mknod ${name}${unit}d b $blk `expr $unit '*' 16 + 3`
  212. mknod ${name}${unit}e b $blk `expr $unit '*' 16 + 4`
  213. mknod ${name}${unit}f b $blk `expr $unit '*' 16 + 5`
  214. mknod ${name}${unit}g b $blk `expr $unit '*' 16 + 6`
  215. mknod ${name}${unit}h b $blk `expr $unit '*' 16 + 7`
  216. mknod ${name}${unit}i b $blk `expr $unit '*' 16 + 8`
  217. mknod ${name}${unit}j b $blk `expr $unit '*' 16 + 9`
  218. mknod ${name}${unit}k b $blk `expr $unit '*' 16 + 10`
  219. mknod ${name}${unit}l b $blk `expr $unit '*' 16 + 11`
  220. mknod ${name}${unit}m b $blk `expr $unit '*' 16 + 12`
  221. mknod ${name}${unit}n b $blk `expr $unit '*' 16 + 13`
  222. mknod ${name}${unit}o b $blk `expr $unit '*' 16 + 14`
  223. mknod ${name}${unit}p b $blk `expr $unit '*' 16 + 15`
  224. mknod r${name}${unit}a c $chr `expr $unit '*' 16 + 0`
  225. mknod r${name}${unit}b c $chr `expr $unit '*' 16 + 1`
  226. mknod r${name}${unit}d c $chr `expr $unit '*' 16 + 3`
  227. mknod r${name}${unit}e c $chr `expr $unit '*' 16 + 4`
  228. mknod r${name}${unit}f c $chr `expr $unit '*' 16 + 5`
  229. mknod r${name}${unit}g c $chr `expr $unit '*' 16 + 6`
  230. mknod r${name}${unit}h c $chr `expr $unit '*' 16 + 7`
  231. mknod r${name}${unit}i c $chr `expr $unit '*' 16 + 8`
  232. mknod r${name}${unit}j c $chr `expr $unit '*' 16 + 9`
  233. mknod r${name}${unit}k c $chr `expr $unit '*' 16 + 10`
  234. mknod r${name}${unit}l c $chr `expr $unit '*' 16 + 11`
  235. mknod r${name}${unit}m c $chr `expr $unit '*' 16 + 12`
  236. mknod r${name}${unit}n c $chr `expr $unit '*' 16 + 13`
  237. mknod r${name}${unit}o c $chr `expr $unit '*' 16 + 14`
  238. mknod r${name}${unit}p c $chr `expr $unit '*' 16 + 15`
  239. chown root.operator ${name}${unit}[a-p] r${name}${unit}[a-p]
  240. chmod 640 ${name}${unit}[a-p] r${name}${unit}[a-p]
  241. ;;
  242. *)
  243. echo bad unit for disk in: $i
  244. ;;
  245. esac
  246. umask 77
  247. ;;
  248. vnd*)
  249. umask 2 ; unit=`expr $i : 'vnd\(.*\)'`
  250. for name in vnd svnd; do
  251. blk=0; chr=17;
  252. case $name in
  253. vnd) off=0;;
  254. svnd) off=128;;
  255. esac
  256. rm -f $name$unit? r$name$unit?
  257. mknod ${name}${unit}a b $blk `expr $unit '*' 16 + $off + 0`
  258. mknod ${name}${unit}b b $blk `expr $unit '*' 16 + $off + 1`
  259. mknod ${name}${unit}c b $blk `expr $unit '*' 16 + $off + 2`
  260. mknod ${name}${unit}d b $blk `expr $unit '*' 16 + $off + 3`
  261. mknod ${name}${unit}e b $blk `expr $unit '*' 16 + $off + 4`
  262. mknod ${name}${unit}f b $blk `expr $unit '*' 16 + $off + 5`
  263. mknod ${name}${unit}g b $blk `expr $unit '*' 16 + $off + 6`
  264. mknod ${name}${unit}h b $blk `expr $unit '*' 16 + $off + 7`
  265. mknod ${name}${unit}i b $blk `expr $unit '*' 16 + $off + 8`
  266. mknod ${name}${unit}j b $blk `expr $unit '*' 16 + $off + 9`
  267. mknod ${name}${unit}k b $blk `expr $unit '*' 16 + $off + 10`
  268. mknod ${name}${unit}l b $blk `expr $unit '*' 16 + $off + 11`
  269. mknod ${name}${unit}m b $blk `expr $unit '*' 16 + $off + 12`
  270. mknod ${name}${unit}n b $blk `expr $unit '*' 16 + $off + 13`
  271. mknod ${name}${unit}o b $blk `expr $unit '*' 16 + $off + 14`
  272. mknod ${name}${unit}p b $blk `expr $unit '*' 16 + $off + 15`
  273. mknod r${name}${unit}a c $chr `expr $unit '*' 16 + $off + 0`
  274. mknod r${name}${unit}b c $chr `expr $unit '*' 16 + $off + 1`
  275. mknod r${name}${unit}c c $chr `expr $unit '*' 16 + $off + 2`
  276. mknod r${name}${unit}d c $chr `expr $unit '*' 16 + $off + 3`
  277. mknod r${name}${unit}e c $chr `expr $unit '*' 16 + $off + 4`
  278. mknod r${name}${unit}f c $chr `expr $unit '*' 16 + $off + 5`
  279. mknod r${name}${unit}g c $chr `expr $unit '*' 16 + $off + 6`
  280. mknod r${name}${unit}h c $chr `expr $unit '*' 16 + $off + 7`
  281. mknod r${name}${unit}i c $chr `expr $unit '*' 16 + $off + 8`
  282. mknod r${name}${unit}j c $chr `expr $unit '*' 16 + $off + 9`
  283. mknod r${name}${unit}k c $chr `expr $unit '*' 16 + $off + 10`
  284. mknod r${name}${unit}l c $chr `expr $unit '*' 16 + $off + 11`
  285. mknod r${name}${unit}m c $chr `expr $unit '*' 16 + $off + 12`
  286. mknod r${name}${unit}n c $chr `expr $unit '*' 16 + $off + 13`
  287. mknod r${name}${unit}o c $chr `expr $unit '*' 16 + $off + 14`
  288. mknod r${name}${unit}p c $chr `expr $unit '*' 16 + $off + 15`
  289. chown root.operator ${name}${unit}[a-p] r${name}${unit}[a-p]
  290. chmod 640 ${name}${unit}[a-p] r${name}${unit}[a-p]
  291. done
  292. umask 77
  293. ;;
  294. cd*)
  295. umask 2 ; unit=`expr $i : '..\(.*\)'`
  296. case $i in
  297. cd*) name=cd; blk=6; chr=9;;
  298. esac
  299. rm -f $name$unit? r$name$unit?
  300. case $unit in
  301. 0|1|2|3|4|5|6)
  302. mknod ${name}${unit}a b $blk `expr $unit '*' 8 + 0`
  303. mknod ${name}${unit}d b $blk `expr $unit '*' 8 + 3`
  304. mknod r${name}${unit}a c $chr `expr $unit '*' 8 + 0`
  305. chown root.operator ${name}${unit}[a-h] r${name}${unit}[a-h]
  306. chmod 640 ${name}${unit}[a-h] r${name}${unit}[a-h]
  307. ;;
  308. *)
  309. echo bad unit for disk in: $i
  310. ;;
  311. esac
  312. umask 77
  313. ;;
  314. ttye*)
  315. unit=`expr $i : 'ttye\(.*\)'`
  316. rm -f ttye${unit}
  317. rm -f ite*
  318. case $unit in
  319. 0|1|2|3|4|5|6|7|8|9)
  320. mknod ttye${unit} c 12 ${unit}
  321. ;;
  322. *)
  323. echo bad unit for ttye in: $i
  324. ;;
  325. esac
  326. ;;
  327. grf*)
  328. unit=`expr $i : 'grf\(.*\)'`
  329. rm -f grf${unit}
  330. case $unit in
  331. 0|1|2|3|4|5|6|7|8|9)
  332. mknod grf${unit} c 11 ${unit}; chmod 666 grf${unit}
  333. ;;
  334. *)
  335. echo bad unit for grf in: $i
  336. ;;
  337. esac
  338. ;;
  339. mouse*)
  340. unit=`expr $i : 'mouse\(.*\)'`
  341. rm -f mouse${unit}
  342. case $unit in
  343. 0|1)
  344. mknod mouse${unit} c 15 ${unit}; chmod 666 mouse${unit}
  345. if [ $unit = 0 ]
  346. then
  347. rm -f mouse; ln -s mouse${unit} mouse
  348. fi
  349. ;;
  350. *)
  351. echo bad unit for mouse in: $i
  352. ;;
  353. esac
  354. ;;
  355. kbd)
  356. rm -f kbd
  357. mknod kbd c 14 0
  358. ;;
  359. view*)
  360. unit=`expr $i : 'view\(.*\)'`
  361. rm -f view${unit}
  362. case $unit in
  363. 00|01|02|03|04|05|06|07|08|09)
  364. mknod view${unit} c 13 ${unit}; chmod 666 view${unit}
  365. ;;
  366. *)
  367. echo bad unit for view in: $i
  368. ;;
  369. esac
  370. ;;
  371. pty*)
  372. class=`expr $i : 'pty\(.*\)'`
  373. case $class in
  374. 0) offset=0 name=p;;
  375. 1) offset=16 name=q;;
  376. 2) offset=32 name=r;;
  377. 3) offset=48 name=s;;
  378. 4) offset=64 name=t;;
  379. 5) offset=80 name=u;;
  380. 6) offset=96 name=v;;
  381. 7) offset=112 name=w;;
  382. 8) offset=128 name=x;;
  383. 9) offset=144 name=y;;
  384. 10) offset=160 name=z;;
  385. 11) offset=176 name=P;;
  386. 12) offset=192 name=Q;;
  387. 13) offset=208 name=R;;
  388. 14) offset=224 name=S;;
  389. 15) offset=240 name=T;;
  390. *) echo bad unit for pty in: $i;;
  391. esac
  392. case $class in
  393. 0|1|2|3|4|5|6|7|8|9|10|11|12|13|14|15)
  394. umask 0
  395. (i=0; while [ $i -lt 16 ]; do
  396. eval `printf "rm -f tty%s%x; mknod tty%s%x c 4 %d; \
  397. rm -f pty%s%x; mknod pty%s%x c 5 %d" $name $i \
  398. $name $i $offset $name $i $name $i $offset`
  399. offset=$(($offset+1))
  400. i=$(($i+1))
  401. done)
  402. umask 77
  403. ;;
  404. esac
  405. ;;
  406. lpt*)
  407. unit=`expr $i : 'lpt\(.*\)'`
  408. rm -f lpt$unit
  409. mknod lpt$unit c 29 $unit
  410. chown root.wheel lpt$unit
  411. ;;
  412. bpf*)
  413. unit=`expr $i : 'bpf\(.*\)'`
  414. rm -f bpf$unit
  415. mknod bpf$unit c 19 $unit
  416. chown root.wheel bpf$unit
  417. ;;
  418. tun*)
  419. unit=`expr $i : 'tun\(.*\)'`
  420. rm -f tun$unit
  421. mknod tun$unit c 28 $unit
  422. chmod 600 tun$unit
  423. chown root.wheel tun$unit
  424. ;;
  425. lkm)
  426. rm -f lkm
  427. mknod lkm c 20 0
  428. chown root.kmem lkm
  429. chmod 640 lkm
  430. ;;
  431. random|srandom|urandom|prandom|arandom)
  432. rm -f random urandom srandom prandom arandom
  433. mknod random c 30 0
  434. mknod srandom c 30 1
  435. mknod urandom c 30 2
  436. mknod prandom c 30 3
  437. mknod arandom c 30 4
  438. chown root.wheel random srandom urandom prandom arandom
  439. chmod 644 random srandom urandom prandom arandom
  440. ;;
  441. uk*)
  442. unit=`expr $i : 'uk\(.*\)'`
  443. rm -f uk$unit
  444. mknod uk$unit c 31 $unit
  445. chown root.operator uk$unit
  446. chmod 640 uk$unit
  447. ;;
  448. ss*)
  449. unit=`expr $i : 'ss\(.*\)'`
  450. rm -f ss$unit
  451. mknod ss$unit c 32 $unit
  452. chown root.operator ss$unit
  453. chmod 440 ss$unit
  454. # backwards compatibility with older PINTs
  455. rm -f scan$unit
  456. ln -s ss$unit scan$unit
  457. ;;
  458. local)
  459. umask 0
  460. test -s MAKEDEV.local && sh MAKEDEV.local
  461. umask 77
  462. ;;
  463. *)
  464. echo $i: unknown device
  465. ;;
  466. esac
  467. done