Patch by "starsseed" (with style fixes by myself):
PartitionMapWriter::WriteMBR(): Also read the old MBR from disk when the boot code shall be overwritten. Prevents overwriting of the disk ID. Closes ticket #7507. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@41565 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
222b8cf7b7
commit
c2069a9a2e
@ -75,7 +75,9 @@ struct partition_descriptor {
|
||||
|
||||
// partition_table
|
||||
struct partition_table {
|
||||
char code_area[446];
|
||||
char code_area[440];
|
||||
uint32 disk_id;
|
||||
uint16 reserved;
|
||||
partition_descriptor table[4];
|
||||
uint16 signature;
|
||||
|
||||
|
@ -10,11 +10,14 @@
|
||||
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <new>
|
||||
|
||||
#include <debug.h>
|
||||
|
||||
|
||||
#ifndef _USER_MODE
|
||||
# include <KernelExport.h>
|
||||
#endif
|
||||
@ -134,13 +137,14 @@ PartitionMapWriter::WriteMBR(const PartitionMap* map, bool writeBootCode)
|
||||
return B_BAD_VALUE;
|
||||
|
||||
partition_table partitionTable;
|
||||
status_t error = _ReadBlock(0, partitionTable);
|
||||
if (error != B_OK)
|
||||
return error;
|
||||
if (writeBootCode) {
|
||||
// the boot code must be small enough to fit in the code area
|
||||
STATIC_ASSERT(sizeof(kBootCode) <= sizeof(partitionTable.code_area));
|
||||
partitionTable.clear_code_area();
|
||||
partitionTable.fill_code_area(kBootCode, sizeof(kBootCode));
|
||||
} else {
|
||||
status_t error = _ReadBlock(0, partitionTable);
|
||||
if (error != B_OK)
|
||||
return error;
|
||||
}
|
||||
|
||||
partitionTable.signature = kPartitionTableSectorSignature;
|
||||
@ -152,7 +156,7 @@ PartitionMapWriter::WriteMBR(const PartitionMap* map, bool writeBootCode)
|
||||
partition->GetPartitionDescriptor(descriptor);
|
||||
}
|
||||
|
||||
status_t error = _WriteBlock(0, partitionTable);
|
||||
error = _WriteBlock(0, partitionTable);
|
||||
return error;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user