From 54b83adf45d2b2433084b8ee1785a80c5a13e2dd Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Thu, 29 Aug 2019 00:43:51 -0400 Subject: cgpt: show: dump drive details in verbose/debug mode The drive details are the only place where block sizes are tracked, so make sure we display them so the user knows the bytes-per-block. Might as well dump all the other drive details while we're here. BUG=None TEST=CQ passes BRANCH=None Change-Id: I2f2546feec2d58a295ce69c2bfe89a5ecf392f46 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1773966 Reviewed-by: Julius Werner Tested-by: Mike Frysinger Commit-Queue: Mike Frysinger --- cgpt/cgpt_show.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/cgpt/cgpt_show.c b/cgpt/cgpt_show.c index af4d88fa..0a956130 100644 --- a/cgpt/cgpt_show.c +++ b/cgpt/cgpt_show.c @@ -73,7 +73,7 @@ static void HeaderDetails(GptHeader *header, GptEntry *entries, PrintSignature(indent, header->signature, sizeof(header->signature), raw); printf("%sRev: 0x%08x\n", indent, header->revision); - printf("%sSize: %d\n", indent, header->size); + printf("%sSize: %d (blocks)\n", indent, header->size); printf("%sHeader CRC: 0x%08x %s\n", indent, header->header_crc32, (HeaderCrc(header) != header->header_crc32) ? "(INVALID)" : ""); printf("%sMy LBA: %lld\n", indent, (long long)header->my_lba); @@ -269,6 +269,23 @@ static int GptShow(struct drive *drive, CgptShowParams *params) { } else { // show all partitions GptEntry *entries; + if (params->debug || params->verbose) { + printf("Drive details:\n"); + printf(" Total Size (bytes): %" PRIu64 "\n", drive->size); + printf(" LBA Size (bytes): %d\n", drive->gpt.sector_bytes); + if (drive->gpt.flags & GPT_FLAG_EXTERNAL) { + printf(" Drive (where GPT lives) Size (blocks): %" PRIu64 "\n", + drive->gpt.gpt_drive_sectors); + printf(" Drive (where partitions live) Size (blocks): %" PRIu64 "\n", + drive->gpt.streaming_drive_sectors); + } else { + // We know gpt_drive_sectors == streaming_drive_sectors here. + printf(" Drive Size (blocks): %" PRIu64 "\n", + drive->gpt.gpt_drive_sectors); + } + printf("\n"); + } + if (CGPT_OK != ReadPMBR(drive)) { Error("Unable to read PMBR\n"); return CGPT_FAILED; -- cgit v1.2.1