/* * ssread - send stream read. * * Read while computing incremental checksum */ static size_t ssread(void *buf, size_t len, zio_cksum_t *cksum) { size_t outlen; if ((outlen = fread(buf, len, 1, send_stream)) == 0) return (0); if (do_cksum) { if (do_byteswap) fletcher_4_incremental_byteswap(buf, len, cksum); else fletcher_4_incremental_native(buf, len, cksum); } total_stream_len += len; return (outlen); }
static int dump_bytes(dmu_sendarg_t *dsp, void *buf, int len) { dsl_dataset_t *ds = dsp->dsa_os->os_dsl_dataset; ssize_t resid; /* have to get resid to get detailed errno */ ASSERT3U(len % 8, ==, 0); fletcher_4_incremental_native(buf, len, &dsp->dsa_zc); dsp->dsa_err = vn_rdwr(UIO_WRITE, dsp->dsa_vp, (caddr_t)buf, len, 0, UIO_SYSSPACE, FAPPEND, RLIM64_INFINITY, CRED(), &resid); mutex_enter(&ds->ds_sendstream_lock); *dsp->dsa_off += len; mutex_exit(&ds->ds_sendstream_lock); return (dsp->dsa_err); }
void fletcher_4_native(const void *buf, uint64_t size, zio_cksum_t *zcp) { const fletcher_4_ops_t *ops; uint64_t p2size = P2ALIGN(size, 64); ASSERT(IS_P2ALIGNED(size, sizeof (uint32_t))); if (size == 0) { ZIO_SET_CHECKSUM(zcp, 0, 0, 0, 0); } else if (p2size == 0) { ops = &fletcher_4_scalar_ops; fletcher_4_native_impl(ops, buf, size, zcp); } else { ops = fletcher_4_impl_get(); fletcher_4_native_impl(ops, buf, p2size, zcp); if (p2size < size) fletcher_4_incremental_native((char *)buf + p2size, size - p2size, zcp); } }