Subject: Re: @booted_kernel magic symlink?
To: Chapman Flack <nblists@anastigmatix.net>
From: Steven M. Bellovin <smb@cs.columbia.edu>
List: tech-kern
Date: 04/27/2006 14:51:50
On Thu, 27 Apr 2006 14:07:24 -0400, Chapman Flack
<nblists@anastigmatix.net> wrote:

> Steven M. Bellovin wrote:
> > Here's a quick-and-dirty hack, very lightly tested.  There's deliberately
> > no stop routine to delete the symlink, and it runs before savecore; the
> > idea is that if the system crashed, you can save the failed kernel....
> [snip]
> >	bk=`sysctl machdep.booted_kernel 2>/dev/null | sed 's/.*= //'`
> 	[snip]
> >		ln -s "$bk" "$booted_kernel_flags"
> 
> That's very close. The one major point overlooked is that it has to
> be ln -s "$kernelfs_mountpoint/$bk" "$booted_kernel_flags" where
> kernelfs_mountpoint will need configuration by the human administrator
> in rc.conf.  Otherwise, you've just written something that makes the
> same information sysctl has available as a symlink, which is missing the
> same component that was missing to start with.

That was the point of using booted_kernel_flags, to let the administrator
specify that somewhere.
> 
> minor nits: ln -sf can eliminate the rm; sysctl -n eliminates the sed.
> 
Thanks.  The train was arriving at my station; I didn't have time to poke
further...

		--Steven M. Bellovin, http://www.cs.columbia.edu/~smb