devfs.conf support for wildcarded devices

From: Sean McNeil <sean_at_mcneil.com>
Date: Thu, 08 Jan 2004 11:51:18 -0800
I saw a previous post once on this, but I haven't seen support for
wildcards implemented.  I've gone ahead and tried what I think is a
workable mechanism to support this.  Please let me know if this would do
what I think people are interested in (it does what I want ;)

/etc/rc.d/devfs:

#!/bin/sh
#
# $FreeBSD: src/etc/rc.d/devfs,v 1.6 2003/08/20 06:15:18 mtm Exp $
#

# PROVIDE: devfs
# REQUIRE: LOGIN
# BEFORE:  securelevel
# KEYWORD: FreeBSD

. /etc/rc.subr

name="devfs"
start_cmd='devfs_start'
stop_cmd=':'

devfs_start()
{
	if [ -n "$devfs_system_ruleset" ]; then
		devfs_init_rulesets
		devfs_set_ruleset $devfs_system_ruleset /dev
		devfs_apply_ruleset $devfs_system_ruleset /dev
	fi
	read_devfs_conf
}

read_devfs_conf()
{
	if [ -r /etc/devfs.conf ]; then
		cd /dev
		while read action devlist parameter; do
		   for device in ${devlist}; do
			case "${action}" in
			l*)	if [ -c ${device} -a ! -e ${parameter} ]; then
					ln -fs ${device} ${parameter}
				fi
				;;
			o*)	if [ -c ${device} ]; then
					chown ${parameter} ${device}
				fi
				;;
			p*)	if [ -c ${device} ]; then
					chmod ${parameter} ${device}
				fi
				;;
			esac
		  done
		done < /etc/devfs.conf
	fi
}

load_rc_config $name
run_rc_command "$1"
Received on Thu Jan 08 2004 - 10:51:25 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:37:37 UTC