Commit f7cfd3a4 authored by Daniel Verkamp's avatar Daniel Verkamp Committed by Ben Walker
Browse files

bdev/gpt: compare the correct MBR entry start LBA



The protective MBR entry may not be the first one.  This is already
handled correctly when comparing the total size field, but the start LBA
field was always looking at the first entry.

Change-Id: Ie54e424b2e9cb546b1ed04192662936e04e08b6b
Signed-off-by: default avatarDaniel Verkamp <daniel.verkamp@intel.com>
Reviewed-on: https://review.gerrithub.io/370747


Tested-by: default avatarSPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: default avatarBen Walker <benjamin.walker@intel.com>
parent 94174eec
Loading
Loading
Loading
Loading
+8 −7
Original line number Diff line number Diff line
@@ -203,13 +203,6 @@ spdk_gpt_check_mbr(struct spdk_gpt *gpt)
		return -1;
	}

	expected_start_lba = GPT_PRIMARY_PARTITION_TABLE_LBA;
	if (from_le32(&mbr->partitions[0].start_lba) != expected_start_lba) {
		SPDK_TRACELOG(SPDK_TRACE_GPT_PARSE, "start lba mismatch, provided=%u, expected=%u\n",
			      from_le32(&mbr->partitions[0].start_lba), expected_start_lba);
		return -1;
	}

	for (i = 0; i < PRIMARY_PARTITION_NUMBER; i++) {
		if (mbr->partitions[i].os_type == SPDK_MBR_OS_TYPE_GPT_PROTECTIVE) {
			primary_partition = i;
@@ -219,6 +212,14 @@ spdk_gpt_check_mbr(struct spdk_gpt *gpt)
	}

	if (ret == GPT_PROTECTIVE_MBR) {
		expected_start_lba = GPT_PRIMARY_PARTITION_TABLE_LBA;
		if (from_le32(&mbr->partitions[primary_partition].start_lba) != expected_start_lba) {
			SPDK_TRACELOG(SPDK_TRACE_GPT_PARSE, "start lba mismatch, provided=%u, expected=%u\n",
				      from_le32(&mbr->partitions[primary_partition].start_lba),
				      expected_start_lba);
			return -1;
		}

		total_lba_size = from_le32(&mbr->partitions[primary_partition].size_lba);
		if ((total_lba_size != ((uint32_t) gpt->total_sectors - 1)) &&
		    (total_lba_size != 0xFFFFFFFF)) {