grub-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v3 08/10] cryptodisk: Rename total_length field in grub_crypt


From: Patrick Steinhardt
Subject: Re: [PATCH v3 08/10] cryptodisk: Rename total_length field in grub_cryptodisk_t to total_sectors.
Date: Fri, 23 Oct 2020 19:58:50 +0200

On Mon, Oct 19, 2020 at 06:09:56PM -0500, Glenn Washburn wrote:
> This creates an alignment with grub_disk_t naming of the same field and is
> more intuitive as to how it should be used.
> 
> Signed-off-by: Glenn Washburn <development@efficientek.com>

Reviewed-by: Patrick Steinhardt <ps@pks.im>

Patrick

> ---
>  grub-core/disk/cryptodisk.c | 2 +-
>  grub-core/disk/geli.c       | 2 +-
>  grub-core/disk/luks.c       | 2 +-
>  grub-core/disk/luks2.c      | 4 ++--
>  include/grub/cryptodisk.h   | 3 ++-
>  5 files changed, 7 insertions(+), 6 deletions(-)
> 
> diff --git a/grub-core/disk/cryptodisk.c b/grub-core/disk/cryptodisk.c
> index 1a91c2d55..f5d098f65 100644
> --- a/grub-core/disk/cryptodisk.c
> +++ b/grub-core/disk/cryptodisk.c
> @@ -711,7 +711,7 @@ grub_cryptodisk_open (const char *name, grub_disk_t disk)
>      }
>  
>    disk->data = dev;
> -  disk->total_sectors = dev->total_length;
> +  disk->total_sectors = dev->total_sectors;
>    disk->max_agglomerate = GRUB_DISK_MAX_MAX_AGGLOMERATE;
>    disk->id = dev->id;
>    dev->ref++;
> diff --git a/grub-core/disk/geli.c b/grub-core/disk/geli.c
> index e9d23299a..4ec875821 100644
> --- a/grub-core/disk/geli.c
> +++ b/grub-core/disk/geli.c
> @@ -391,7 +391,7 @@ configure_ciphers (grub_disk_t disk, const char 
> *check_uuid,
>  
>    newdev->modname = "geli";
>  
> -  newdev->total_length = grub_disk_get_size (disk) - 1;
> +  newdev->total_sectors = grub_disk_get_size (disk) - 1;
>    grub_memcpy (newdev->uuid, uuid, sizeof (newdev->uuid));
>    COMPILE_TIME_ASSERT (sizeof (newdev->uuid) >= 32 * 2 + 1);
>    return newdev;
> diff --git a/grub-core/disk/luks.c b/grub-core/disk/luks.c
> index 20cc20b9b..545734342 100644
> --- a/grub-core/disk/luks.c
> +++ b/grub-core/disk/luks.c
> @@ -125,7 +125,7 @@ configure_ciphers (grub_disk_t disk, const char 
> *check_uuid,
>    newdev->offset = grub_be_to_cpu32 (header.payloadOffset);
>    newdev->source_disk = NULL;
>    newdev->log_sector_size = LUKS1_LOG_SECTOR_SIZE;
> -  newdev->total_length = grub_disk_get_size (disk) - newdev->offset;
> +  newdev->total_sectors = grub_disk_get_size (disk) - newdev->offset;
>    grub_memcpy (newdev->uuid, uuid, sizeof (uuid));
>    newdev->modname = "luks";
>  
> diff --git a/grub-core/disk/luks2.c b/grub-core/disk/luks2.c
> index b9e0e98e1..bae54936c 100644
> --- a/grub-core/disk/luks2.c
> +++ b/grub-core/disk/luks2.c
> @@ -616,10 +616,10 @@ luks2_recover_key (grub_disk_t disk,
>        crypt->log_sector_size = sizeof (unsigned int) * 8
>               - __builtin_clz ((unsigned int) segment.sector_size) - 1;
>        if (grub_strcmp (segment.size, "dynamic") == 0)
> -     crypt->total_length = (grub_disk_get_size (disk) >> 
> (crypt->log_sector_size - disk->log_sector_size))
> +     crypt->total_sectors = (grub_disk_get_size (disk) >> 
> (crypt->log_sector_size - disk->log_sector_size))
>                              - crypt->offset;
>        else
> -     crypt->total_length = grub_strtoull (segment.size, NULL, 10) >> 
> crypt->log_sector_size;
> +     crypt->total_sectors = grub_strtoull (segment.size, NULL, 10) >> 
> crypt->log_sector_size;
>  
>        ret = luks2_decrypt_key (candidate_key, disk, crypt, &keyslot,
>                              (const grub_uint8_t *) passphrase, grub_strlen 
> (passphrase));
> diff --git a/include/grub/cryptodisk.h b/include/grub/cryptodisk.h
> index 006f3ec49..9e10ae927 100644
> --- a/include/grub/cryptodisk.h
> +++ b/include/grub/cryptodisk.h
> @@ -73,7 +73,8 @@ struct grub_cryptodisk
>  
>    char *source;
>    grub_disk_addr_t offset;
> -  grub_disk_addr_t total_length;
> +  /* Total number of encrypted sectors of size (1<<log_sector_size) */
> +  grub_disk_addr_t total_sectors;
>    grub_disk_t source_disk;
>    int ref;
>    grub_crypto_cipher_handle_t cipher;
> -- 
> 2.27.0
> 

Attachment: signature.asc
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]