Remove some unneeded subroutines for padding writes to dump devices.
Right now we only need to pad when writing kernel dump headers, so flatten three related subroutines into one. The encrypted kernel dump code already writes out its key in a dumper.blocksize-sized block. No functional change intended. Reviewed by: cem, def Sponsored by: Dell EMC Isilon Differential Revision: https://reviews.freebsd.org/D11647
This commit is contained in:
parent
01938d3666
commit
e9666bf645
@ -1151,52 +1151,26 @@ dump_write(struct dumperinfo *di, void *virtual, vm_offset_t physical,
|
||||
return (dump_raw_write(di, virtual, physical, offset, length));
|
||||
}
|
||||
|
||||
static int
|
||||
dump_pad(struct dumperinfo *di, void *virtual, size_t length, void **buf,
|
||||
size_t *size)
|
||||
{
|
||||
|
||||
if (length > di->blocksize)
|
||||
return (ENOMEM);
|
||||
|
||||
*size = di->blocksize;
|
||||
if (length == di->blocksize) {
|
||||
*buf = virtual;
|
||||
} else {
|
||||
*buf = di->blockbuf;
|
||||
memcpy(*buf, virtual, length);
|
||||
memset((uint8_t *)*buf + length, 0, di->blocksize - length);
|
||||
}
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
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;
|
||||
void *buf;
|
||||
size_t hdrsz;
|
||||
|
||||
ret = dump_raw_write_pad(di, kdh, physical, offset, sizeof(*kdh),
|
||||
&size);
|
||||
if (ret == 0 && size != di->blocksize)
|
||||
ret = EINVAL;
|
||||
return (ret);
|
||||
hdrsz = sizeof(*kdh);
|
||||
if (hdrsz > di->blocksize)
|
||||
return (ENOMEM);
|
||||
|
||||
if (hdrsz == di->blocksize)
|
||||
buf = kdh;
|
||||
else {
|
||||
buf = di->blockbuf;
|
||||
memset(buf, 0, di->blocksize);
|
||||
memcpy(buf, kdh, hdrsz);
|
||||
}
|
||||
|
||||
return (dump_raw_write(di, buf, physical, offset, di->blocksize));
|
||||
}
|
||||
|
||||
/*
|
||||
|
Loading…
Reference in New Issue
Block a user