From owner-freebsd-current@FreeBSD.ORG Thu Feb 22 02:27:07 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 E4D6216A402 for ; Thu, 22 Feb 2007 02:27:07 +0000 (UTC) (envelope-from yar@comp.chem.msu.su) Received: from comp.chem.msu.su (comp.chem.msu.su [158.250.32.97]) by mx1.freebsd.org (Postfix) with ESMTP id 13D8113C441 for ; Thu, 22 Feb 2007 02:27:06 +0000 (UTC) (envelope-from yar@comp.chem.msu.su) Received: from comp.chem.msu.su (localhost [127.0.0.1]) by comp.chem.msu.su (8.13.4/8.13.4) with ESMTP id l1M22q7r079011; Thu, 22 Feb 2007 05:02:52 +0300 (MSK) (envelope-from yar@comp.chem.msu.su) Received: (from yar@localhost) by comp.chem.msu.su (8.13.4/8.13.4/Submit) id l1M22pi4079010; Thu, 22 Feb 2007 05:02:51 +0300 (MSK) (envelope-from yar) Date: Thu, 22 Feb 2007 05:02:51 +0300 From: Yar Tikhiy To: Jeremie Le Hen Message-ID: <20070222020250.GM54441@comp.chem.msu.su> References: <20070221231108.GC2479@obiwan.tataz.chchile.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20070221231108.GC2479@obiwan.tataz.chchile.org> User-Agent: Mutt/1.5.9i Cc: freebsd-current@freebsd.org Subject: Re: 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: Thu, 22 Feb 2007 02:27:08 -0000 On Thu, Feb 22, 2007 at 12:11:08AM +0100, Jeremie Le Hen wrote: > 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()). This topic could be more appropriate on freebsd-rc. > 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 > > ? .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" Excuse me, but the last part of your patch looks like an unjustified hack. The proper way is to pass additional arguments to run_rc_command so that it passes them on to the respective method. If you just change run_rc_command "$1" to run_rc_command "$@" devfs_start() will get the additional arguments as its positional parameters $1, $2, ... Then you will be able to detect that there are such arguments and act correspondingly from devfs_start(). There are other examples in /etc/rc.d. Note that for some reason they use $*, not "$@": run_rc_command $* I cannot think of a good reason to do so. -- Yar