mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2026-05-22 02:27:36 +03:00
Add convenience wrappers for common uio usage
The macOS uio struct is opaque and the API must be used, this makes the smallest changes to the code for all platforms. Reviewed-by: Matt Macy <mmacy@FreeBSD.org> Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: Jorgen Lundman <lundman@lundman.net> Closes #10412
This commit is contained in:
@@ -48,7 +48,7 @@ crypto_uio_data(crypto_data_t *data, uchar_t *buf, int len, cmd_type_t cmd,
|
||||
uchar_t *datap;
|
||||
|
||||
ASSERT(data->cd_format == CRYPTO_DATA_UIO);
|
||||
if (uiop->uio_segflg != UIO_SYSSPACE) {
|
||||
if (uio_segflg(uiop) != UIO_SYSSPACE) {
|
||||
return (CRYPTO_ARGUMENTS_BAD);
|
||||
}
|
||||
|
||||
@@ -56,12 +56,9 @@ crypto_uio_data(crypto_data_t *data, uchar_t *buf, int len, cmd_type_t cmd,
|
||||
* Jump to the first iovec containing data to be
|
||||
* processed.
|
||||
*/
|
||||
for (vec_idx = 0; vec_idx < uiop->uio_iovcnt &&
|
||||
offset >= uiop->uio_iov[vec_idx].iov_len;
|
||||
offset -= uiop->uio_iov[vec_idx++].iov_len)
|
||||
;
|
||||
offset = uio_index_at_offset(uiop, offset, &vec_idx);
|
||||
|
||||
if (vec_idx == uiop->uio_iovcnt && length > 0) {
|
||||
if (vec_idx == uio_iovcnt(uiop) && length > 0) {
|
||||
/*
|
||||
* The caller specified an offset that is larger than
|
||||
* the total size of the buffers it provided.
|
||||
@@ -69,12 +66,11 @@ crypto_uio_data(crypto_data_t *data, uchar_t *buf, int len, cmd_type_t cmd,
|
||||
return (CRYPTO_DATA_LEN_RANGE);
|
||||
}
|
||||
|
||||
while (vec_idx < uiop->uio_iovcnt && length > 0) {
|
||||
cur_len = MIN(uiop->uio_iov[vec_idx].iov_len -
|
||||
while (vec_idx < uio_iovcnt(uiop) && length > 0) {
|
||||
cur_len = MIN(uio_iovlen(uiop, vec_idx) -
|
||||
offset, length);
|
||||
|
||||
datap = (uchar_t *)(uiop->uio_iov[vec_idx].iov_base +
|
||||
offset);
|
||||
datap = (uchar_t *)(uio_iovbase(uiop, vec_idx) + offset);
|
||||
switch (cmd) {
|
||||
case COPY_FROM_DATA:
|
||||
bcopy(datap, buf, cur_len);
|
||||
@@ -101,7 +97,7 @@ crypto_uio_data(crypto_data_t *data, uchar_t *buf, int len, cmd_type_t cmd,
|
||||
offset = 0;
|
||||
}
|
||||
|
||||
if (vec_idx == uiop->uio_iovcnt && length > 0) {
|
||||
if (vec_idx == uio_iovcnt(uiop) && length > 0) {
|
||||
/*
|
||||
* The end of the specified iovec's was reached but
|
||||
* the length requested could not be processed.
|
||||
@@ -182,7 +178,7 @@ crypto_update_uio(void *ctx, crypto_data_t *input, crypto_data_t *output,
|
||||
&common_ctx->cc_iv[0]);
|
||||
}
|
||||
|
||||
if (input->cd_uio->uio_segflg != UIO_SYSSPACE) {
|
||||
if (uio_segflg(input->cd_uio) != UIO_SYSSPACE) {
|
||||
return (CRYPTO_ARGUMENTS_BAD);
|
||||
}
|
||||
|
||||
@@ -190,11 +186,8 @@ crypto_update_uio(void *ctx, crypto_data_t *input, crypto_data_t *output,
|
||||
* Jump to the first iovec containing data to be
|
||||
* processed.
|
||||
*/
|
||||
for (vec_idx = 0; vec_idx < uiop->uio_iovcnt &&
|
||||
offset >= uiop->uio_iov[vec_idx].iov_len;
|
||||
offset -= uiop->uio_iov[vec_idx++].iov_len)
|
||||
;
|
||||
if (vec_idx == uiop->uio_iovcnt && length > 0) {
|
||||
offset = uio_index_at_offset(uiop, offset, &vec_idx);
|
||||
if (vec_idx == uio_iovcnt(uiop) && length > 0) {
|
||||
/*
|
||||
* The caller specified an offset that is larger than the
|
||||
* total size of the buffers it provided.
|
||||
@@ -205,11 +198,11 @@ crypto_update_uio(void *ctx, crypto_data_t *input, crypto_data_t *output,
|
||||
/*
|
||||
* Now process the iovecs.
|
||||
*/
|
||||
while (vec_idx < uiop->uio_iovcnt && length > 0) {
|
||||
cur_len = MIN(uiop->uio_iov[vec_idx].iov_len -
|
||||
while (vec_idx < uio_iovcnt(uiop) && length > 0) {
|
||||
cur_len = MIN(uio_iovlen(uiop, vec_idx) -
|
||||
offset, length);
|
||||
|
||||
int rv = (cipher)(ctx, uiop->uio_iov[vec_idx].iov_base + offset,
|
||||
int rv = (cipher)(ctx, uio_iovbase(uiop, vec_idx) + offset,
|
||||
cur_len, output);
|
||||
|
||||
if (rv != CRYPTO_SUCCESS) {
|
||||
@@ -220,7 +213,7 @@ crypto_update_uio(void *ctx, crypto_data_t *input, crypto_data_t *output,
|
||||
offset = 0;
|
||||
}
|
||||
|
||||
if (vec_idx == uiop->uio_iovcnt && length > 0) {
|
||||
if (vec_idx == uio_iovcnt(uiop) && length > 0) {
|
||||
/*
|
||||
* The end of the specified iovec's was reached but
|
||||
* the length requested could not be processed, i.e.
|
||||
|
||||
Reference in New Issue
Block a user