Changeset View
Changeset View
Standalone View
Standalone View
sys/ddb/db_textdump.c
Show First 20 Lines • Show All 72 Lines • ▼ Show 20 Lines | |||||
#include <ddb/ddb.h> | #include <ddb/ddb.h> | ||||
#include <ddb/db_lex.h> | #include <ddb/db_lex.h> | ||||
static SYSCTL_NODE(_debug_ddb, OID_AUTO, textdump, CTLFLAG_RW, 0, | static SYSCTL_NODE(_debug_ddb, OID_AUTO, textdump, CTLFLAG_RW, 0, | ||||
"DDB textdump options"); | "DDB textdump options"); | ||||
/* | /* | ||||
* Don't touch the first SIZEOF_METADATA bytes on the dump device. This is | |||||
* to protect us from metadata and metadata from us. | |||||
*/ | |||||
#define SIZEOF_METADATA (64*1024) | |||||
/* | |||||
* Data is written out as a series of files in the ustar tar format. ustar | * Data is written out as a series of files in the ustar tar format. ustar | ||||
* is a simple streamed format consiting of a series of files prefixed with | * is a simple streamed format consiting of a series of files prefixed with | ||||
* headers, and all padded to 512-byte block boundaries, which maps | * headers, and all padded to 512-byte block boundaries, which maps | ||||
* conveniently to our requirements. | * conveniently to our requirements. | ||||
*/ | */ | ||||
struct ustar_header { | struct ustar_header { | ||||
char uh_filename[100]; | char uh_filename[100]; | ||||
char uh_mode[8]; | char uh_mode[8]; | ||||
▲ Show 20 Lines • Show All 143 Lines • ▼ Show 20 Lines | |||||
static int | static int | ||||
textdump_writeblock(struct dumperinfo *di, off_t offset, char *buffer) | textdump_writeblock(struct dumperinfo *di, off_t offset, char *buffer) | ||||
{ | { | ||||
if (textdump_error) | if (textdump_error) | ||||
return (textdump_error); | return (textdump_error); | ||||
if (offset + TEXTDUMP_BLOCKSIZE > di->mediasize) | if (offset + TEXTDUMP_BLOCKSIZE > di->mediasize) | ||||
return (EIO); | return (EIO); | ||||
if (offset < SIZEOF_METADATA) | if (offset < KERNELDUMP_METADATA_SIZE) | ||||
return (ENOSPC); | return (ENOSPC); | ||||
textdump_error = dump_write(di, buffer, 0, offset + di->mediaoffset, | textdump_error = dump_write(di, buffer, 0, offset + di->mediaoffset, | ||||
TEXTDUMP_BLOCKSIZE); | TEXTDUMP_BLOCKSIZE); | ||||
if (textdump_error) | if (textdump_error) | ||||
printf("textdump_writeblock: offset %jd, error %d\n", (intmax_t)offset, | printf("textdump_writeblock: offset %jd, error %d\n", (intmax_t)offset, | ||||
textdump_error); | textdump_error); | ||||
return (textdump_error); | return (textdump_error); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 183 Lines • ▼ Show 20 Lines | textdump_dumpsys(struct dumperinfo *di) | ||||
} | } | ||||
/* | /* | ||||
* We don't know a priori how large the dump will be, but we do know | * We don't know a priori how large the dump will be, but we do know | ||||
* that we need to reserve space for metadata and that we need two | * that we need to reserve space for metadata and that we need two | ||||
* dump headers. Also leave room for one ustar header and one block | * dump headers. Also leave room for one ustar header and one block | ||||
* of data. | * of data. | ||||
*/ | */ | ||||
if (di->mediasize < SIZEOF_METADATA + 2 * sizeof(kdh)) { | if (di->mediasize < KERNELDUMP_METADATA_SIZE + 2 * sizeof(kdh)) { | ||||
printf("Insufficient space on dump partition for minimal textdump.\n"); | printf("Insufficient space on dump partition for minimal textdump.\n"); | ||||
return; | return; | ||||
} | } | ||||
textdump_error = 0; | textdump_error = 0; | ||||
/* | /* | ||||
* Disable EKCD because we don't provide encrypted textdumps. | * Disable EKCD because we don't provide encrypted textdumps. | ||||
*/ | */ | ||||
▲ Show 20 Lines • Show All 108 Lines • Show Last 20 Lines |