From owner-freebsd-current@FreeBSD.ORG Wed Feb 21 23:09:14 2007 Return-Path: X-Original-To: freebsd-current@FreeBSD.org Delivered-To: freebsd-current@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id DB2CA16A401 for ; Wed, 21 Feb 2007 23:09:14 +0000 (UTC) (envelope-from tataz@tataz.chchile.org) Received: from smtp5-g19.free.fr (smtp5-g19.free.fr [212.27.42.35]) by mx1.freebsd.org (Postfix) with ESMTP id 7C55B13C494 for ; Wed, 21 Feb 2007 23:09:14 +0000 (UTC) (envelope-from tataz@tataz.chchile.org) Received: from tatooine.tataz.chchile.org (tataz.chchile.org [82.233.239.98]) by smtp5-g19.free.fr (Postfix) with ESMTP id D8BBF359B0 for ; Thu, 22 Feb 2007 00:09:13 +0100 (CET) Received: from obiwan.tataz.chchile.org (unknown [192.168.1.25]) by tatooine.tataz.chchile.org (Postfix) with ESMTP id 86F0B9BE05 for ; Wed, 21 Feb 2007 23:11:08 +0000 (UTC) Received: by obiwan.tataz.chchile.org (Postfix, from userid 1000) id 7C12B405B; Thu, 22 Feb 2007 00:11:08 +0100 (CET) Date: Thu, 22 Feb 2007 00:11:08 +0100 From: Jeremie Le Hen To: freebsd-current@FreeBSD.org Message-ID: <20070221231108.GC2479@obiwan.tataz.chchile.org> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="PuGuTyElPB9bOcsM" Content-Disposition: inline User-Agent: Mutt/1.5.13 (2006-08-11) Cc: Subject: Using /etc/rc.d/devfs from command-line X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 21 Feb 2007 23:09:14 -0000 --PuGuTyElPB9bOcsM Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Hi, The attached patch allows to provide arguments to rc.d/devfs with the same syntax as $devfs_set_rulesets. This is then easier to mount manually devfs inside a directory and apply some predefined rulesets on it. Before this patch you had to manually apply rules to the devfs mount point, provided pre-configured rulesets had been loaded into the kernel (with rc.subr's devfs_init_rulesets()). Example: % mount_devfs none /space/chroot/dev % /etc/rc.d/devfs start /space/chroot/dev=devfsrules_jail Best regards, -- Jeremie Le Hen < jeremie at le-hen dot org >< ttz at chchile dot org > --PuGuTyElPB9bOcsM Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="rc.d_devfs.patch" ? .devfs.swp ? rc.d_devfs.patch Index: devfs =================================================================== RCS file: /home/ncvs/src/etc/rc.d/devfs,v retrieving revision 1.12 diff -u -p -r1.12 devfs --- devfs 21 Jan 2006 14:31:45 -0000 1.12 +++ devfs 21 Feb 2007 22:55:53 -0000 @@ -14,6 +14,21 @@ name="devfs" start_cmd='devfs_start' stop_cmd=':' +set_rulesets() +{ + if [ -n "$devfs_set_rulesets" ]; then + local _dir_set + local _dir + local _set + for _dir_set in $devfs_set_rulesets; do + _dir=${_dir_set%=*} + _set=${_dir_set#*=} + devfs_set_ruleset $_set $_dir + devfs_apply_ruleset $_set $_dir + done + fi +} + devfs_start() { if [ -n "$devfs_system_ruleset" -o -n "$devfs_set_rulesets" ]; then @@ -22,17 +37,7 @@ devfs_start() devfs_set_ruleset $devfs_system_ruleset /dev devfs_apply_ruleset $devfs_system_ruleset /dev fi - if [ -n "$devfs_set_rulesets" ]; then - local _dir_set - local _dir - local _set - for _dir_set in $devfs_set_rulesets; do - _dir=${_dir_set%=*} - _set=${_dir_set#*=} - devfs_set_ruleset $_set $_dir - devfs_apply_ruleset $_set $_dir - done - fi + set_rulesets fi read_devfs_conf } @@ -67,4 +72,14 @@ read_devfs_conf() } load_rc_config $name -run_rc_command "$1" +cmd="$1" +if [ $# -gt 0 ]; then + shift +fi +if [ -n "$*" ]; then + start_cmd="set_rulesets" + devfs_set_rulesets="$*" + devfs_init_rulesets +fi + +run_rc_command "$cmd" --PuGuTyElPB9bOcsM--