summaryrefslogtreecommitdiffstats
path: root/sys/amd64
diff options
context:
space:
mode:
authormarcel <marcel@FreeBSD.org>2002-04-03 07:24:12 +0000
committermarcel <marcel@FreeBSD.org>2002-04-03 07:24:12 +0000
commit0dbbe50955903ed143bea85061e98780e7fb4da4 (patch)
treeb6dcb5afbd5f2f972055f768371369118ac773e8 /sys/amd64
parent8d96cdfea385d755723b1d9b0f2d33d9b3a368a5 (diff)
downloadFreeBSD-src-0dbbe50955903ed143bea85061e98780e7fb4da4.zip
FreeBSD-src-0dbbe50955903ed143bea85061e98780e7fb4da4.tar.gz
Make the kernel dump header endianness invariant by always dumping
in dump byte order (=network byte order). Swap blocksize and dumptime to avoid extraneous padding on 64-bit architectures. Use CTASSERT instead of runtime checks to make sure the header is 512 bytes large. Various style(9) fixes. Reviewed by: phk, bde, mike
Diffstat (limited to 'sys/amd64')
-rw-r--r--sys/amd64/amd64/dump_machdep.c19
1 files changed, 7 insertions, 12 deletions
diff --git a/sys/amd64/amd64/dump_machdep.c b/sys/amd64/amd64/dump_machdep.c
index b914af1..09db68b 100644
--- a/sys/amd64/amd64/dump_machdep.c
+++ b/sys/amd64/amd64/dump_machdep.c
@@ -44,6 +44,8 @@
#include <vm/pmap.h>
#include <machine/md_var.h>
+CTASSERT(sizeof(struct kerneldumpheader) == 512);
+
static struct kerneldumpheader kdh;
void
@@ -57,21 +59,14 @@ dumpsys(struct dumperinfo *di)
printf("Dumping %u MB\n", Maxmem / (1024*1024 / PAGE_SIZE));
- if (sizeof kdh != 512) {
- printf(
- "Compiled struct kerneldumpheader is %d, not %d bytes\n",
- sizeof kdh, 512);
- return;
- }
-
/* Fill in the kernel dump header */
strcpy(kdh.magic, KERNELDUMPMAGIC);
strcpy(kdh.architecture, "i386");
- kdh.version = KERNELDUMPVERSION;
- kdh.architectureversion = KERNELDUMP_I386_VERSION;
- kdh.dumplength = Maxmem * (off_t)PAGE_SIZE;
- kdh.blocksize = di->blocksize;
- kdh.dumptime = time_second;
+ kdh.version = htod32(KERNELDUMPVERSION);
+ kdh.architectureversion = htod32(KERNELDUMP_I386_VERSION);
+ kdh.dumplength = htod64(Maxmem * (off_t)PAGE_SIZE);
+ kdh.dumptime = htod64(time_second);
+ kdh.blocksize = htod32(di->blocksize);
strncpy(kdh.hostname, hostname, sizeof kdh.hostname);
strncpy(kdh.versionstring, version, sizeof kdh.versionstring);
if (panicstr != NULL)
OpenPOWER on IntegriCloud