From 2dd0a26ac04939442c9db2dfb76c28b6d3c78aaf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Tue, 29 Jan 2013 00:02:31 +0100 Subject: [PATCH] gpt: Fixed off by one error. * The backup header would have been written one block behind the actual last block. Well, at least it would have tried to do so :-) --- src/add-ons/kernel/partitioning_systems/gpt/efi_gpt.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/add-ons/kernel/partitioning_systems/gpt/efi_gpt.cpp b/src/add-ons/kernel/partitioning_systems/gpt/efi_gpt.cpp index 7b87a291a08..8dbf7ad7418 100644 --- a/src/add-ons/kernel/partitioning_systems/gpt/efi_gpt.cpp +++ b/src/add-ons/kernel/partitioning_systems/gpt/efi_gpt.cpp @@ -73,7 +73,7 @@ static float efi_gpt_identify_partition(int fd, partition_data* partition, void** _cookie) { EFI::Header* header = new (std::nothrow) EFI::Header(fd, - partition->size / partition->block_size, partition->block_size); + (partition->size - 1) / partition->block_size, partition->block_size); status_t status = header->InitCheck(); if (status != B_OK) { delete header; @@ -110,9 +110,8 @@ efi_gpt_scan_partition(int fd, partition_data* partition, void* _cookie) if (entry.EndBlock() * partition->block_size > (uint64)partition->size) { - TRACE(("efi_gpt: child partition exceeds existing space (%Ld MB)\n", - (entry.EndBlock() - entry.StartBlock()) * partition->block_size - / 1024 / 1024)); + TRACE(("efi_gpt: child partition exceeds existing space (ends at " + "block %" B_PRIu64 ")\n", entry.EndBlock())); continue; } @@ -699,7 +698,7 @@ efi_gpt_initialize(int fd, partition_id partitionID, const char* name, update_disk_device_job_progress(job, 0.0); - EFI::Header header(partitionSize / partition->block_size, + EFI::Header header((partitionSize - 1) / partition->block_size, partition->block_size); status_t result = header.InitCheck(); if (result != B_OK)