aboutsummaryrefslogtreecommitdiff
path: root/sys/i386
diff options
context:
space:
mode:
authorMark Johnston <markj@FreeBSD.org>2017-08-18 03:52:35 +0000
committerMark Johnston <markj@FreeBSD.org>2017-08-18 03:52:35 +0000
commit50ef60dabeb9edd3e6cd17f39ffa8b15f3f19c69 (patch)
tree0c2745a71919dd6481f4d99e4dcf4c73c7c73355 /sys/i386
parent9a61faf67d9eb2200999d653728aafe6121db1e3 (diff)
downloadsrc-50ef60dabeb9edd3e6cd17f39ffa8b15f3f19c69.tar.gz
src-50ef60dabeb9edd3e6cd17f39ffa8b15f3f19c69.zip
Factor out duplicated kernel dump code into dump_{start,finish}().
dump_start() and dump_finish() are responsible for writing kernel dump headers, optionally writing the key when encryption is enabled, and initializing the initial offset into the dump device. Also remove the unused dump_pad(), and make some functions static now that they're only called from kern_shutdown.c. No functional change intended. Reviewed by: cem, def Sponsored by: Dell EMC Isilon Differential Revision: https://reviews.freebsd.org/D11584
Notes
Notes: svn path=/head/; revision=322644
Diffstat (limited to 'sys/i386')
-rw-r--r--sys/i386/i386/minidump_machdep.c42
1 files changed, 5 insertions, 37 deletions
diff --git a/sys/i386/i386/minidump_machdep.c b/sys/i386/i386/minidump_machdep.c
index b50a0de82a62..30e2058a4fdb 100644
--- a/sys/i386/i386/minidump_machdep.c
+++ b/sys/i386/i386/minidump_machdep.c
@@ -47,12 +47,6 @@ __FBSDID("$FreeBSD$");
CTASSERT(sizeof(struct kerneldumpheader) == 512);
-/*
- * Don't touch the first SIZEOF_METADATA bytes on the dump device. This
- * is to protect us from metadata and to protect metadata from us.
- */
-#define SIZEOF_METADATA (64*1024)
-
#define MD_ALIGN(x) (((off_t)(x) + PAGE_MASK) & ~PAGE_MASK)
#define DEV_ALIGN(x) roundup2((off_t)(x), DEV_BSIZE)
@@ -244,22 +238,8 @@ minidumpsys(struct dumperinfo *di)
}
dumpsize += PAGE_SIZE;
- /* Determine dump offset on device. */
- if (di->mediasize < SIZEOF_METADATA + dumpsize + di->blocksize * 2 +
- kerneldumpcrypto_dumpkeysize(di->kdc)) {
- error = ENOSPC;
- goto fail;
- }
- dumplo = di->mediaoffset + di->mediasize - dumpsize;
- dumplo -= di->blocksize * 2;
- dumplo -= kerneldumpcrypto_dumpkeysize(di->kdc);
progress = dumpsize;
- /* Initialize kernel dump crypto. */
- error = kerneldumpcrypto_init(di->kdc);
- if (error)
- goto fail;
-
/* Initialize mdhdr */
bzero(&mdhdr, sizeof(mdhdr));
strcpy(mdhdr.magic, MINIDUMP_MAGIC);
@@ -278,17 +258,9 @@ minidumpsys(struct dumperinfo *di)
printf("Physical memory: %ju MB\n", ptoa((uintmax_t)physmem) / 1048576);
printf("Dumping %llu MB:", (long long)dumpsize >> 20);
- /* Dump leader */
- error = dump_write_header(di, &kdh, 0, dumplo);
- if (error)
- goto fail;
- dumplo += di->blocksize;
-
- /* Dump key */
- error = dump_write_key(di, 0, dumplo);
- if (error)
+ error = dump_start(di, &kdh, &dumplo);
+ if (error != 0)
goto fail;
- dumplo += kerneldumpcrypto_dumpkeysize(di->kdc);
/* Dump my header */
bzero(&fakept, sizeof(fakept));
@@ -362,14 +334,10 @@ minidumpsys(struct dumperinfo *di)
if (error)
goto fail;
- /* Dump trailer */
- error = dump_write_header(di, &kdh, 0, dumplo);
- if (error)
+ error = dump_finish(di, &kdh, dumplo);
+ if (error != 0)
goto fail;
- dumplo += di->blocksize;
- /* Signal completion, signoff and exit stage left. */
- dump_write(di, NULL, 0, 0, 0);
printf("\nDump complete\n");
return (0);
@@ -379,7 +347,7 @@ minidumpsys(struct dumperinfo *di)
if (error == ECANCELED)
printf("\nDump aborted\n");
- else if (error == ENOSPC)
+ else if (error == E2BIG || error == ENOSPC)
printf("\nDump failed. Partition too small.\n");
else
printf("\n** DUMP FAILED (ERROR %d) **\n", error);