X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=disk%2Fpart_dos.c;h=936cee0d36cedc7ad3fa55180666175582f16bd0;hb=cad28d37d5146cf293fe841c7c8e6f658c8a4940;hp=c77d8815606ffaa2353fbe7375e4760ceb66a959;hpb=b331cd6204ffdc568cd6c06bd18e72aa9bc61f22;p=oweals%2Fu-boot.git diff --git a/disk/part_dos.c b/disk/part_dos.c index c77d881560..936cee0d36 100644 --- a/disk/part_dos.c +++ b/disk/part_dos.c @@ -1,9 +1,8 @@ +// SPDX-License-Identifier: GPL-2.0+ /* * (C) Copyright 2001 * Raymond Lo, lo@routefree.com * Wolfgang Denk, DENX Software Engineering, wd@denx.de. - * - * SPDX-License-Identifier: GPL-2.0+ */ /* @@ -20,7 +19,7 @@ #include #include "part_dos.h" -#ifdef HAVE_BLOCK_DEVICE +#ifdef CONFIG_HAVE_BLOCK_DEVICE #define DOS_PART_DEFAULT_SECTOR 512 @@ -44,7 +43,7 @@ static inline int is_extended(int part_type) static inline int is_bootable(dos_partition_t *p) { - return p->boot_ind == 0x80; + return (p->sys_ind == 0xef) || (p->boot_ind == 0x80); } static void print_one_part(dos_partition_t *p, lbaint_t ext_part_sector, @@ -89,6 +88,21 @@ static int test_block_type(unsigned char *buffer) static int part_test_dos(struct blk_desc *dev_desc) { +#ifndef CONFIG_SPL_BUILD + ALLOC_CACHE_ALIGN_BUFFER(legacy_mbr, mbr, 1); + + if (blk_dread(dev_desc, 0, 1, (ulong *)mbr) != 1) + return -1; + + if (test_block_type((unsigned char *)mbr) != DOS_MBR) + return -1; + + if (dev_desc->sig_type == SIG_TYPE_NONE && + mbr->unique_mbr_signature != 0) { + dev_desc->sig_type = SIG_TYPE_MBR; + dev_desc->mbr_sig = mbr->unique_mbr_signature; + } +#else ALLOC_CACHE_ALIGN_BUFFER(unsigned char, buffer, dev_desc->blksz); if (blk_dread(dev_desc, 0, 1, (ulong *)buffer) != 1) @@ -96,6 +110,7 @@ static int part_test_dos(struct blk_desc *dev_desc) if (test_block_type(buffer) != DOS_MBR) return -1; +#endif return 0; } @@ -204,7 +219,7 @@ static int part_get_info_extended(struct blk_desc *dev_desc, if (((pt->boot_ind & ~0x80) == 0) && (pt->sys_ind != 0) && (part_num == which_part) && - (is_extended(pt->sys_ind) == 0)) { + (ext_part_sector == 0 || is_extended(pt->sys_ind) == 0)) { info->blksz = DOS_PART_DEFAULT_SECTOR; info->start = (lbaint_t)(ext_part_sector + le32_to_int(pt->start4)); @@ -217,6 +232,7 @@ static int part_get_info_extended(struct blk_desc *dev_desc, #if CONFIG_IS_ENABLED(PARTITION_UUIDS) sprintf(info->uuid, "%08x-%02x", disksig, part_num); #endif + info->sys_ind = pt->sys_ind; return 0; }