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.
This commit is contained in:
parent
856cc59e58
commit
08006f7c8f
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user