what(1) on kernel binary
Jilles Tjoelker
jilles at stack.nl
Mon Jun 20 15:26:50 GMT 2005
On FreeBSD 4.x, one could easily determine the version and compilation
date of a kernel binary like this:
jilles at toad /home/jilles% what /kernel
/kernel:
FreeBSD 4.11-STABLE #20: Mon May 9 18:43:52 CEST 2005
On FreeBSD 5.x/6.x with GCC 3.x, this doesn't work anymore.
The cause is that these two arrays (in /sys/conf/newvers.sh) are now both
aligned to a 32-byte boundary, so there are 28 null bytes between @(#)
and the version number:
char sccspad[32 - 4 /* sizeof(sccs) */] = { '\\0' };
char sccs[4] = { '@', '(', '#', ')' };
A possible solution is to change the two arrays to a single one
containing 28 null bytes and @(#).
char sccs[32] = { '\\0', '\\0', '\\0', '\\0', '\\0', '\\0', '\\0',
'\\0', '\\0', '\\0', '\\0', '\\0', '\\0', '\\0', '\\0', '\\0', '\\0',
'\\0', '\\0', '\\0', '\\0', '\\0', '\\0', '\\0', '\\0', '\\0', '\\0',
'\\0', '@', '(', '#', ')' };
The symbols sccs and sccspad are not otherwise used in the RELENG_5
kernel.
what(1) still shows some garbage from the em(4) driver:
$RCSfile: if_em_hw.h,v $$Revision: 1.41 $$Date: 2004/05/17 15:18:53 $
$RCSfile: if_em_hw.h,v $$Revision: 1.41 $$Date: 2004/05/17 15:18:53 $
--
Jilles Tjoelker
-------------- next part --------------
--- src/sys/conf/newvers.sh.orig Thu Nov 4 23:02:55 2004
+++ src/sys/conf/newvers.sh Wed Jun 15 18:15:55 2005
@@ -85,8 +85,7 @@
i=`${MAKE:-make} -V KERN_IDENT`
cat << EOF > vers.c
$COPYRIGHT
-char sccspad[32 - 4 /* sizeof(sccs) */] = { '\\0' };
-char sccs[4] = { '@', '(', '#', ')' };
+char sccs[32] = { '\\0', '\\0', '\\0', '\\0', '\\0', '\\0', '\\0', '\\0', '\\0', '\\0', '\\0', '\\0', '\\0', '\\0', '\\0', '\\0', '\\0', '\\0', '\\0', '\\0', '\\0', '\\0', '\\0', '\\0', '\\0', '\\0', '\\0', '\\0', '@', '(', '#', ')' };
char version[] = "${VERSION} #${v}: ${t}\\n ${u}@${h}:${d}\\n";
char ostype[] = "${TYPE}";
char osrelease[] = "${RELEASE}";
More information about the freebsd-hackers
mailing list