[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[CRYPTO-LUKS v1 15/19] cryptodisk, luks2: Add header line to procfs entr
From: |
Glenn Washburn |
Subject: |
[CRYPTO-LUKS v1 15/19] cryptodisk, luks2: Add header line to procfs entry and crypto and source device names. |
Date: |
Fri, 31 Jul 2020 07:01:56 -0500 |
A header line is added to luks_script for easier comprehension of fields by
user. And the crypto disk name and source device names are added.
Signed-off-by: Glenn Washburn <development@efficientek.com>
---
grub-core/disk/cryptodisk.c | 28 ++++++++++++++++++++++------
1 file changed, 22 insertions(+), 6 deletions(-)
diff --git a/grub-core/disk/cryptodisk.c b/grub-core/disk/cryptodisk.c
index 9399849b6..2c6e73b39 100644
--- a/grub-core/disk/cryptodisk.c
+++ b/grub-core/disk/cryptodisk.c
@@ -1206,35 +1206,48 @@ hex (grub_uint8_t val)
}
/* Open a file named NAME and initialize FILE. */
+#define STR(s) #s
+#define MAX_ID_PRINT 10000
static char *
luks_script_get (grub_size_t *sz)
{
grub_cryptodisk_t i;
grub_size_t size = 0;
char *ptr, *ret;
+ const char header[] = N_("<type> <devname> <source disk> <uuid> <sector "
+ "offset> <sector size> <cipher> <key> <options>\n");
+ static char errmsg[] = N_("Can not list more than " STR(MAX_ID_PRINT)
+ " crypto devices.\n");
*sz = 0;
for (i = cryptodisk_list; i != NULL; i = i->next)
- if (grub_strcmp (i->modname, "luks") == 0 ||
- grub_strcmp (i->modname, "luks2") == 0)
+ if (i->id >= MAX_ID_PRINT)
+ {
+ *sz = sizeof (errmsg);
+ return errmsg;
+ }
+ else if (grub_strcmp (i->modname, "luks") == 0 ||
+ grub_strcmp (i->modname, "luks2") == 0)
{
size += grub_strlen (i->modname);
size += sizeof ("_mount");
+ size += sizeof ("crypto");
+ size += grub_strlen (i->source);
size += grub_strlen (i->uuid);
size += grub_strlen (i->cipher->cipher->name);
- /* mode + mode_iv + spaces + offset + sector size + ??? + '\n' */
- size += 5 + 8 + 5 + 20 + 4 + 16 + 1;
+ /* spaces + maxidlen + mode + mode_iv + offset + sector size + ??? +
'\n' */
+ size += 7 + sizeof (STR(MAX_ID_PRINT)) + 5 + 8 + 20 + 4 + 16 + 1;
if (i->essiv_hash)
size += grub_strlen (i->essiv_hash->name);
size += i->keysize * 2;
}
- ret = grub_malloc (size + 1);
+ ret = grub_malloc (sizeof (header) + size + 1);
if (!ret)
return 0;
- ptr = ret;
+ ptr = grub_stpcpy (ret, header);
for (i = cryptodisk_list; i != NULL; i = i->next)
if (grub_strcmp (i->modname, "luks") == 0 ||
@@ -1244,6 +1257,9 @@ luks_script_get (grub_size_t *sz)
const char *iptr;
ptr = grub_stpcpy (ptr, i->modname);
ptr = grub_stpcpy (ptr, "_mount ");
+ ptr += grub_snprintf (ptr, 8 + sizeof (STR(MAX_ID_PRINT)), "crypto%lu
", i->id);
+ ptr = grub_stpcpy (ptr, i->source);
+ *ptr++ = ' ';
ptr = grub_stpcpy (ptr, i->uuid);
*ptr++ = ' ';
ptr += grub_snprintf (ptr, 21, "%" PRIuGRUB_UINT64_T " ", i->offset);
--
2.25.1
- [CRYPTO-LUKS v1 06/19] luks2: Rename source disk variabled named 'disk' to 'source' as in luks.c., (continued)
- [CRYPTO-LUKS v1 06/19] luks2: Rename source disk variabled named 'disk' to 'source' as in luks.c., Glenn Washburn, 2020/07/31
- [CRYPTO-LUKS v1 07/19] luks2: grub_cryptodisk_t->total_length is the max number of device native sectors., Glenn Washburn, 2020/07/31
- [CRYPTO-LUKS v1 08/19] cryptodisk, luks: Allow special processing for comparing UUIDs., Glenn Washburn, 2020/07/31
- [CRYPTO-LUKS v1 09/19] cryptodisk: Unregister cryptomount command when removing module., Glenn Washburn, 2020/07/31
- [CRYPTO-LUKS v1 10/19] fs: Fix block lists not being able to address to end of disk sometimes., Glenn Washburn, 2020/07/31
- [CRYPTO-LUKS v1 11/19] cryptodisk: Properly handle non-512 byte sized sectors., Glenn Washburn, 2020/07/31
- [CRYPTO-LUKS v1 12/19] cryptodisk: Rename total_length field in grub_cryptodisk_t to total_sectors., Glenn Washburn, 2020/07/31
- [CRYPTO-LUKS v1 13/19] fs: Allow number of blocks in block list to be optional, where length will be defaulted to the length of the device., Glenn Washburn, 2020/07/31
- [CRYPTO-LUKS v1 14/19] loopback: Add procfs entry 'loopbacks' to output configured loopback devices., Glenn Washburn, 2020/07/31
- [CRYPTO-LUKS v1 15/19] cryptodisk, luks2: Add header line to procfs entry and crypto and source device names.,
Glenn Washburn <=
- [CRYPTO-LUKS v1 16/19] cryptodisk: Add a couple comments noting the usage of a couple fields in grub_cryptodisk_t as is done for grub_disk_t., Glenn Washburn, 2020/07/31
- [CRYPTO-LUKS v1 17/19] luks2: Ensure that bit fields of grub_luks2_digest_t in luks2_parse_digest are initialized before returning., Glenn Washburn, 2020/07/31
- [CRYPTO-LUKS v1 18/19] luks2: Fix use of incorrect index and some error messages., Glenn Washburn, 2020/07/31
- [CRYPTO-LUKS v1 19/19] cryptodisk: Rename offset in grub_cryptodisk_t to offset_sectors to improve readability., Glenn Washburn, 2020/07/31
- Re: [CRYPTO-LUKS v1 00/19] Fixes and improvements for cryptodisks+luks2 and a few other things., Patrick Steinhardt, 2020/07/31