grub-devel
[Top][All Lists]
Advanced

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

[CRYPTO-LUKS v1 19/19] cryptodisk: Rename offset in grub_cryptodisk_t to


From: Glenn Washburn
Subject: [CRYPTO-LUKS v1 19/19] cryptodisk: Rename offset in grub_cryptodisk_t to offset_sectors to improve readability.
Date: Fri, 31 Jul 2020 07:02:00 -0500

Signed-off-by: Glenn Washburn <development@efficientek.com>
---
 grub-core/disk/cryptodisk.c | 12 ++++++------
 grub-core/disk/geli.c       |  2 +-
 grub-core/disk/luks.c       |  4 ++--
 grub-core/disk/luks2.c      |  4 ++--
 include/grub/cryptodisk.h   |  2 +-
 5 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/grub-core/disk/cryptodisk.c b/grub-core/disk/cryptodisk.c
index 2c6e73b39..4921d031d 100644
--- a/grub-core/disk/cryptodisk.c
+++ b/grub-core/disk/cryptodisk.c
@@ -761,12 +761,12 @@ grub_cryptodisk_read (grub_disk_t disk, grub_disk_addr_t 
sector,
                "Reading %" PRIuGRUB_SIZE " sectors from sector 0x%"
                PRIxGRUB_UINT64_T " with offset of %" PRIuGRUB_UINT64_T
                " sectors and sector size of %u on disk (%s)\n",
-               size, sector, dev->offset, 1U << disk->log_sector_size,
+               size, sector, dev->offset_sectors, 1U << disk->log_sector_size,
                dev->source_disk->name);
 
   err = grub_disk_read (dev->source_disk,
-                       ((sector + dev->offset) << (disk->log_sector_size
-                                                  - GRUB_DISK_SECTOR_BITS)), 0,
+                       ((sector + dev->offset_sectors) << 
(disk->log_sector_size
+                                                          - 
GRUB_DISK_SECTOR_BITS)), 0,
                        size << disk->log_sector_size, buf);
   if (err)
     {
@@ -813,7 +813,7 @@ grub_cryptodisk_write (grub_disk_t disk, grub_disk_addr_t 
sector,
                "Writing %" PRIuGRUB_SIZE " sectors to sector 0x%"
                PRIxGRUB_UINT64_T " with offset of %" PRIuGRUB_UINT64_T
                " sectors and sector size of %u on disk (%s)\n",
-               size, sector, dev->offset, 1U << disk->log_sector_size,
+               size, sector, dev->offset_sectors, 1U << disk->log_sector_size,
                dev->source_disk->name);
 
   gcry_err = grub_cryptodisk_endecrypt (dev, (grub_uint8_t *) tmp,
@@ -831,7 +831,7 @@ grub_cryptodisk_write (grub_disk_t disk, grub_disk_addr_t 
sector,
     err = grub_disk_write_weak (dev->source_disk,
                                (sector << (disk->log_sector_size
                                            - GRUB_DISK_SECTOR_BITS))
-                               + dev->offset,
+                               + dev->offset_sectors,
                                0, size << disk->log_sector_size, tmp);
   else
     err = grub_error (GRUB_ERR_BUG, "disk.mod not loaded");
@@ -1262,7 +1262,7 @@ luks_script_get (grub_size_t *sz)
        *ptr++ = ' ';
        ptr = grub_stpcpy (ptr, i->uuid);
        *ptr++ = ' ';
-       ptr += grub_snprintf (ptr, 21, "%" PRIuGRUB_UINT64_T " ", i->offset);
+       ptr += grub_snprintf (ptr, 21, "%" PRIuGRUB_UINT64_T " ", 
i->offset_sectors);
        ptr += grub_snprintf (ptr, 6, "%d ", 1 << i->log_sector_size);
        for (iptr = i->cipher->cipher->name; *iptr; iptr++)
          *ptr++ = grub_tolower (*iptr);
diff --git a/grub-core/disk/geli.c b/grub-core/disk/geli.c
index 4ec875821..0175ce4c4 100644
--- a/grub-core/disk/geli.c
+++ b/grub-core/disk/geli.c
@@ -361,7 +361,7 @@ configure_ciphers (grub_disk_t disk, const char *check_uuid,
     }
   newdev->cipher = cipher;
   newdev->secondary_cipher = secondary_cipher;
-  newdev->offset = 0;
+  newdev->offset_sectors = 0;
   newdev->source_disk = NULL;
   newdev->benbi_log = 0;
   if (grub_le_to_cpu16 (header.alg) == 0x16)
diff --git a/grub-core/disk/luks.c b/grub-core/disk/luks.c
index b1db3d137..f825fa9a9 100644
--- a/grub-core/disk/luks.c
+++ b/grub-core/disk/luks.c
@@ -110,10 +110,10 @@ configure_ciphers (grub_disk_t disk, const char 
*check_uuid,
   newdev = grub_zalloc (sizeof (struct grub_cryptodisk));
   if (!newdev)
       return NULL;
-  newdev->offset = grub_be_to_cpu32 (header.payloadOffset);
+  newdev->offset_sectors = grub_be_to_cpu32 (header.payloadOffset);
   newdev->source_disk = NULL;
   newdev->log_sector_size = LOG_SECTOR_SIZE;
-  newdev->total_sectors = grub_disk_get_size (disk) - newdev->offset;
+  newdev->total_sectors = grub_disk_get_size (disk) - newdev->offset_sectors;
   grub_memcpy (newdev->uuid, header.uuid, sizeof (newdev->uuid));
   newdev->modname = "luks";
 
diff --git a/grub-core/disk/luks2.c b/grub-core/disk/luks2.c
index 09584c84c..35f705076 100644
--- a/grub-core/disk/luks2.c
+++ b/grub-core/disk/luks2.c
@@ -605,7 +605,7 @@ luks2_recover_key (grub_disk_t source,
       grub_dprintf ("luks2", "Trying keyslot %"PRIuGRUB_SIZE"\n", i);
 
       /* Set up disk according to keyslot's segment. */
-      crypt->offset = grub_divmod64 (segment.offset, segment.sector_size, 
NULL);
+      crypt->offset_sectors = grub_divmod64 (segment.offset, 
segment.sector_size, NULL);
       crypt->log_sector_size = sizeof (unsigned int) * 8
                - __builtin_clz ((unsigned int) segment.sector_size) - 1;
       if (grub_strcmp (segment.size, "dynamic") == 0)
@@ -614,7 +614,7 @@ luks2_recover_key (grub_disk_t source,
         * before subtracting the offset, which is in cryptodisk sized sectors.
         */
        crypt->total_sectors = (grub_disk_get_size (source) >> 
(crypt->log_sector_size - source->log_sector_size))
-                              - crypt->offset;
+                              - crypt->offset_sectors;
       else
        crypt->total_sectors = grub_strtoull (segment.size, NULL, 10) >> 
crypt->log_sector_size;
 
diff --git a/include/grub/cryptodisk.h b/include/grub/cryptodisk.h
index 8d3284aad..1a78f6f58 100644
--- a/include/grub/cryptodisk.h
+++ b/include/grub/cryptodisk.h
@@ -70,7 +70,7 @@ struct grub_cryptodisk
   /* The offset number of sectors of the encrypt data on the underlying disk
    * where sectors are the size of this cryptodisk.
    */
-  grub_disk_addr_t offset;
+  grub_disk_addr_t offset_sectors;
   /* Total number of encrypted sectors of size (1<<log_sector_size) */
   grub_disk_addr_t total_sectors;
   grub_disk_t source_disk;
-- 
2.25.1




reply via email to

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