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
|
status_t
|
||||||
Header::WriteEntry(int fd, uint32 entryIndex)
|
Header::WriteEntry(int fd, uint32 entryIndex)
|
||||||
{
|
{
|
||||||
// Determine block to write
|
off_t entryOffset = entryIndex * fHeader.EntrySize();
|
||||||
off_t blockOffset =
|
|
||||||
+ entryIndex * fHeader.EntrySize() / fBlockSize;
|
|
||||||
uint32 entryOffset = entryIndex * fHeader.EntrySize() % fBlockSize;
|
|
||||||
|
|
||||||
status_t status = _Write(fd,
|
status_t status = _Write(fd,
|
||||||
(fHeader.EntriesBlock() + blockOffset) * fBlockSize + entryOffset,
|
fHeader.EntriesBlock() * fBlockSize + entryOffset,
|
||||||
fEntries + entryOffset, fBlockSize);
|
fEntries + entryOffset, fHeader.EntrySize());
|
||||||
if (status != B_OK)
|
if (status != B_OK)
|
||||||
return status;
|
return status;
|
||||||
|
|
||||||
@ -209,8 +206,8 @@ Header::WriteEntry(int fd, uint32 entryIndex)
|
|||||||
|
|
||||||
// Write backup
|
// Write backup
|
||||||
status_t backupStatus = _Write(fd,
|
status_t backupStatus = _Write(fd,
|
||||||
(fBackupHeader.EntriesBlock() + blockOffset) * fBlockSize + entryOffset,
|
fBackupHeader.EntriesBlock() * fBlockSize + entryOffset,
|
||||||
fEntries + entryOffset, fBlockSize);
|
fEntries + entryOffset, fHeader.EntrySize());
|
||||||
|
|
||||||
return status == B_OK ? backupStatus : status;
|
return status == B_OK ? backupStatus : status;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user