On Wed, Mar 03, 2021 at 09:18:44PM +0200, Dāvis Mosāns wrote:
> Currently only single checksum byte is outputted.
> This fixes it so that full checksum is outputted.
> 
> Signed-off-by: Dāvis Mosāns <[email protected]>
> ---
>  kernel-shared/disk-io.c | 32 +++++++++++++++++++++++++++-----
>  1 file changed, 27 insertions(+), 5 deletions(-)
> 
> diff --git a/kernel-shared/disk-io.c b/kernel-shared/disk-io.c
> index 6f584986..10b2421e 100644
> --- a/kernel-shared/disk-io.c
> +++ b/kernel-shared/disk-io.c
> @@ -160,10 +160,30 @@ int btrfs_csum_data(u16 csum_type, const u8 *data, u8 
> *out, size_t len)
>       return -1;
>  }
>  
> +int btrfs_format_csum(u16 csum_type, u16 csum_size, const char *data, char 
> *output)
> +{
> +     int i;
> +     int position = 0;
> +     int direction = 1;
> +     if (csum_type == BTRFS_CSUM_TYPE_CRC32 ||
> +             csum_type == BTRFS_CSUM_TYPE_XXHASH) {
> +             position = csum_size - 1;
> +             direction = -1;
> +     }

Per the discussion, I've dropped the direction variable and added the
"0x" prefix. The csum_size does not need to be passed, though it's
available in the caller's context. The type should be enough and then
the function can find the size independently.

Updated patch added to devel, thanks.

Reply via email to