Collect N identical (or near identical) mkdumpheader() implementations into
one, as threatened in the comment. Textdump magic can be passed in.
This commit is contained in:
parent
b2ce972537
commit
e6592ee55c
@ -105,27 +105,6 @@ md_pa_next(struct md_pa *mdp)
|
|||||||
return (mdp);
|
return (mdp);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* XXX should be MI */
|
|
||||||
static void
|
|
||||||
mkdumpheader(struct kerneldumpheader *kdh, uint32_t archver, uint64_t dumplen,
|
|
||||||
uint32_t blksz)
|
|
||||||
{
|
|
||||||
|
|
||||||
bzero(kdh, sizeof(*kdh));
|
|
||||||
strncpy(kdh->magic, KERNELDUMPMAGIC, sizeof(kdh->magic));
|
|
||||||
strncpy(kdh->architecture, MACHINE_ARCH, sizeof(kdh->architecture));
|
|
||||||
kdh->version = htod32(KERNELDUMPVERSION);
|
|
||||||
kdh->architectureversion = htod32(archver);
|
|
||||||
kdh->dumplength = htod64(dumplen);
|
|
||||||
kdh->dumptime = htod64(time_second);
|
|
||||||
kdh->blocksize = htod32(blksz);
|
|
||||||
strncpy(kdh->hostname, G_hostname, sizeof(kdh->hostname));
|
|
||||||
strncpy(kdh->versionstring, version, sizeof(kdh->versionstring));
|
|
||||||
if (panicstr != NULL)
|
|
||||||
strncpy(kdh->panicstring, panicstr, sizeof(kdh->panicstring));
|
|
||||||
kdh->parity = kerneldump_parity(kdh);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
buf_write(struct dumperinfo *di, char *ptr, size_t sz)
|
buf_write(struct dumperinfo *di, char *ptr, size_t sz)
|
||||||
{
|
{
|
||||||
@ -326,7 +305,7 @@ dumpsys(struct dumperinfo *di)
|
|||||||
dumplo = di->mediaoffset + di->mediasize - dumpsize;
|
dumplo = di->mediaoffset + di->mediasize - dumpsize;
|
||||||
dumplo -= sizeof(kdh) * 2;
|
dumplo -= sizeof(kdh) * 2;
|
||||||
|
|
||||||
mkdumpheader(&kdh, KERNELDUMP_AMD64_VERSION, dumpsize, di->blocksize);
|
mkdumpheader(&kdh, KERNELDUMPMAGIC, KERNELDUMP_AMD64_VERSION, dumpsize, di->blocksize);
|
||||||
|
|
||||||
printf("Dumping %llu MB (%d chunks)\n", (long long)dumpsize >> 20,
|
printf("Dumping %llu MB (%d chunks)\n", (long long)dumpsize >> 20,
|
||||||
ehdr.e_phnum);
|
ehdr.e_phnum);
|
||||||
|
@ -81,27 +81,6 @@ is_dumpable(vm_paddr_t pa)
|
|||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* XXX should be MI */
|
|
||||||
static void
|
|
||||||
mkdumpheader(struct kerneldumpheader *kdh, uint32_t archver, uint64_t dumplen,
|
|
||||||
uint32_t blksz)
|
|
||||||
{
|
|
||||||
|
|
||||||
bzero(kdh, sizeof(*kdh));
|
|
||||||
strncpy(kdh->magic, KERNELDUMPMAGIC, sizeof(kdh->magic));
|
|
||||||
strncpy(kdh->architecture, MACHINE_ARCH, sizeof(kdh->architecture));
|
|
||||||
kdh->version = htod32(KERNELDUMPVERSION);
|
|
||||||
kdh->architectureversion = htod32(archver);
|
|
||||||
kdh->dumplength = htod64(dumplen);
|
|
||||||
kdh->dumptime = htod64(time_second);
|
|
||||||
kdh->blocksize = htod32(blksz);
|
|
||||||
strncpy(kdh->hostname, G_hostname, sizeof(kdh->hostname));
|
|
||||||
strncpy(kdh->versionstring, version, sizeof(kdh->versionstring));
|
|
||||||
if (panicstr != NULL)
|
|
||||||
strncpy(kdh->panicstring, panicstr, sizeof(kdh->panicstring));
|
|
||||||
kdh->parity = kerneldump_parity(kdh);
|
|
||||||
}
|
|
||||||
|
|
||||||
#define PG2MB(pgs) (((pgs) + (1 << 8) - 1) >> 8)
|
#define PG2MB(pgs) (((pgs) + (1 << 8) - 1) >> 8)
|
||||||
|
|
||||||
static int
|
static int
|
||||||
@ -284,7 +263,7 @@ minidumpsys(struct dumperinfo *di)
|
|||||||
mdhdr.dmapbase = DMAP_MIN_ADDRESS;
|
mdhdr.dmapbase = DMAP_MIN_ADDRESS;
|
||||||
mdhdr.dmapend = DMAP_MAX_ADDRESS;
|
mdhdr.dmapend = DMAP_MAX_ADDRESS;
|
||||||
|
|
||||||
mkdumpheader(&kdh, KERNELDUMP_AMD64_VERSION, dumpsize, di->blocksize);
|
mkdumpheader(&kdh, KERNELDUMPMAGIC, KERNELDUMP_AMD64_VERSION, dumpsize, di->blocksize);
|
||||||
|
|
||||||
printf("Physical memory: %ju MB\n", ptoa((uintmax_t)physmem) / 1048576);
|
printf("Physical memory: %ju MB\n", ptoa((uintmax_t)physmem) / 1048576);
|
||||||
printf("Dumping %llu MB:", (long long)dumpsize >> 20);
|
printf("Dumping %llu MB:", (long long)dumpsize >> 20);
|
||||||
|
@ -103,27 +103,6 @@ md_pa_next(struct md_pa *mdp)
|
|||||||
return (mdp);
|
return (mdp);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* XXX should be MI */
|
|
||||||
static void
|
|
||||||
mkdumpheader(struct kerneldumpheader *kdh, uint32_t archver, uint64_t dumplen,
|
|
||||||
uint32_t blksz)
|
|
||||||
{
|
|
||||||
|
|
||||||
bzero(kdh, sizeof(*kdh));
|
|
||||||
strncpy(kdh->magic, KERNELDUMPMAGIC, sizeof(kdh->magic));
|
|
||||||
strncpy(kdh->architecture, MACHINE_ARCH, sizeof(kdh->architecture));
|
|
||||||
kdh->version = htod32(KERNELDUMPVERSION);
|
|
||||||
kdh->architectureversion = htod32(archver);
|
|
||||||
kdh->dumplength = htod64(dumplen);
|
|
||||||
kdh->dumptime = htod64(time_second);
|
|
||||||
kdh->blocksize = htod32(blksz);
|
|
||||||
strncpy(kdh->hostname, G_hostname, sizeof(kdh->hostname));
|
|
||||||
strncpy(kdh->versionstring, version, sizeof(kdh->versionstring));
|
|
||||||
if (panicstr != NULL)
|
|
||||||
strncpy(kdh->panicstring, panicstr, sizeof(kdh->panicstring));
|
|
||||||
kdh->parity = kerneldump_parity(kdh);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
buf_write(struct dumperinfo *di, char *ptr, size_t sz)
|
buf_write(struct dumperinfo *di, char *ptr, size_t sz)
|
||||||
{
|
{
|
||||||
@ -325,7 +304,7 @@ dumpsys(struct dumperinfo *di)
|
|||||||
dumplo = di->mediaoffset + di->mediasize - dumpsize;
|
dumplo = di->mediaoffset + di->mediasize - dumpsize;
|
||||||
dumplo -= sizeof(kdh) * 2;
|
dumplo -= sizeof(kdh) * 2;
|
||||||
|
|
||||||
mkdumpheader(&kdh, KERNELDUMP_ARM_VERSION, dumpsize, di->blocksize);
|
mkdumpheader(&kdh, KERNELDUMPMAGIC, KERNELDUMP_ARM_VERSION, dumpsize, di->blocksize);
|
||||||
|
|
||||||
printf("Dumping %llu MB (%d chunks)\n", (long long)dumpsize >> 20,
|
printf("Dumping %llu MB (%d chunks)\n", (long long)dumpsize >> 20,
|
||||||
ehdr.e_phnum);
|
ehdr.e_phnum);
|
||||||
|
@ -176,30 +176,6 @@ static int textdump_error; /* Carried write error, if any. */
|
|||||||
char textdump_block_buffer[TEXTDUMP_BLOCKSIZE];
|
char textdump_block_buffer[TEXTDUMP_BLOCKSIZE];
|
||||||
static struct kerneldumpheader kdh;
|
static struct kerneldumpheader kdh;
|
||||||
|
|
||||||
/*
|
|
||||||
* Text dumps are prefixed with a normal kernel dump header but with a
|
|
||||||
* different magic number to allow them to be uniquely identified.
|
|
||||||
*/
|
|
||||||
static void
|
|
||||||
mkdumpheader(struct kerneldumpheader *kdh, uint32_t archver,
|
|
||||||
uint64_t dumplen, uint32_t blksz)
|
|
||||||
{
|
|
||||||
|
|
||||||
bzero(kdh, sizeof(*kdh));
|
|
||||||
strncpy(kdh->magic, TEXTDUMPMAGIC, sizeof(kdh->magic));
|
|
||||||
strncpy(kdh->architecture, MACHINE_ARCH, sizeof(kdh->architecture));
|
|
||||||
kdh->version = htod32(KERNELDUMPVERSION);
|
|
||||||
kdh->architectureversion = htod32(archver);
|
|
||||||
kdh->dumplength = htod64(dumplen);
|
|
||||||
kdh->dumptime = htod64(time_second);
|
|
||||||
kdh->blocksize = htod32(blksz);
|
|
||||||
strncpy(kdh->hostname, G_hostname, sizeof(kdh->hostname));
|
|
||||||
strncpy(kdh->versionstring, version, sizeof(kdh->versionstring));
|
|
||||||
if (panicstr != NULL)
|
|
||||||
strncpy(kdh->panicstring, panicstr, sizeof(kdh->panicstring));
|
|
||||||
kdh->parity = kerneldump_parity(kdh);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Calculate and fill in the checksum for a ustar header.
|
* Calculate and fill in the checksum for a ustar header.
|
||||||
*/
|
*/
|
||||||
@ -468,7 +444,7 @@ textdump_dumpsys(struct dumperinfo *di)
|
|||||||
*/
|
*/
|
||||||
textdump_offset = di->mediasize - sizeof(kdh);
|
textdump_offset = di->mediasize - sizeof(kdh);
|
||||||
textdump_saveoff(&trailer_offset);
|
textdump_saveoff(&trailer_offset);
|
||||||
mkdumpheader(&kdh, KERNELDUMP_TEXT_VERSION, 0, TEXTDUMP_BLOCKSIZE);
|
mkdumpheader(&kdh, TEXTDUMPMAGIC, KERNELDUMP_TEXT_VERSION, 0, TEXTDUMP_BLOCKSIZE);
|
||||||
(void)textdump_writenextblock(di, (char *)&kdh);
|
(void)textdump_writenextblock(di, (char *)&kdh);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -493,7 +469,7 @@ textdump_dumpsys(struct dumperinfo *di)
|
|||||||
* size.
|
* size.
|
||||||
*/
|
*/
|
||||||
dumplen = trailer_offset - (textdump_offset + TEXTDUMP_BLOCKSIZE);
|
dumplen = trailer_offset - (textdump_offset + TEXTDUMP_BLOCKSIZE);
|
||||||
mkdumpheader(&kdh, KERNELDUMP_TEXT_VERSION, dumplen,
|
mkdumpheader(&kdh, TEXTDUMPMAGIC, KERNELDUMP_TEXT_VERSION, dumplen,
|
||||||
TEXTDUMP_BLOCKSIZE);
|
TEXTDUMP_BLOCKSIZE);
|
||||||
(void)textdump_writenextblock(di, (char *)&kdh);
|
(void)textdump_writenextblock(di, (char *)&kdh);
|
||||||
textdump_restoreoff(trailer_offset);
|
textdump_restoreoff(trailer_offset);
|
||||||
|
@ -105,27 +105,6 @@ md_pa_next(struct md_pa *mdp)
|
|||||||
return (mdp);
|
return (mdp);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* XXX should be MI */
|
|
||||||
static void
|
|
||||||
mkdumpheader(struct kerneldumpheader *kdh, uint32_t archver, uint64_t dumplen,
|
|
||||||
uint32_t blksz)
|
|
||||||
{
|
|
||||||
|
|
||||||
bzero(kdh, sizeof(*kdh));
|
|
||||||
strncpy(kdh->magic, KERNELDUMPMAGIC, sizeof(kdh->magic));
|
|
||||||
strncpy(kdh->architecture, MACHINE_ARCH, sizeof(kdh->architecture));
|
|
||||||
kdh->version = htod32(KERNELDUMPVERSION);
|
|
||||||
kdh->architectureversion = htod32(archver);
|
|
||||||
kdh->dumplength = htod64(dumplen);
|
|
||||||
kdh->dumptime = htod64(time_second);
|
|
||||||
kdh->blocksize = htod32(blksz);
|
|
||||||
strncpy(kdh->hostname, G_hostname, sizeof(kdh->hostname));
|
|
||||||
strncpy(kdh->versionstring, version, sizeof(kdh->versionstring));
|
|
||||||
if (panicstr != NULL)
|
|
||||||
strncpy(kdh->panicstring, panicstr, sizeof(kdh->panicstring));
|
|
||||||
kdh->parity = kerneldump_parity(kdh);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
buf_write(struct dumperinfo *di, char *ptr, size_t sz)
|
buf_write(struct dumperinfo *di, char *ptr, size_t sz)
|
||||||
{
|
{
|
||||||
@ -326,7 +305,7 @@ dumpsys(struct dumperinfo *di)
|
|||||||
dumplo = di->mediaoffset + di->mediasize - dumpsize;
|
dumplo = di->mediaoffset + di->mediasize - dumpsize;
|
||||||
dumplo -= sizeof(kdh) * 2;
|
dumplo -= sizeof(kdh) * 2;
|
||||||
|
|
||||||
mkdumpheader(&kdh, KERNELDUMP_I386_VERSION, dumpsize, di->blocksize);
|
mkdumpheader(&kdh, KERNELDUMPMAGIC, KERNELDUMP_I386_VERSION, dumpsize, di->blocksize);
|
||||||
|
|
||||||
printf("Dumping %llu MB (%d chunks)\n", (long long)dumpsize >> 20,
|
printf("Dumping %llu MB (%d chunks)\n", (long long)dumpsize >> 20,
|
||||||
ehdr.e_phnum);
|
ehdr.e_phnum);
|
||||||
|
@ -79,27 +79,6 @@ is_dumpable(vm_paddr_t pa)
|
|||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* XXX should be MI */
|
|
||||||
static void
|
|
||||||
mkdumpheader(struct kerneldumpheader *kdh, uint32_t archver, uint64_t dumplen,
|
|
||||||
uint32_t blksz)
|
|
||||||
{
|
|
||||||
|
|
||||||
bzero(kdh, sizeof(*kdh));
|
|
||||||
strncpy(kdh->magic, KERNELDUMPMAGIC, sizeof(kdh->magic));
|
|
||||||
strncpy(kdh->architecture, MACHINE_ARCH, sizeof(kdh->architecture));
|
|
||||||
kdh->version = htod32(KERNELDUMPVERSION);
|
|
||||||
kdh->architectureversion = htod32(archver);
|
|
||||||
kdh->dumplength = htod64(dumplen);
|
|
||||||
kdh->dumptime = htod64(time_second);
|
|
||||||
kdh->blocksize = htod32(blksz);
|
|
||||||
strncpy(kdh->hostname, G_hostname, sizeof(kdh->hostname));
|
|
||||||
strncpy(kdh->versionstring, version, sizeof(kdh->versionstring));
|
|
||||||
if (panicstr != NULL)
|
|
||||||
strncpy(kdh->panicstring, panicstr, sizeof(kdh->panicstring));
|
|
||||||
kdh->parity = kerneldump_parity(kdh);
|
|
||||||
}
|
|
||||||
|
|
||||||
#define PG2MB(pgs) (((pgs) + (1 << 8) - 1) >> 8)
|
#define PG2MB(pgs) (((pgs) + (1 << 8) - 1) >> 8)
|
||||||
|
|
||||||
static int
|
static int
|
||||||
@ -280,7 +259,7 @@ minidumpsys(struct dumperinfo *di)
|
|||||||
mdhdr.paemode = 1;
|
mdhdr.paemode = 1;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
mkdumpheader(&kdh, KERNELDUMP_I386_VERSION, dumpsize, di->blocksize);
|
mkdumpheader(&kdh, KERNELDUMPMAGIC, KERNELDUMP_I386_VERSION, dumpsize, di->blocksize);
|
||||||
|
|
||||||
printf("Physical memory: %ju MB\n", ptoa((uintmax_t)physmem) / 1048576);
|
printf("Physical memory: %ju MB\n", ptoa((uintmax_t)physmem) / 1048576);
|
||||||
printf("Dumping %llu MB:", (long long)dumpsize >> 20);
|
printf("Dumping %llu MB:", (long long)dumpsize >> 20);
|
||||||
|
@ -60,27 +60,6 @@ static off_t dumplo, fileofs;
|
|||||||
static char buffer[DEV_BSIZE];
|
static char buffer[DEV_BSIZE];
|
||||||
static size_t fragsz;
|
static size_t fragsz;
|
||||||
|
|
||||||
/* XXX should be MI */
|
|
||||||
static void
|
|
||||||
mkdumpheader(struct kerneldumpheader *kdh, uint32_t archver, uint64_t dumplen,
|
|
||||||
uint32_t blksz)
|
|
||||||
{
|
|
||||||
|
|
||||||
bzero(kdh, sizeof(*kdh));
|
|
||||||
strncpy(kdh->magic, KERNELDUMPMAGIC, sizeof(kdh->magic));
|
|
||||||
strncpy(kdh->architecture, MACHINE_ARCH, sizeof(kdh->architecture));
|
|
||||||
kdh->version = htod32(KERNELDUMPVERSION);
|
|
||||||
kdh->architectureversion = htod32(archver);
|
|
||||||
kdh->dumplength = htod64(dumplen);
|
|
||||||
kdh->dumptime = htod64(time_second);
|
|
||||||
kdh->blocksize = htod32(blksz);
|
|
||||||
strncpy(kdh->hostname, G_hostname, sizeof(kdh->hostname));
|
|
||||||
strncpy(kdh->versionstring, version, sizeof(kdh->versionstring));
|
|
||||||
if (panicstr != NULL)
|
|
||||||
strncpy(kdh->panicstring, panicstr, sizeof(kdh->panicstring));
|
|
||||||
kdh->parity = kerneldump_parity(kdh);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
buf_write(struct dumperinfo *di, char *ptr, size_t sz)
|
buf_write(struct dumperinfo *di, char *ptr, size_t sz)
|
||||||
{
|
{
|
||||||
@ -261,7 +240,7 @@ dumpsys(struct dumperinfo *di)
|
|||||||
dumplo = di->mediaoffset + di->mediasize - dumpsize;
|
dumplo = di->mediaoffset + di->mediasize - dumpsize;
|
||||||
dumplo -= sizeof(kdh) * 2;
|
dumplo -= sizeof(kdh) * 2;
|
||||||
|
|
||||||
mkdumpheader(&kdh, KERNELDUMP_IA64_VERSION, dumpsize, di->blocksize);
|
mkdumpheader(&kdh, KERNELDUMPMAGIC, KERNELDUMP_IA64_VERSION, dumpsize, di->blocksize);
|
||||||
|
|
||||||
printf("Dumping %llu MB (%d chunks)\n", (long long)dumpsize >> 20,
|
printf("Dumping %llu MB (%d chunks)\n", (long long)dumpsize >> 20,
|
||||||
ehdr.e_phnum);
|
ehdr.e_phnum);
|
||||||
|
@ -53,6 +53,7 @@ __FBSDID("$FreeBSD$");
|
|||||||
#include <sys/eventhandler.h>
|
#include <sys/eventhandler.h>
|
||||||
#include <sys/kdb.h>
|
#include <sys/kdb.h>
|
||||||
#include <sys/kernel.h>
|
#include <sys/kernel.h>
|
||||||
|
#include <sys/kerneldump.h>
|
||||||
#include <sys/kthread.h>
|
#include <sys/kthread.h>
|
||||||
#include <sys/malloc.h>
|
#include <sys/malloc.h>
|
||||||
#include <sys/mount.h>
|
#include <sys/mount.h>
|
||||||
@ -64,6 +65,7 @@ __FBSDID("$FreeBSD$");
|
|||||||
#include <sys/smp.h> /* smp_active */
|
#include <sys/smp.h> /* smp_active */
|
||||||
#include <sys/sysctl.h>
|
#include <sys/sysctl.h>
|
||||||
#include <sys/sysproto.h>
|
#include <sys/sysproto.h>
|
||||||
|
#include <sys/vimage.h>
|
||||||
|
|
||||||
#include <ddb/ddb.h>
|
#include <ddb/ddb.h>
|
||||||
|
|
||||||
@ -686,3 +688,23 @@ dumpsys(struct dumperinfo *di __unused)
|
|||||||
printf("Kernel dumps not implemented on this architecture\n");
|
printf("Kernel dumps not implemented on this architecture\n");
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
void
|
||||||
|
mkdumpheader(struct kerneldumpheader *kdh, char *magic, uint32_t archver,
|
||||||
|
uint64_t dumplen, uint32_t blksz)
|
||||||
|
{
|
||||||
|
|
||||||
|
bzero(kdh, sizeof(*kdh));
|
||||||
|
strncpy(kdh->magic, magic, sizeof(kdh->magic));
|
||||||
|
strncpy(kdh->architecture, MACHINE_ARCH, sizeof(kdh->architecture));
|
||||||
|
kdh->version = htod32(KERNELDUMPVERSION);
|
||||||
|
kdh->architectureversion = htod32(archver);
|
||||||
|
kdh->dumplength = htod64(dumplen);
|
||||||
|
kdh->dumptime = htod64(time_second);
|
||||||
|
kdh->blocksize = htod32(blksz);
|
||||||
|
strncpy(kdh->hostname, G_hostname, sizeof(kdh->hostname));
|
||||||
|
strncpy(kdh->versionstring, version, sizeof(kdh->versionstring));
|
||||||
|
if (panicstr != NULL)
|
||||||
|
strncpy(kdh->panicstring, panicstr, sizeof(kdh->panicstring));
|
||||||
|
kdh->parity = kerneldump_parity(kdh);
|
||||||
|
}
|
||||||
|
@ -56,27 +56,6 @@ static vm_size_t fragsz;
|
|||||||
|
|
||||||
#define MAXDUMPSZ (MAXDUMPPGS << PAGE_SHIFT)
|
#define MAXDUMPSZ (MAXDUMPPGS << PAGE_SHIFT)
|
||||||
|
|
||||||
/* XXX should be MI */
|
|
||||||
static void
|
|
||||||
mkdumpheader(struct kerneldumpheader *kdh, uint32_t archver, uint64_t dumplen,
|
|
||||||
uint32_t blksz)
|
|
||||||
{
|
|
||||||
|
|
||||||
bzero(kdh, sizeof(*kdh));
|
|
||||||
strncpy(kdh->magic, KERNELDUMPMAGIC, sizeof(kdh->magic));
|
|
||||||
strncpy(kdh->architecture, MACHINE_ARCH, sizeof(kdh->architecture));
|
|
||||||
kdh->version = htod32(KERNELDUMPVERSION);
|
|
||||||
kdh->architectureversion = htod32(archver);
|
|
||||||
kdh->dumplength = htod64(dumplen);
|
|
||||||
kdh->dumptime = htod64(time_second);
|
|
||||||
kdh->blocksize = htod32(blksz);
|
|
||||||
strncpy(kdh->hostname, G_hostname, sizeof(kdh->hostname));
|
|
||||||
strncpy(kdh->versionstring, version, sizeof(kdh->versionstring));
|
|
||||||
if (panicstr != NULL)
|
|
||||||
strncpy(kdh->panicstring, panicstr, sizeof(kdh->panicstring));
|
|
||||||
kdh->parity = kerneldump_parity(kdh);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
buf_write(struct dumperinfo *di, char *ptr, size_t sz)
|
buf_write(struct dumperinfo *di, char *ptr, size_t sz)
|
||||||
{
|
{
|
||||||
@ -191,7 +170,7 @@ dumpsys(struct dumperinfo *di)
|
|||||||
/* Determine dump offset on device. */
|
/* Determine dump offset on device. */
|
||||||
dumplo = di->mediaoffset + di->mediasize - totsize;
|
dumplo = di->mediaoffset + di->mediasize - totsize;
|
||||||
|
|
||||||
mkdumpheader(&kdh, KERNELDUMP_SPARC64_VERSION, size, di->blocksize);
|
mkdumpheader(&kdh, KERNELDUMPMAGIC, KERNELDUMP_SPARC64_VERSION, size, di->blocksize);
|
||||||
|
|
||||||
printf("Dumping %lu MB (%d chunks)\n", (u_long)(size >> 20), nreg);
|
printf("Dumping %lu MB (%d chunks)\n", (u_long)(size >> 20), nreg);
|
||||||
|
|
||||||
|
@ -57,27 +57,6 @@ static vm_size_t fragsz;
|
|||||||
|
|
||||||
#define MAXDUMPSZ (MAXDUMPPGS << PAGE_SHIFT)
|
#define MAXDUMPSZ (MAXDUMPPGS << PAGE_SHIFT)
|
||||||
|
|
||||||
/* XXX should be MI */
|
|
||||||
static void
|
|
||||||
mkdumpheader(struct kerneldumpheader *kdh, uint32_t archver, uint64_t dumplen,
|
|
||||||
uint32_t blksz)
|
|
||||||
{
|
|
||||||
|
|
||||||
bzero(kdh, sizeof(*kdh));
|
|
||||||
strncpy(kdh->magic, KERNELDUMPMAGIC, sizeof(kdh->magic));
|
|
||||||
strncpy(kdh->architecture, MACHINE_ARCH, sizeof(kdh->architecture));
|
|
||||||
kdh->version = htod32(KERNELDUMPVERSION);
|
|
||||||
kdh->architectureversion = htod32(archver);
|
|
||||||
kdh->dumplength = htod64(dumplen);
|
|
||||||
kdh->dumptime = htod64(time_second);
|
|
||||||
kdh->blocksize = htod32(blksz);
|
|
||||||
strncpy(kdh->hostname, G_hostname, sizeof(kdh->hostname));
|
|
||||||
strncpy(kdh->versionstring, version, sizeof(kdh->versionstring));
|
|
||||||
if (panicstr != NULL)
|
|
||||||
strncpy(kdh->panicstring, panicstr, sizeof(kdh->panicstring));
|
|
||||||
kdh->parity = kerneldump_parity(kdh);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
buf_write(struct dumperinfo *di, char *ptr, size_t sz)
|
buf_write(struct dumperinfo *di, char *ptr, size_t sz)
|
||||||
{
|
{
|
||||||
@ -194,7 +173,7 @@ dumpsys(struct dumperinfo *di)
|
|||||||
/* Determine dump offset on device. */
|
/* Determine dump offset on device. */
|
||||||
dumplo = di->mediaoffset + di->mediasize - totsize;
|
dumplo = di->mediaoffset + di->mediasize - totsize;
|
||||||
|
|
||||||
mkdumpheader(&kdh, KERNELDUMP_SPARC64_VERSION, size, di->blocksize);
|
mkdumpheader(&kdh, KERNELDUMPMAGIC, KERNELDUMP_SPARC64_VERSION, size, di->blocksize);
|
||||||
|
|
||||||
printf("Dumping %lu MB (%d chunks)\n", (u_long)(size >> 20), nreg);
|
printf("Dumping %lu MB (%d chunks)\n", (u_long)(size >> 20), nreg);
|
||||||
|
|
||||||
|
@ -98,4 +98,9 @@ kerneldump_parity(struct kerneldumpheader *kdhp)
|
|||||||
return (parity);
|
return (parity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef _KERNEL
|
||||||
|
void mkdumpheader(struct kerneldumpheader *kdh, char *magic, uint32_t archver,
|
||||||
|
uint64_t dumplen, uint32_t blksz);
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif /* _SYS_KERNELDUMP_H */
|
#endif /* _SYS_KERNELDUMP_H */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user