mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2026-05-22 18:40:43 +03:00
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:
+24
-24
@@ -271,15 +271,15 @@ sha1_digest_update_uio(SHA1_CTX *sha1_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.
|
||||
@@ -290,12 +290,12 @@ sha1_digest_update_uio(SHA1_CTX *sha1_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);
|
||||
|
||||
SHA1Update(sha1_ctx,
|
||||
(uint8_t *)uio_iovbase(data->cd_uio, vec_idx) + offset,
|
||||
(uint8_t *)zfs_uio_iovbase(data->cd_uio, vec_idx) + offset,
|
||||
cur_len);
|
||||
|
||||
length -= cur_len;
|
||||
@@ -303,7 +303,7 @@ sha1_digest_update_uio(SHA1_CTX *sha1_ctx, crypto_data_t *data)
|
||||
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.
|
||||
@@ -330,15 +330,15 @@ sha1_digest_final_uio(SHA1_CTX *sha1_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
|
||||
@@ -348,7 +348,7 @@ sha1_digest_final_uio(SHA1_CTX *sha1_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 SHA1 digest will fit in the current
|
||||
* iovec.
|
||||
@@ -360,11 +360,11 @@ sha1_digest_final_uio(SHA1_CTX *sha1_ctx, crypto_data_t *digest,
|
||||
* the user only what was requested.
|
||||
*/
|
||||
SHA1Final(digest_scratch, sha1_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 {
|
||||
SHA1Final((uchar_t *)uio_iovbase(digest->
|
||||
SHA1Final((uchar_t *)zfs_uio_iovbase(digest->
|
||||
cd_uio, vec_idx) + offset,
|
||||
sha1_ctx);
|
||||
}
|
||||
@@ -382,11 +382,11 @@ sha1_digest_final_uio(SHA1_CTX *sha1_ctx, crypto_data_t *digest,
|
||||
|
||||
SHA1Final(digest_tmp, sha1_ctx);
|
||||
|
||||
while (vec_idx < uio_iovcnt(digest->cd_uio) && length > 0) {
|
||||
cur_len = MIN(uio_iovlen(digest->cd_uio, vec_idx) -
|
||||
while (vec_idx < zfs_uio_iovcnt(digest->cd_uio) && length > 0) {
|
||||
cur_len = 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;
|
||||
@@ -395,7 +395,7 @@ sha1_digest_final_uio(SHA1_CTX *sha1_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.
|
||||
@@ -1096,12 +1096,12 @@ sha1_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
|
||||
@@ -1112,12 +1112,12 @@ sha1_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;
|
||||
|
||||
+24
-24
@@ -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;
|
||||
|
||||
+20
-20
@@ -272,18 +272,18 @@ skein_digest_update_uio(skein_ctx_t *ctx, const crypto_data_t *data)
|
||||
size_t length = data->cd_length;
|
||||
uint_t vec_idx = 0;
|
||||
size_t cur_len;
|
||||
uio_t *uio = data->cd_uio;
|
||||
zfs_uio_t *uio = data->cd_uio;
|
||||
|
||||
/* we support only kernel buffer */
|
||||
if (uio_segflg(uio) != UIO_SYSSPACE)
|
||||
if (zfs_uio_segflg(uio) != UIO_SYSSPACE)
|
||||
return (CRYPTO_ARGUMENTS_BAD);
|
||||
|
||||
/*
|
||||
* Jump to the first iovec containing data to be
|
||||
* digested.
|
||||
*/
|
||||
offset = uio_index_at_offset(uio, offset, &vec_idx);
|
||||
if (vec_idx == uio_iovcnt(uio)) {
|
||||
offset = zfs_uio_index_at_offset(uio, offset, &vec_idx);
|
||||
if (vec_idx == zfs_uio_iovcnt(uio)) {
|
||||
/*
|
||||
* The caller specified an offset that is larger than the
|
||||
* total size of the buffers it provided.
|
||||
@@ -294,16 +294,16 @@ skein_digest_update_uio(skein_ctx_t *ctx, const crypto_data_t *data)
|
||||
/*
|
||||
* Now do the digesting on the iovecs.
|
||||
*/
|
||||
while (vec_idx < uio_iovcnt(uio) && length > 0) {
|
||||
cur_len = MIN(uio_iovlen(uio, vec_idx) - offset, length);
|
||||
SKEIN_OP(ctx, Update, (uint8_t *)uio_iovbase(uio, vec_idx)
|
||||
while (vec_idx < zfs_uio_iovcnt(uio) && length > 0) {
|
||||
cur_len = MIN(zfs_uio_iovlen(uio, vec_idx) - offset, length);
|
||||
SKEIN_OP(ctx, Update, (uint8_t *)zfs_uio_iovbase(uio, vec_idx)
|
||||
+ offset, cur_len);
|
||||
length -= cur_len;
|
||||
vec_idx++;
|
||||
offset = 0;
|
||||
}
|
||||
|
||||
if (vec_idx == uio_iovcnt(uio) && length > 0) {
|
||||
if (vec_idx == zfs_uio_iovcnt(uio) && length > 0) {
|
||||
/*
|
||||
* The end of the specified iovec's was reached but
|
||||
* the length requested could not be processed, i.e.
|
||||
@@ -322,19 +322,19 @@ static int
|
||||
skein_digest_final_uio(skein_ctx_t *ctx, crypto_data_t *digest,
|
||||
crypto_req_handle_t req)
|
||||
{
|
||||
off_t offset = digest->cd_offset;
|
||||
uint_t vec_idx = 0;
|
||||
uio_t *uio = digest->cd_uio;
|
||||
off_t offset = digest->cd_offset;
|
||||
uint_t vec_idx = 0;
|
||||
zfs_uio_t *uio = digest->cd_uio;
|
||||
|
||||
/* we support only kernel buffer */
|
||||
if (uio_segflg(uio) != UIO_SYSSPACE)
|
||||
if (zfs_uio_segflg(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(uio, offset, &vec_idx);
|
||||
if (vec_idx == uio_iovcnt(uio)) {
|
||||
offset = zfs_uio_index_at_offset(uio, offset, &vec_idx);
|
||||
if (vec_idx == zfs_uio_iovcnt(uio)) {
|
||||
/*
|
||||
* The caller specified an offset that is larger than the
|
||||
* total size of the buffers it provided.
|
||||
@@ -342,10 +342,10 @@ skein_digest_final_uio(skein_ctx_t *ctx, crypto_data_t *digest,
|
||||
return (CRYPTO_DATA_LEN_RANGE);
|
||||
}
|
||||
if (offset + CRYPTO_BITS2BYTES(ctx->sc_digest_bitlen) <=
|
||||
uio_iovlen(uio, vec_idx)) {
|
||||
zfs_uio_iovlen(uio, vec_idx)) {
|
||||
/* The computed digest will fit in the current iovec. */
|
||||
SKEIN_OP(ctx, Final,
|
||||
(uchar_t *)uio_iovbase(uio, vec_idx) + offset);
|
||||
(uchar_t *)zfs_uio_iovbase(uio, vec_idx) + offset);
|
||||
} else {
|
||||
uint8_t *digest_tmp;
|
||||
off_t scratch_offset = 0;
|
||||
@@ -357,11 +357,11 @@ skein_digest_final_uio(skein_ctx_t *ctx, crypto_data_t *digest,
|
||||
if (digest_tmp == NULL)
|
||||
return (CRYPTO_HOST_MEMORY);
|
||||
SKEIN_OP(ctx, Final, digest_tmp);
|
||||
while (vec_idx < uio_iovcnt(uio) && length > 0) {
|
||||
cur_len = MIN(uio_iovlen(uio, vec_idx) - offset,
|
||||
while (vec_idx < zfs_uio_iovcnt(uio) && length > 0) {
|
||||
cur_len = MIN(zfs_uio_iovlen(uio, vec_idx) - offset,
|
||||
length);
|
||||
bcopy(digest_tmp + scratch_offset,
|
||||
uio_iovbase(uio, vec_idx) + offset, cur_len);
|
||||
zfs_uio_iovbase(uio, vec_idx) + offset, cur_len);
|
||||
|
||||
length -= cur_len;
|
||||
vec_idx++;
|
||||
@@ -370,7 +370,7 @@ skein_digest_final_uio(skein_ctx_t *ctx, crypto_data_t *digest,
|
||||
}
|
||||
kmem_free(digest_tmp, CRYPTO_BITS2BYTES(ctx->sc_digest_bitlen));
|
||||
|
||||
if (vec_idx == uio_iovcnt(uio) && length > 0) {
|
||||
if (vec_idx == zfs_uio_iovcnt(uio) && 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