Date: Fri, 18 Aug 2017 04:07:26 +0000 (UTC) From: Mark Johnston <markj@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r322646 - head/sys/kern Message-ID: <201708180407.v7I47Qhd011620@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: markj Date: Fri Aug 18 04:07:25 2017 New Revision: 322646 URL: https://svnweb.freebsd.org/changeset/base/322646 Log: 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 Modified: head/sys/kern/kern_shutdown.c Modified: head/sys/kern/kern_shutdown.c ============================================================================== --- head/sys/kern/kern_shutdown.c Fri Aug 18 04:04:09 2017 (r322645) +++ head/sys/kern/kern_shutdown.c Fri Aug 18 04:07:25 2017 (r322646) @@ -1152,51 +1152,25 @@ dump_write(struct dumperinfo *di, void *virtual, vm_of } static int -dump_pad(struct dumperinfo *di, void *virtual, size_t length, void **buf, - size_t *size) +dump_write_header(struct dumperinfo *di, struct kerneldumpheader *kdh, + 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); - *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); + if (hdrsz == di->blocksize) + buf = kdh; + else { + buf = di->blockbuf; + memset(buf, 0, di->blocksize); + memcpy(buf, kdh, hdrsz); } - 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; - - ret = dump_raw_write_pad(di, kdh, physical, offset, sizeof(*kdh), - &size); - if (ret == 0 && size != di->blocksize) - ret = EINVAL; - return (ret); + return (dump_raw_write(di, buf, physical, offset, di->blocksize)); } /*
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201708180407.v7I47Qhd011620>