Changeset View
Changeset View
Standalone View
Standalone View
head/sys/kern/kern_shutdown.c
Show First 20 Lines • Show All 1,146 Lines • ▼ Show 20 Lines | return (dump_encrypted_write(di, virtual, physical, offset, | ||||
length)); | length)); | ||||
} | } | ||||
#endif | #endif | ||||
return (dump_raw_write(di, virtual, physical, offset, length)); | return (dump_raw_write(di, virtual, physical, offset, length)); | ||||
} | } | ||||
static int | static int | ||||
dump_pad(struct dumperinfo *di, void *virtual, size_t length, void **buf, | dump_write_header(struct dumperinfo *di, struct kerneldumpheader *kdh, | ||||
size_t *size) | vm_offset_t physical, off_t offset) | ||||
{ | { | ||||
void *buf; | |||||
size_t hdrsz; | |||||
if (length > di->blocksize) | hdrsz = sizeof(*kdh); | ||||
if (hdrsz > di->blocksize) | |||||
return (ENOMEM); | return (ENOMEM); | ||||
*size = di->blocksize; | if (hdrsz == di->blocksize) | ||||
if (length == di->blocksize) { | buf = kdh; | ||||
*buf = virtual; | else { | ||||
} else { | buf = di->blockbuf; | ||||
*buf = di->blockbuf; | memset(buf, 0, di->blocksize); | ||||
memcpy(*buf, virtual, length); | memcpy(buf, kdh, hdrsz); | ||||
memset((uint8_t *)*buf + length, 0, di->blocksize - length); | |||||
} | } | ||||
return (0); | return (dump_raw_write(di, buf, physical, offset, di->blocksize)); | ||||
} | |||||
static int | |||||
dump_raw_write_pad(struct dumperinfo *di, void *virtual, vm_offset_t physical, | |||||
off_t offset, size_t length, size_t *size) | |||||
{ | |||||
void *buf; | |||||
int error; | |||||
error = dump_pad(di, virtual, length, &buf, size); | |||||
if (error != 0) | |||||
return (error); | |||||
return (dump_raw_write(di, buf, physical, offset, *size)); | |||||
} | |||||
static int | |||||
dump_write_header(struct dumperinfo *di, struct kerneldumpheader *kdh, | |||||
vm_offset_t physical, off_t offset) | |||||
{ | |||||
size_t size; | |||||
int ret; | |||||
ret = dump_raw_write_pad(di, kdh, physical, offset, sizeof(*kdh), | |||||
&size); | |||||
if (ret == 0 && size != di->blocksize) | |||||
ret = EINVAL; | |||||
return (ret); | |||||
} | } | ||||
/* | /* | ||||
* Don't touch the first SIZEOF_METADATA bytes on the dump device. This is to | * Don't touch the first SIZEOF_METADATA bytes on the dump device. This is to | ||||
* protect us from metadata and metadata from us. | * protect us from metadata and metadata from us. | ||||
*/ | */ | ||||
#define SIZEOF_METADATA (64 * 1024) | #define SIZEOF_METADATA (64 * 1024) | ||||
▲ Show 20 Lines • Show All 97 Lines • Show Last 20 Lines |