From patchwork Thu Sep 8 04:11:19 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lei Wen X-Patchwork-Id: 113867 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id 6BC6DB6F76 for ; Thu, 8 Sep 2011 14:11:33 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 67AB52813D; Thu, 8 Sep 2011 06:11:30 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id qQ1+HjwHe89e; Thu, 8 Sep 2011 06:11:30 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 3415E2813E; Thu, 8 Sep 2011 06:11:29 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 723132813E for ; Thu, 8 Sep 2011 06:11:27 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id rYwmMvA+rcnI for ; Thu, 8 Sep 2011 06:11:26 +0200 (CEST) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from dakia2.marvell.com (dakia2.marvell.com [65.219.4.35]) by theia.denx.de (Postfix) with ESMTPS id 583F42813D for ; Thu, 8 Sep 2011 06:11:25 +0200 (CEST) X-ASG-Debug-ID: 1315455081-082b7a7d0001-4l7tJC Received: from maili.marvell.com (maili.marvell.com [10.68.76.51]) by dakia2.marvell.com with ESMTP id NKr2x8EWSrZZbMvr; Wed, 07 Sep 2011 21:11:21 -0700 (PDT) X-Barracuda-Envelope-From: leiwen@marvell.com Received: from localhost (sh4-dt.marvell.com [10.38.164.102]) by maili.marvell.com (Postfix) with ESMTP id 98FAD8A002; Wed, 7 Sep 2011 21:11:20 -0700 (PDT) From: Lei Wen To: Wolfgang Denk , Marek Vasut , u-boot@lists.denx.de X-ASG-Orig-Subj: [PATCH V3] part: show efi partition name when print out partition info Date: Wed, 7 Sep 2011 21:11:19 -0700 X-ASG-Orig-Subj: [PATCH V3] part: show efi partition name when print out partition info Message-Id: <1315455079-13051-1-git-send-email-leiwen@marvell.com> X-Mailer: git-send-email 1.7.0.4 In-Reply-To: <20110907192154.6C99E140875D@gemini.denx.de> References: <20110907192154.6C99E140875D@gemini.denx.de> X-Barracuda-Connect: maili.marvell.com[10.68.76.51] X-Barracuda-Start-Time: 1315455081 X-Barracuda-URL: http://10.68.76.222:80/cgi-mod/mark.cgi X-Barracuda-Spam-Score: -1002.00 X-Barracuda-Spam-Status: No, SCORE=-1002.00 using global scores of TAG_LEVEL=1000.0 QUARANTINE_LEVEL=1000.0 KILL_LEVEL=1000.0 Subject: [U-Boot] [PATCH V3] part: show efi partition name when print out partition info X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.9 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de Previous output: Marvell>> mmc part Partition Map for MMC device 1 -- Partition Type: EFI Part Start LBA End LBA gpt1 0x8C00 0xCBFF gpt2 0xCC00 0x57BFF gpt3 0x57C00 0xA2BFF gpt4 0xA2C00 0xECBFDE With the patch, the output becomes: Marvell>> mmc part Partition Map for MMC device 1 -- Partition Type: EFI Part Name Start LBA End LBA 1 ramdisk 0x00008C00 0x0000CBFF 2 system 0x0000CC00 0x00057BFF 3 userdata 0x00057C00 0x000A2BFF 4 remaining 0x000A2C00 0x00ECBFDE Signed-off-by: Lei Wen --- Changelog: V1: align the efi part name output to the left V2: correct patch description for this new alignment V3: Remove the magic number definition, and reuse the same number used by partition_name. Fix loop overflow issue. disk/part_efi.c | 24 ++++++++++++++++++++---- disk/part_efi.h | 3 ++- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/disk/part_efi.c b/disk/part_efi.c index 1b04c27..0a513c6 100644 --- a/disk/part_efi.c +++ b/disk/part_efi.c @@ -35,6 +35,7 @@ #include #include #include "part_efi.h" +#include #if defined(CONFIG_CMD_IDE) || \ defined(CONFIG_CMD_MG_DISK) || \ @@ -99,6 +100,20 @@ static gpt_entry *alloc_read_gpt_entries(block_dev_desc_t * dev_desc, static int is_pte_valid(gpt_entry * pte); +static char *print_efiname(gpt_entry *pte) +{ + static char name[PARTNAME_SZ + 1]; + int i; + for (i = 0; i < PARTNAME_SZ; i++) { + u8 c; + c = pte->partition_name[i] & 0xff; + c = (c && !isprint(c)) ? '.' : c; + name[i] = c; + } + name[PARTNAME_SZ] = 0; + return name; +} + /* * Public Functions (include/part.h) */ @@ -122,12 +137,12 @@ void print_part_efi(block_dev_desc_t * dev_desc) debug("%s: gpt-entry at 0x%08X\n", __FUNCTION__, (unsigned int)*pgpt_pte); - printf("Part Start LBA End LBA\n"); + printf("Part\tName\t\t\tStart LBA\tEnd LBA\n"); for (i = 0; i < le32_to_int(gpt_head.num_partition_entries); i++) { if (is_pte_valid(&(*pgpt_pte)[i])) { - printf("%s%d 0x%llX 0x%llX\n", GPT_ENTRY_NAME, - (i + 1), + printf("%3d\t%-18s\t0x%08llX\t0x%08llX\n", (i + 1), + print_efiname(&(*pgpt_pte)[i]), le64_to_int((*pgpt_pte)[i].starting_lba), le64_to_int((*pgpt_pte)[i].ending_lba)); } else { @@ -169,7 +184,8 @@ int get_partition_info_efi(block_dev_desc_t * dev_desc, int part, - info->start; info->blksz = GPT_BLOCK_SIZE; - sprintf((char *)info->name, "%s%d", GPT_ENTRY_NAME, part); + sprintf((char *)info->name, "%s", + print_efiname(&(*pgpt_pte)[part - 1])); sprintf((char *)info->type, "U-Boot"); debug("%s: start 0x%lX, size 0x%lX, name %s", __FUNCTION__, diff --git a/disk/part_efi.h b/disk/part_efi.h index 6bbb06b..5903e7c 100644 --- a/disk/part_efi.h +++ b/disk/part_efi.h @@ -117,13 +117,14 @@ typedef struct _gpt_entry_attributes { unsigned long long type_guid_specific:16; } __attribute__ ((packed)) gpt_entry_attributes; +#define PARTNAME_SZ (72 / sizeof(efi_char16_t)) typedef struct _gpt_entry { efi_guid_t partition_type_guid; efi_guid_t unique_partition_guid; unsigned char starting_lba[8]; unsigned char ending_lba[8]; gpt_entry_attributes attributes; - efi_char16_t partition_name[72 / sizeof(efi_char16_t)]; + efi_char16_t partition_name[PARTNAME_SZ]; } __attribute__ ((packed)) gpt_entry;