Date: Mon, 20 Jun 2005 17:26:49 +0200 From: Jilles Tjoelker <jilles@stack.nl> To: freebsd-hackers@freebsd.org Subject: what(1) on kernel binary Message-ID: <20050620152649.GA1201@stack.nl>
next in thread | raw e-mail | index | archive | help
--n8g4imXOkfNTN/H1 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On FreeBSD 4.x, one could easily determine the version and compilation date of a kernel binary like this: jilles@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 --n8g4imXOkfNTN/H1 Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="newvers.sh.patch" --- 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}"; --n8g4imXOkfNTN/H1--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20050620152649.GA1201>