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 > _at__at_ -14,6 +14,21 _at__at_ 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 > _at__at_ -22,17 +37,7 _at__at_ 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 > } > _at__at_ -67,4 +72,14 _at__at_ 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 "$_at_" 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 "$_at_": run_rc_command $* I cannot think of a good reason to do so. -- YarReceived on Thu Feb 22 2007 - 01:27:07 UTC
This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:39:05 UTC