From 08006f7c8fa8cd104ccfbe024d083b3bc09e0422 Mon Sep 17 00:00:00 2001 From: Jessica Hamilton Date: Fri, 20 Nov 2015 19:17:56 +1300 Subject: [PATCH] efi_gpt: properly fix block offset calculations for partition entries In 2346363b, had corrected the offset writing to the disk, but missed correcting the offset for reading from the entries struct. Instead of writing a block, just write the single entry, simplifying the offset logic considerably. --- .../kernel/partitioning_systems/gpt/Header.cpp | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/add-ons/kernel/partitioning_systems/gpt/Header.cpp b/src/add-ons/kernel/partitioning_systems/gpt/Header.cpp index 864878a596..046d601423 100644 --- a/src/add-ons/kernel/partitioning_systems/gpt/Header.cpp +++ b/src/add-ons/kernel/partitioning_systems/gpt/Header.cpp @@ -193,14 +193,11 @@ Header::InitCheck() const status_t Header::WriteEntry(int fd, uint32 entryIndex) { - // Determine block to write - off_t blockOffset = - + entryIndex * fHeader.EntrySize() / fBlockSize; - uint32 entryOffset = entryIndex * fHeader.EntrySize() % fBlockSize; + off_t entryOffset = entryIndex * fHeader.EntrySize(); status_t status = _Write(fd, - (fHeader.EntriesBlock() + blockOffset) * fBlockSize + entryOffset, - fEntries + entryOffset, fBlockSize); + fHeader.EntriesBlock() * fBlockSize + entryOffset, + fEntries + entryOffset, fHeader.EntrySize()); if (status != B_OK) return status; @@ -209,8 +206,8 @@ Header::WriteEntry(int fd, uint32 entryIndex) // Write backup status_t backupStatus = _Write(fd, - (fBackupHeader.EntriesBlock() + blockOffset) * fBlockSize + entryOffset, - fEntries + entryOffset, fBlockSize); + fBackupHeader.EntriesBlock() * fBlockSize + entryOffset, + fEntries + entryOffset, fHeader.EntrySize()); return status == B_OK ? backupStatus : status; }