diff options
author | Brian Atkinson <[email protected]> | 2021-01-20 22:27:30 -0700 |
---|---|---|
committer | GitHub <[email protected]> | 2021-01-20 21:27:30 -0800 |
commit | d0cd9a5cc65e39feab5631ad4b5c09cf004ad3f0 (patch) | |
tree | f228b2dbb9655257e4f8e85862320ee61cae9ff4 /module/icp/io/sha2_mod.c | |
parent | e2af2acce3436acdb2b35fdc7c9de1a30ea85514 (diff) |
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 <[email protected]>
Reviewed-by: Jorgen Lundman <[email protected]>
Reviewed-by: Brian Behlendorf <[email protected]>
Signed-off-by: Brian Atkinson <[email protected]>
Closes #11438
Diffstat (limited to 'module/icp/io/sha2_mod.c')
-rw-r--r-- | module/icp/io/sha2_mod.c | 48 |
1 files changed, 24 insertions, 24 deletions
diff --git a/module/icp/io/sha2_mod.c b/module/icp/io/sha2_mod.c index a4a5c6041..d690cd0bc 100644 --- a/module/icp/io/sha2_mod.c +++ b/module/icp/io/sha2_mod.c @@ -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; |