Skip to content

Commit

Permalink
gpt: Fixed off by one error.
Browse files Browse the repository at this point in the history
* The backup header would have been written one block behind the actual
  last block. Well, at least it would have tried to do so :-)
  • Loading branch information
axeld committed Jan 28, 2013
1 parent 7775bfe commit 2dd0a26
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/add-ons/kernel/partitioning_systems/gpt/efi_gpt.cpp
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 2dd0a26

Please sign in to comment.