[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v3 1/4] luks: extract qcrypto_block_calculate_payload_offset(
From: |
Max Reitz |
Subject: |
Re: [PATCH v3 1/4] luks: extract qcrypto_block_calculate_payload_offset() |
Date: |
Wed, 19 Feb 2020 14:03:50 +0100 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.4.1 |
On 11.02.20 17:03, Stefan Hajnoczi wrote:
> The qcow2 .bdrv_measure() code calculates the crypto payload offset.
> This logic really belongs in crypto/block.c where it can be reused by
> other image formats.
>
> The "luks" block driver will need this same logic in order to implement
> .bdrv_measure(), so extract the qcrypto_block_calculate_payload_offset()
> function now.
>
> Signed-off-by: Stefan Hajnoczi <address@hidden>
> ---
> block/qcow2.c | 74 +++++++++++-------------------------------
> crypto/block.c | 40 +++++++++++++++++++++++
> include/crypto/block.h | 22 +++++++++++++
> 3 files changed, 81 insertions(+), 55 deletions(-)
[...]
> diff --git a/crypto/block.c b/crypto/block.c
> index 325752871c..a9e1b8cc36 100644
> --- a/crypto/block.c
> +++ b/crypto/block.c
> @@ -115,6 +115,46 @@ QCryptoBlock
> *qcrypto_block_create(QCryptoBlockCreateOptions *options,
[...]
> +bool
> +qcrypto_block_calculate_payload_offset(QCryptoBlockCreateOptions
> *create_opts,
> + const char *optprefix,
> + size_t *len,
> + Error **errp)
> +{
> + QCryptoBlock *crypto;
> + bool ok;
> +
> + /* Fake LUKS creation in order to determine the payload size */
> + crypto = qcrypto_block_create(create_opts, optprefix,
> + qcrypto_block_headerlen_hdr_init_func,
> + qcrypto_block_headerlen_hdr_write_func,
> + len, errp);
> + ok = crypto != NULL;
> + qcrypto_block_free(crypto);
> + return ok;
Speaking of g_autoptr... Would g_autoptr(QCryptoBlock) crypto; suffice
to contract these three lines into “return crypto != NULL;”?
Either way:
Reviewed-by: Max Reitz <address@hidden>
signature.asc
Description: OpenPGP digital signature