MCPcopy Create free account
hub / github.com/F-Stack/f-stack / kerneldumpcomp_write_cb

Function kerneldumpcomp_write_cb

freebsd/kern/kern_shutdown.c:1449–1478  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1447#endif /* EKCD */
1448
1449static int
1450kerneldumpcomp_write_cb(void *base, size_t length, off_t offset, void *arg)
1451{
1452 struct dumperinfo *di;
1453 size_t resid, rlength;
1454 int error;
1455
1456 di = arg;
1457
1458 if (length % di->blocksize != 0) {
1459 /*
1460 * This must be the final write after flushing the compression
1461 * stream. Write as many full blocks as possible and stash the
1462 * residual data in the dumper's block buffer. It will be
1463 * padded and written in dump_finish().
1464 */
1465 rlength = rounddown(length, di->blocksize);
1466 if (rlength != 0) {
1467 error = _dump_append(di, base, 0, rlength);
1468 if (error != 0)
1469 return (error);
1470 }
1471 resid = length - rlength;
1472 memmove(di->blockbuf, (uint8_t *)base + rlength, resid);
1473 bzero((uint8_t *)di->blockbuf + resid, di->blocksize - resid);
1474 di->kdcomp->kdc_resid = resid;
1475 return (EAGAIN);
1476 }
1477 return (_dump_append(di, base, 0, length));
1478}
1479
1480/*
1481 * Write kernel dump headers at the beginning and end of the dump extent.

Callers

nothing calls this directly

Calls 3

_dump_appendFunction · 0.85
bzeroFunction · 0.85
memmoveFunction · 0.50

Tested by

no test coverage detected