Subject: Re: @booted_kernel magic symlink?
To: Alan Barrett <apb@cequrux.com>
From: Steven M. Bellovin <smb@cs.columbia.edu>
List: tech-kern
Date: 04/27/2006 12:40:30
This is a multi-part message in MIME format.

--Multipart=_Thu__27_Apr_2006_12_40_30_-0400_T/GgK.oReRGN7Uas
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit

On Thu, 27 Apr 2006 10:05:28 +0300, Alan Barrett <apb@cequrux.com> wrote:

> On Wed, 26 Apr 2006, Bill Studenmund wrote:
> > [This thread] was about making it easier to find the booted kernel.
> 
> There's already an easy way to find the booted kernel: $(sysctl
> machdep.booted_kernel).  I suppose that's not easy enough for some people,
> and I can see the attraction of a fixed name that would just DTRT when
> used as an arg to open(3).
> 
> I see two obvious ways of allowing a fixed file name to DTRT: a magic
> symlink, or a magic kernfs node.  I think I'd prefer a kernfs node,
> like /kern/kernel, and it has the advantage that it would be possible
> (in principle) to make it work in some situations where a magic symlink
> would not work.
> 
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....



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

--Multipart=_Thu__27_Apr_2006_12_40_30_-0400_T/GgK.oReRGN7Uas
Content-Type: application/octet-stream;
 name="booted_kernel"
Content-Disposition: attachment;
 filename="booted_kernel"
Content-Transfer-Encoding: base64

IyEvYmluL3NoCiMKCiMgUFJPVklERTogYm9vdGVkX2tlcm5lbAojIFJFUVVJUkU6IG1vdW50Y3Jp
dGxvY2FsCiMgQkVGT1JFOiAgc2F2ZWNvcmUKCiRfcmNfc3Vicl9sb2FkZWQgLiAvZXRjL3JjLnN1
YnIKCm5hbWU9ImJvb3RlZF9rZXJuZWwiCnJjdmFyPSRuYW1lCnN0YXJ0X2NtZD0iYm9vdGVkX2tl
cm5lbF9zdGFydCIKc3RvcF9jbWQ9IjoiCgpib290ZWRfa2VybmVsX3N0YXJ0KCkKewoJaWYgWyAt
eiAiJGJvb3RlZF9rZXJuZWxfZmxhZ3MiIF0KCXRoZW4KCQlib290ZWRfa2VybmVsX2ZsYWdzPSIv
Ym9vdGVkX2tlcm5lbCIKCWZpCgliaz1gc3lzY3RsIG1hY2hkZXAuYm9vdGVkX2tlcm5lbCAyPi9k
ZXYvbnVsbCB8IHNlZCAncy8uKj0gLy8nYAoJaWYgWyAhIC16ICIkYmsiIF0KCXRoZW4KCQlybSAt
ZiAiJGJvb3RlZF9rZXJuZWxfZmxhZ3MiCgkJbG4gLXMgIiRiayIgIiRib290ZWRfa2VybmVsX2Zs
YWdzIgoJZmkKfQoKbG9hZF9yY19jb25maWcgJG5hbWUKcnVuX3JjX2NvbW1hbmQgIiQxIgo=

--Multipart=_Thu__27_Apr_2006_12_40_30_-0400_T/GgK.oReRGN7Uas--