Subject: Proposal to fix booted_kernel on shark.
To: None <port-arm32@netbsd.org>
From: None <toddpw@toddpw.org>
List: port-arm32
Date: 01/19/2003 03:17:58
NetBSD/shark is now ELF, but the firmware only reads a.out. Copy both kernels
to /, no problem.  Understandably, machdep.booted_kernel reports "netbsd.aout"
however, and groveling programs now fail because they expected an ELF kernel.

Proposed solution is to strip the .aout suffix, under the assumption that an
ELF kernel without that suffix will usually be available in the same place,
and if it isn't, we're probably screwed anyway.

--- shark_machdep.c.orig	Fri May  3 14:28:11 2002
+++ shark_machdep.c	Sat Jan 18 21:21:06 2003
@@ -392,10 +392,17 @@
 			return;
 		cp = strrchr(boot_component, ':');
 		if (cp != NULL) {
+			int cplen;
 			*cp++ = '\0';
 			if (cp[0] == '\\')
 				cp++;
 			booted_kernel = cp; 
+
+			/* Zap ".aout" suffix since we only grok ELF now. */
+			cplen = strlen(cp);
+			if (cplen > 5 && !strcmp(&cp[cplen-5], ".aout")) {
+				cp[cplen-5] = '\0';
+			}
 		}
 	}
 
Tested good against 1.6 on my shark.  The diff above is against -current
from this evening, after applying the 1.6 diff successfully using patch.

Any suggestions before I commit?

-- 
Todd Whitesel
toddpw @ toddpw.org