From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1kOqS1-0007f4-JM for mharc-grub-devel@gnu.org; Sat, 03 Oct 2020 18:56:27 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54768) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kOqRq-0007bE-05 for grub-devel@gnu.org; Sat, 03 Oct 2020 18:56:14 -0400 Received: from mail-oi1-x241.google.com ([2607:f8b0:4864:20::241]:35156) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kOqRl-0000Fw-Ai for grub-devel@gnu.org; Sat, 03 Oct 2020 18:56:13 -0400 Received: by mail-oi1-x241.google.com with SMTP id w141so5045280oia.2 for ; Sat, 03 Oct 2020 15:56:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=efficientek-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=QsbbprNoKBUzpy8d8i/fK7I/N5CqxLDTw4CZt4Rs0zs=; b=UHWwjf7F1bKxody+SwAcLUo3Ng3lAsZeIB2QK9vnrjraFuXYPs+/F0i0AG1R2Nzw6q uHHBu8KwmXh30ZtbEZtS0obrAIYH6DkXV0yFU0ldH39AKfjs2BaBRS7T5ETw/yqDDiyh HxYcMqJ/uAqHflbfU0pTjsfYpLdVllxpi6db10kih6rivO/s3PVHrzoc9R047dREVr67 Yf5eQi2dcEZ7dwdZHzT3bAoafLXED8pGYvKOTcs0sDTF5Iv5WofQwNT1ICmA3mIeSUFP 9GY+FLmp7IX7YLK1afG+mlmT15SViIuooY8/ctXjdZ0lVYBS7pWAb3ITx2w0Zq5qj+/g apEg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=QsbbprNoKBUzpy8d8i/fK7I/N5CqxLDTw4CZt4Rs0zs=; b=uTt+YrThfzFYgnT5Sf/KOdmr185IP6LphiSp3jTHorgq2JC8LaPW1OyjBN70V3tlwA h2ysTyWeTTo5XPeHgeHyHyYNBHSCogmuVeAJXnpx2rBGsbZvM1IElAgBO+bqLbE+CugN tBwPZs/3RuPkKxtI8Fxf1NSP3Qf+BQBAbSZmlZPoi2PMhOvAx7e5Vb4csranVz6hmXYF Jrkpnp8FjYaDzB5OsVRuMleDoN2TU9lujS2t6Qd46eGZuu1Fm0ftTdTm3+e5Y+IUu61u VH+9b1wvsKEVUgiQ48Ky8/c+eWhk/Eb0B2kE3p1eMObrWRh5pO2+yCjTWlq/00kXT435 QnTQ== X-Gm-Message-State: AOAM5308nJVy/cZmaiN0K0SzvL46zU6p54qJhnbdSbL5onTg6FpIP2+Z jVfu5Zo9yYYiinGDcWwFiQ0zpV+VoJ8Zyw== X-Google-Smtp-Source: ABdhPJzoNhfN1HSDfILytf7hwLrNYhHEnPi9ZIHHRzrxcCgsrBiZAzXwZGawinf7kaAR9JwRHFwt+g== X-Received: by 2002:aca:ea57:: with SMTP id i84mr3951017oih.0.1601765767915; Sat, 03 Oct 2020 15:56:07 -0700 (PDT) Received: from crass-HP-ZBook-15-G2.lan ([136.49.44.103]) by smtp.gmail.com with ESMTPSA id d17sm1524580oth.73.2020.10.03.15.56.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 03 Oct 2020 15:56:07 -0700 (PDT) From: Glenn Washburn To: grub-devel@gnu.org Cc: Daniel Kiper , Patrick Steinhardt , Glenn Washburn Subject: [PATCH v2 08/10] cryptodisk: Rename total_length field in grub_cryptodisk_t to total_sectors. Date: Sat, 3 Oct 2020 17:55:32 -0500 Message-Id: X-Mailer: git-send-email 2.27.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=2607:f8b0:4864:20::241; envelope-from=development@efficientek.com; helo=mail-oi1-x241.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 03 Oct 2020 22:56:14 -0000 This makes the 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 --- 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 b7d3b425a..2e295cac8 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<