Question about NIC link state initialization

perryh at pluto.rain.com perryh at pluto.rain.com
Fri Jul 1 08:12:34 UTC 2011


Steve Polyack <korvus at comcast.net> wrote:

> I was able to "fix" the single-user mode behavior (which I agree,
> isn't necessarily broken) and get it to bring up the links by
> simply patching init(8) to call system("/sbin/ifconfig") before
> prompting for the single-user shell.  It works, but I feel dirty.

I see no particular objection to adding a way of running "something"
ahead of the single-user shell, but system(3) is not necessarily the
best mechanism to use for the purpose because it invokes a shell.
It would be both more efficient and more robust to call fork(2) and
exec(3) (or execve(2)) directly.

It would be more general to fork/exec "/etc/rc.single" instead of
"/sbin/ifconfig", expecting "/etc/rc.single" to be an executable
script (with an appropriate shebang line) and ignoring the failure
which would occur if it did not exist.  (In your case, instead of
a script, you could make /etc/rc.single a link to /sbin/ifconfig.)


More information about the freebsd-net mailing list