devfs revision 127222
140123Sdes#!/bin/sh
240123Sdes#
3709Swollman# $FreeBSD: head/etc/rc.d/devfs 127222 2004-03-20 07:10:16Z green $
437Srgrimes#
537Srgrimes
637Srgrimes# PROVIDE: devfs
737Srgrimes# REQUIRE: LOGIN
837Srgrimes# BEFORE:  securelevel
937Srgrimes# KEYWORD: FreeBSD nojail
108460Sjkh
1125184Sjkh. /etc/rc.subr
128460Sjkh
138460Sjkhname="devfs"
1437Srgrimesstart_cmd='devfs_start'
1537Srgrimesstop_cmd=':'
1637Srgrimes
1737Srgrimesdevfs_start()
1837Srgrimes{
1937Srgrimes	if [ -n "$devfs_system_ruleset" -o -n "$devfs_set_rulesets" ]; then
2037Srgrimes		devfs_init_rulesets
2137Srgrimes		if [ -n "$devfs_system_ruleset" ]; then
2220684Sjoerg			devfs_set_ruleset $devfs_system_ruleset /dev
2337Srgrimes			devfs_apply_ruleset $devfs_system_ruleset /dev
2437Srgrimes		fi
2515568Sasami		if [ -n "$devfs_set_rulesets" ]; then
2625184Sjkh			local _dir_set
2715568Sasami			local _dir
2815568Sasami			local _set
2915568Sasami			for _dir_set in $devfs_set_rulesets; do
303843Sdg				_dir=${_dir_set%=*}
313843Sdg				_set=${_dir_set#*=}
3225184Sjkh				devfs_set_ruleset $_set $_dir
3337Srgrimes				devfs_apply_ruleset $_set $_dir
3437Srgrimes			done
3537Srgrimes		fi
3637Srgrimes	fi
3737Srgrimes	read_devfs_conf
3837Srgrimes}
3937Srgrimes
4037Srgrimesread_devfs_conf()
4137Srgrimes{
4237Srgrimes	if [ -r /etc/devfs.conf ]; then
4337Srgrimes		cd /dev
4437Srgrimes		while read action device parameter; do
4537Srgrimes			case "${action}" in
4637Srgrimes			l*)	if [ -c ${device} -a ! -e ${parameter} ]; then
4737Srgrimes					ln -fs ${device} ${parameter}
4837Srgrimes				fi
4937Srgrimes				;;
5037Srgrimes			o*)	if [ -c ${device} ]; then
5137Srgrimes					chown ${parameter} ${device}
5237Srgrimes				fi
5337Srgrimes				;;
5437Srgrimes			p*)	if [ -c ${device} ]; then
5537Srgrimes					chmod ${parameter} ${device}
5637Srgrimes				fi
5737Srgrimes				;;
5837Srgrimes			esac
5937Srgrimes		done < /etc/devfs.conf
6037Srgrimes	fi
6137Srgrimes}
6237Srgrimes
632164Sdgload_rc_config $name
642164Sdgrun_rc_command "$1"
6537Srgrimes