Extending FreeBSD UIO Struct

In FreeBSD the struct uio was just a typedef to uio_t. In order to
extend this struct, outside of the definition for the struct uio, the
struct uio has been embedded inside of a uio_t struct.

Also renamed all the uio_* interfaces to be zfs_uio_* to make it clear
this is a ZFS interface.

Reviewed-by: Ryan Moeller <ryan@iXsystems.com>
Reviewed-by: Jorgen Lundman <lundman@lundman.net>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Brian Atkinson <batkinson@lanl.gov>
Closes #11438
This commit is contained in:
Brian Atkinson
2021-01-20 22:27:30 -07:00
committed by GitHub
parent e2af2acce3
commit d0cd9a5cc6
37 changed files with 521 additions and 457 deletions
+24 -24
View File
@@ -296,15 +296,15 @@ sha2_digest_update_uio(SHA2_CTX *sha2_ctx, crypto_data_t *data)
size_t cur_len;
/* we support only kernel buffer */
if (uio_segflg(data->cd_uio) != UIO_SYSSPACE)
if (zfs_uio_segflg(data->cd_uio) != UIO_SYSSPACE)
return (CRYPTO_ARGUMENTS_BAD);
/*
* Jump to the first iovec containing data to be
* digested.
*/
offset = uio_index_at_offset(data->cd_uio, offset, &vec_idx);
if (vec_idx == uio_iovcnt(data->cd_uio)) {
offset = zfs_uio_index_at_offset(data->cd_uio, offset, &vec_idx);
if (vec_idx == zfs_uio_iovcnt(data->cd_uio)) {
/*
* The caller specified an offset that is larger than the
* total size of the buffers it provided.
@@ -315,18 +315,18 @@ sha2_digest_update_uio(SHA2_CTX *sha2_ctx, crypto_data_t *data)
/*
* Now do the digesting on the iovecs.
*/
while (vec_idx < uio_iovcnt(data->cd_uio) && length > 0) {
cur_len = MIN(uio_iovlen(data->cd_uio, vec_idx) -
while (vec_idx < zfs_uio_iovcnt(data->cd_uio) && length > 0) {
cur_len = MIN(zfs_uio_iovlen(data->cd_uio, vec_idx) -
offset, length);
SHA2Update(sha2_ctx, (uint8_t *)uio_iovbase(data->cd_uio,
SHA2Update(sha2_ctx, (uint8_t *)zfs_uio_iovbase(data->cd_uio,
vec_idx) + offset, cur_len);
length -= cur_len;
vec_idx++;
offset = 0;
}
if (vec_idx == uio_iovcnt(data->cd_uio) && length > 0) {
if (vec_idx == zfs_uio_iovcnt(data->cd_uio) && length > 0) {
/*
* The end of the specified iovec's was reached but
* the length requested could not be processed, i.e.
@@ -353,15 +353,15 @@ sha2_digest_final_uio(SHA2_CTX *sha2_ctx, crypto_data_t *digest,
uint_t vec_idx = 0;
/* we support only kernel buffer */
if (uio_segflg(digest->cd_uio) != UIO_SYSSPACE)
if (zfs_uio_segflg(digest->cd_uio) != UIO_SYSSPACE)
return (CRYPTO_ARGUMENTS_BAD);
/*
* Jump to the first iovec containing ptr to the digest to
* be returned.
*/
offset = uio_index_at_offset(digest->cd_uio, offset, &vec_idx);
if (vec_idx == uio_iovcnt(digest->cd_uio)) {
offset = zfs_uio_index_at_offset(digest->cd_uio, offset, &vec_idx);
if (vec_idx == zfs_uio_iovcnt(digest->cd_uio)) {
/*
* The caller specified an offset that is
* larger than the total size of the buffers
@@ -371,7 +371,7 @@ sha2_digest_final_uio(SHA2_CTX *sha2_ctx, crypto_data_t *digest,
}
if (offset + digest_len <=
uio_iovlen(digest->cd_uio, vec_idx)) {
zfs_uio_iovlen(digest->cd_uio, vec_idx)) {
/*
* The computed SHA2 digest will fit in the current
* iovec.
@@ -387,11 +387,11 @@ sha2_digest_final_uio(SHA2_CTX *sha2_ctx, crypto_data_t *digest,
*/
SHA2Final(digest_scratch, sha2_ctx);
bcopy(digest_scratch, (uchar_t *)uio_iovbase(digest->
cd_uio, vec_idx) + offset,
bcopy(digest_scratch, (uchar_t *)
zfs_uio_iovbase(digest->cd_uio, vec_idx) + offset,
digest_len);
} else {
SHA2Final((uchar_t *)uio_iovbase(digest->
SHA2Final((uchar_t *)zfs_uio_iovbase(digest->
cd_uio, vec_idx) + offset,
sha2_ctx);
@@ -410,12 +410,12 @@ sha2_digest_final_uio(SHA2_CTX *sha2_ctx, crypto_data_t *digest,
SHA2Final(digest_tmp, sha2_ctx);
while (vec_idx < uio_iovcnt(digest->cd_uio) && length > 0) {
while (vec_idx < zfs_uio_iovcnt(digest->cd_uio) && length > 0) {
cur_len =
MIN(uio_iovlen(digest->cd_uio, vec_idx) -
MIN(zfs_uio_iovlen(digest->cd_uio, vec_idx) -
offset, length);
bcopy(digest_tmp + scratch_offset,
uio_iovbase(digest->cd_uio, vec_idx) + offset,
zfs_uio_iovbase(digest->cd_uio, vec_idx) + offset,
cur_len);
length -= cur_len;
@@ -424,7 +424,7 @@ sha2_digest_final_uio(SHA2_CTX *sha2_ctx, crypto_data_t *digest,
offset = 0;
}
if (vec_idx == uio_iovcnt(digest->cd_uio) && length > 0) {
if (vec_idx == zfs_uio_iovcnt(digest->cd_uio) && length > 0) {
/*
* The end of the specified iovec's was reached but
* the length requested could not be processed, i.e.
@@ -1251,12 +1251,12 @@ sha2_mac_verify_atomic(crypto_provider_handle_t provider,
size_t cur_len;
/* we support only kernel buffer */
if (uio_segflg(mac->cd_uio) != UIO_SYSSPACE)
if (zfs_uio_segflg(mac->cd_uio) != UIO_SYSSPACE)
return (CRYPTO_ARGUMENTS_BAD);
/* jump to the first iovec containing the expected digest */
offset = uio_index_at_offset(mac->cd_uio, offset, &vec_idx);
if (vec_idx == uio_iovcnt(mac->cd_uio)) {
offset = zfs_uio_index_at_offset(mac->cd_uio, offset, &vec_idx);
if (vec_idx == zfs_uio_iovcnt(mac->cd_uio)) {
/*
* The caller specified an offset that is
* larger than the total size of the buffers
@@ -1267,12 +1267,12 @@ sha2_mac_verify_atomic(crypto_provider_handle_t provider,
}
/* do the comparison of computed digest vs specified one */
while (vec_idx < uio_iovcnt(mac->cd_uio) && length > 0) {
cur_len = MIN(uio_iovlen(mac->cd_uio, vec_idx) -
while (vec_idx < zfs_uio_iovcnt(mac->cd_uio) && length > 0) {
cur_len = MIN(zfs_uio_iovlen(mac->cd_uio, vec_idx) -
offset, length);
if (bcmp(digest + scratch_offset,
uio_iovbase(mac->cd_uio, vec_idx) + offset,
zfs_uio_iovbase(mac->cd_uio, vec_idx) + offset,
cur_len) != 0) {
ret = CRYPTO_INVALID_MAC;
break;