From nobody@FreeBSD.org  Fri Feb  8 22:23:01 2008
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 368EB16A418
	for <freebsd-gnats-submit@FreeBSD.org>; Fri,  8 Feb 2008 22:23:01 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (www.freebsd.org [IPv6:2001:4f8:fff6::21])
	by mx1.freebsd.org (Postfix) with ESMTP id 20EAD13C45E
	for <freebsd-gnats-submit@FreeBSD.org>; Fri,  8 Feb 2008 22:23:01 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.14.2/8.14.2) with ESMTP id m18MKqg1022175
	for <freebsd-gnats-submit@FreeBSD.org>; Fri, 8 Feb 2008 22:20:52 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.14.2/8.14.1/Submit) id m18MKqsH022174;
	Fri, 8 Feb 2008 22:20:52 GMT
	(envelope-from nobody)
Message-Id: <200802082220.m18MKqsH022174@www.freebsd.org>
Date: Fri, 8 Feb 2008 22:20:52 GMT
From: Fabian Thorns <fabian@thorns.it>
To: freebsd-gnats-submit@FreeBSD.org
Subject: devfs.rules are not initialized under certain (default) circumstances
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         120431
>Category:       conf
>Synopsis:       [patch] devfs.rules are not initialized under certain (default) circumstances
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    dougb
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Fri Feb 08 22:30:01 UTC 2008
>Closed-Date:    Wed Feb 08 09:21:10 UTC 2012
>Last-Modified:  Wed Feb 08 09:21:10 UTC 2012
>Originator:     Fabian Thorns
>Release:        6.2, 6.3 and 7.0-RC1
>Organization:
>Environment:
FreeBSD jailhost 7.0-RC1 FreeBSD 7.0-RC1 #0: Mon Dec 24 12:18:24 UTC 2007     root@logan.cse.buffalo.edu:/usr/obj/usr/src/sys/GENERIC  i386
>Description:
Hi there,

i just tried to set up some jails under FreeBSD 6.3 and 7.0-RC1 and was
unable to assign a devfs-ruleset to a manually mounted devfs:

# mount -t devfs devfs /jails/jail01/dev
# devfs -m /jails/jail01/dev rule -s 4 applyset
devfs rule: ioctl DEVFSIO_SAPPLY: No such process

This is caused by the problem that rulesets from neither
/etc/defaults/devfs.rules nor /etc/devfs.rules are available by default:

# grep rules_jail /etc/defaults/devfs.rules
[devfsrules_jail=4]
# devfs rule showsets
#

However, the rules are available after launching jails through /etc/rc.d/jail.

After looking around in the rc.d-scripts i found that the rulesets listed
in devfs.rules-files in rc.conf are initialized by the rc.subr method
devfs_init_rulesets which is run by /etc/rc.d/jail. I would expect this
function being lunched from /etc/rc.d/devfs at the system startup too, but
this only happens when either devfs_system_ruleset or devfs_set_rulesets
is set in rc.conf. This is not the default-case and is likely to be left
unchanged when not using devfs-rules at startup-time. This might be common
for the hostsystem, but in a jailed environment these rules are definitely
needed and should be useably right away, especially for setting up and
testing jails before starting them with rc.d/jail.

>How-To-Repeat:
see above.
>Fix:
To make the rules available I modified /etc/rc.d/dev changing line 19 from

        if [ -n "$devfs_system_ruleset" -o -n "$devfs_set_rulesets" ]; then

to 

        if [ -n "$devfs_system_ruleset" -o -n "$devfs_set_rulesets" -o -n "$devfs_rulesets" ]; then

. Afterwards all rules are initialized as soon as a ruleset is specified
using devfs_rulesets in rc.conf which is the default for dev.rules in
both /etc/ and /etc/default. The appliance of the rules is conditioned
later in /etc/rc.d/devfs and is therefore not affected by this change.
After launching /etc/rc.d/devfs restart all rules are available and
applicable at any time.

Regards,

Fabian

Patch attached with submission follows:

--- /etc/rc.d/devfs.org	Fri Feb  8 23:06:13 2008
+++ /etc/rc.d/devfs	Fri Feb  8 23:06:31 2008
@@ -16,7 +16,7 @@
 
 devfs_start()
 {
-	if [ -n "$devfs_system_ruleset" -o -n "$devfs_set_rulesets" ]; then
+	if [ -n "$devfs_system_ruleset" -o -n "$devfs_set_rulesets" -o -n "$devfs_rulesets" ]; then
 		devfs_init_rulesets
 		if [ -n "$devfs_system_ruleset" ]; then
 			devfs_set_ruleset $devfs_system_ruleset /dev


>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->freebsd-rc 
Responsible-Changed-By: linimon 
Responsible-Changed-When: Sat Feb 9 03:28:00 UTC 2008 
Responsible-Changed-Why:  
Over to maintainer(s). 

http://www.freebsd.org/cgi/query-pr.cgi?pr=120431 
State-Changed-From-To: open->closed 
State-Changed-By: dougb 
State-Changed-When: Wed Feb 8 09:20:21 UTC 2012 
State-Changed-Why:  

I added a different solution to this problem in HEAD, and will MFC soon 


Responsible-Changed-From-To: freebsd-rc->dougb 
Responsible-Changed-By: dougb 
Responsible-Changed-When: Wed Feb 8 09:20:21 UTC 2012 
Responsible-Changed-Why:  

I'm going to handle this problem. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=120431 
>Unformatted:
