]> git.kernelconcepts.de Git - karo-tx-uboot.git/blobdiff - disk/part_efi.c
karo: tx6: enable FDT support for MFG U-Boot build
[karo-tx-uboot.git] / disk / part_efi.c
index 59865897085c1750067a3c8f2712006cbe6c5abe..09c2e1b6717ff2d7ece2b7b3c4cf8b3fa84a8f90 100644 (file)
@@ -2,23 +2,7 @@
  * Copyright (C) 2008 RuggedCom, Inc.
  * Richard Retanubun <RichardRetanubun@RuggedCom.com>
  *
- * See file CREDITS for list of people who contributed to this
- * project.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
- * MA 02111-1307 USA
+ * SPDX-License-Identifier:    GPL-2.0+
  */
 
 /*
@@ -200,8 +184,8 @@ int get_partition_info_efi(block_dev_desc_t * dev_desc, int part,
        uuid_string(gpt_pte[part - 1].unique_partition_guid.b, info->uuid);
 #endif
 
-       debug("%s: start 0x%lX, size 0x%lX, name %s", __func__,
-               info->start, info->size, info->name);
+       debug("%s: start 0x" LBAF ", size 0x" LBAF ", name %s", __func__,
+             info->start, info->size, info->name);
 
        /* Remember to free pte */
        free(gpt_pte);
@@ -372,7 +356,7 @@ int gpt_fill_pte(gpt_header *gpt_h, gpt_entry *gpt_e,
        u32 offset = (u32)le32_to_cpu(gpt_h->first_usable_lba);
        ulong start;
        int i, k;
-       size_t name_len;
+       size_t efiname_len, dosname_len;
 #ifdef CONFIG_PARTITION_UUIDS
        char *str_uuid;
 #endif
@@ -392,7 +376,7 @@ int gpt_fill_pte(gpt_header *gpt_h, gpt_entry *gpt_e,
                        offset += partitions[i].size;
                }
                if (offset >= gpt_h->last_usable_lba) {
-                       printf("Partitions layout exceds disk size\n");
+                       printf("Partitions layout exceeds disk size\n");
                        return -1;
                }
                /* partition ending lba */
@@ -420,13 +404,18 @@ int gpt_fill_pte(gpt_header *gpt_h, gpt_entry *gpt_e,
                       sizeof(gpt_entry_attributes));
 
                /* partition name */
-               name_len = sizeof(gpt_e[i].partition_name)
+               efiname_len = sizeof(gpt_e[i].partition_name)
                        / sizeof(efi_char16_t);
-               for (k = 0; k < name_len; k++)
+               dosname_len = sizeof(partitions[i].name);
+
+               memset(gpt_e[i].partition_name, 0,
+                      sizeof(gpt_e[i].partition_name));
+
+               for (k = 0; k < min(dosname_len, efiname_len); k++)
                        gpt_e[i].partition_name[k] =
                                (efi_char16_t)(partitions[i].name[k]);
 
-               debug("%s: name: %s offset[%d]: 0x%x size[%d]: 0x%lx\n",
+               debug("%s: name: %s offset[%d]: 0x%x size[%d]: 0x" LBAF "\n",
                      __func__, partitions[i].name, i,
                      offset, i, partitions[i].size);
        }