devfs ruleset processing in rc.subr

Rob Farmer rfarmer at predatorlabs.net
Wed Jan 6 09:18:34 UTC 2010


On Tue, Jan 5, 2010 at 10:49 PM, Doug Barton <dougb at freebsd.org> wrote:
> Rob Farmer wrote:
>> Hello,
>>
>> I am trying to fix an issue with the port shells/scponly's rc.d script
>> and I think I may have come across a bug in /etc/rc.subr related to
>> devfs.
>>
>> Here's what I'm trying to do:
>>
>> make_devfs() {
>>       # $1 is the user name whose home directory needs a minimal
>>       # devfs created. If ~/dev exists, it will be deleted.
>>
>>       eval DEV="~$1/dev"
>>       while /sbin/umount "${DEV}" 2>/dev/null; do :; done
>
> This definitely shouldn't be set up to spin forever like this ...
> probably needs to try the umount || err

How would you recommend to do this? I have the following, but I have a
feeling there must be a simpler way:

	if /sbin/mount | grep "${DEV}" >/dev/null 2>&1; then
		/sbin/umount "${DEV}" 2>/dev/null
	fi

>
>>       /bin/rm -rf "${DEV}"
>
> Personally I would rather see here:
> rmdir $DEV || err 1 "Unable to remove $DEV"

Changed.

>
> Although frankly I'm a little confused as to why you go through all
> these gymnastics, although I do admire your thoroughness. :)  What are
> your goals for all the safety features?

I'm not the original author - I'm pretty new to shell scripting so I'm
just trying to get it working with the minimum amount of changes so I
don't accidentally introduce more mistakes.

>
>>       /bin/mkdir -p "${DEV}"
>>       devfs_domount "${DEV}"
>>       if devfs_init_rulesets; then
>>               devfs_apply_ruleset "1" "${DEV}" && \
>
> # devfs_apply_ruleset ruleset [dir]
> #       Apply ruleset number $ruleset to the devfs mountpoint $dir.
> #       The ruleset argument must be a ruleset name as specified
> #       in a devfs.rules(5) file.
>
> Take a look at /etc/defaults/devfs.rules if you're interested in how
> the symbolic names are assigned.

OK - I see now, I was trying to using the rule numbers instead of the
symbolic names. It works fine when I do it the way it was designed :)

The full script is at
http://students.washington.edu/rfarmer/scponly.in
if you want to take a look before I submit it.

Thanks for your help,

Rob Farmer

>
>
> hth,
>
> Doug
>
> --
>
>        Improve the effectiveness of your Internet presence with
>        a domain name makeover!    http://SupersetSolutions.com/
>
>        Computers are useless. They can only give you answers.
>                        -- Pablo Picasso
>
>


More information about the freebsd-rc mailing list