gpt: Correct naming. efi_* also conflicts with some efi headers
Change-Id: I19b5b2c4609da8474b26588ae8d7d4caf72a826b Reviewed-on: https://review.haiku-os.org/c/haiku/+/2018 Reviewed-by: Fredrik Holmqvist <fredrik.holmqvist@gmail.com> Reviewed-by: Alex von Gluck IV <kallisti5@unixzen.com>
This commit is contained in:
parent
418e068de3
commit
ed7204fad2
|
@ -17,7 +17,7 @@
|
|||
#include <AutoDeleter.h>
|
||||
#include <disk_device_types.h>
|
||||
|
||||
#include "efi_gpt.h"
|
||||
#include "gpt.h"
|
||||
|
||||
#include "GPTPartitionHandle.h"
|
||||
#include "Utility.h"
|
||||
|
|
|
@ -59,7 +59,7 @@ Header::Header(int fd, uint64 lastBlock, uint32 blockSize)
|
|||
// Read and check the partition table header
|
||||
|
||||
fStatus = _Read(fd, (uint64)EFI_HEADER_LOCATION * blockSize,
|
||||
&fHeader, sizeof(efi_table_header));
|
||||
&fHeader, sizeof(gpt_table_header));
|
||||
if (fStatus == B_OK) {
|
||||
if (!_IsHeaderValid(fHeader, EFI_HEADER_LOCATION))
|
||||
fStatus = B_BAD_DATA;
|
||||
|
@ -73,7 +73,7 @@ Header::Header(int fd, uint64 lastBlock, uint32 blockSize)
|
|||
|
||||
// Read backup header, too
|
||||
status_t status = _Read(fd, lastBlock * blockSize, &fBackupHeader,
|
||||
sizeof(efi_table_header));
|
||||
sizeof(gpt_table_header));
|
||||
if (status == B_OK) {
|
||||
if (!_IsHeaderValid(fBackupHeader, lastBlock))
|
||||
status = B_BAD_DATA;
|
||||
|
@ -275,12 +275,12 @@ Header::_WriteHeader(int fd)
|
|||
_UpdateCRC();
|
||||
|
||||
status_t status = _Write(fd, fHeader.AbsoluteBlock() * fBlockSize,
|
||||
&fHeader, sizeof(efi_table_header));
|
||||
&fHeader, sizeof(gpt_table_header));
|
||||
if (status != B_OK)
|
||||
return status;
|
||||
|
||||
return _Write(fd, fBackupHeader.AbsoluteBlock() * fBlockSize,
|
||||
&fBackupHeader, sizeof(efi_table_header));
|
||||
&fBackupHeader, sizeof(gpt_table_header));
|
||||
}
|
||||
|
||||
|
||||
|
@ -306,11 +306,11 @@ Header::_UpdateCRC()
|
|||
|
||||
|
||||
void
|
||||
Header::_UpdateCRC(efi_table_header& header)
|
||||
Header::_UpdateCRC(gpt_table_header& header)
|
||||
{
|
||||
header.SetEntriesCRC(crc32(fEntries, _EntryArraySize()));
|
||||
header.SetHeaderCRC(0);
|
||||
header.SetHeaderCRC(crc32((uint8*)&header, sizeof(efi_table_header)));
|
||||
header.SetHeaderCRC(crc32((uint8*)&header, sizeof(gpt_table_header)));
|
||||
}
|
||||
#endif // !_BOOT_MODE
|
||||
|
||||
|
@ -329,7 +329,7 @@ Header::_Read(int fd, off_t offset, void* data, size_t size) const
|
|||
|
||||
|
||||
bool
|
||||
Header::_IsHeaderValid(efi_table_header& header, uint64 block)
|
||||
Header::_IsHeaderValid(gpt_table_header& header, uint64 block)
|
||||
{
|
||||
return !memcmp(header.header, EFI_PARTITION_HEADER, sizeof(header.header))
|
||||
&& _ValidateHeaderCRC(header)
|
||||
|
@ -338,13 +338,13 @@ Header::_IsHeaderValid(efi_table_header& header, uint64 block)
|
|||
|
||||
|
||||
bool
|
||||
Header::_ValidateHeaderCRC(efi_table_header& header)
|
||||
Header::_ValidateHeaderCRC(gpt_table_header& header)
|
||||
{
|
||||
uint32 originalCRC = header.HeaderCRC();
|
||||
header.SetHeaderCRC(0);
|
||||
|
||||
bool matches = originalCRC == crc32((const uint8*)&header,
|
||||
sizeof(efi_table_header));
|
||||
sizeof(gpt_table_header));
|
||||
|
||||
header.SetHeaderCRC(originalCRC);
|
||||
return matches;
|
||||
|
@ -385,7 +385,7 @@ Header::_PrintGUID(const guid_t &id)
|
|||
|
||||
|
||||
void
|
||||
Header::_Dump(const efi_table_header& header)
|
||||
Header::_Dump(const gpt_table_header& header)
|
||||
{
|
||||
dprintf("EFI header: %.8s\n", header.header);
|
||||
dprintf("EFI revision: %" B_PRIx32 "\n", header.Revision());
|
||||
|
@ -407,7 +407,7 @@ void
|
|||
Header::_DumpPartitions()
|
||||
{
|
||||
for (uint32 i = 0; i < EntryCount(); i++) {
|
||||
const efi_partition_entry &entry = EntryAt(i);
|
||||
const gpt_partition_entry &entry = EntryAt(i);
|
||||
|
||||
if (entry.partition_type == kEmptyGUID)
|
||||
continue;
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
#define GPT_HEADER_H
|
||||
|
||||
|
||||
#include "efi_gpt.h"
|
||||
#include "gpt.h"
|
||||
|
||||
|
||||
namespace EFI {
|
||||
|
@ -31,13 +31,13 @@ public:
|
|||
{ return fHeader.FirstUsableBlock(); }
|
||||
uint64 LastUsableBlock() const
|
||||
{ return fHeader.LastUsableBlock(); }
|
||||
const efi_table_header& TableHeader() const
|
||||
const gpt_table_header& TableHeader() const
|
||||
{ return fHeader; }
|
||||
|
||||
uint32 EntryCount() const
|
||||
{ return fHeader.EntryCount(); }
|
||||
efi_partition_entry& EntryAt(int32 index) const
|
||||
{ return *(efi_partition_entry*)(fEntries
|
||||
gpt_partition_entry& EntryAt(int32 index) const
|
||||
{ return *(gpt_partition_entry*)(fEntries
|
||||
+ fHeader.EntrySize() * index); }
|
||||
|
||||
#ifndef _BOOT_MODE
|
||||
|
@ -51,14 +51,14 @@ private:
|
|||
status_t _Write(int fd, off_t offset, const void* data,
|
||||
size_t size) const;
|
||||
void _UpdateCRC();
|
||||
void _UpdateCRC(efi_table_header& header);
|
||||
void _UpdateCRC(gpt_table_header& header);
|
||||
#endif
|
||||
|
||||
status_t _Read(int fd, off_t offset, void* data,
|
||||
size_t size) const;
|
||||
static bool _IsHeaderValid(efi_table_header& header,
|
||||
static bool _IsHeaderValid(gpt_table_header& header,
|
||||
uint64 block);
|
||||
static bool _ValidateHeaderCRC(efi_table_header& header);
|
||||
static bool _ValidateHeaderCRC(gpt_table_header& header);
|
||||
bool _ValidateEntriesCRC() const;
|
||||
void _SetBackupHeaderFromPrimary(uint64 lastBlock);
|
||||
size_t _EntryArraySize() const
|
||||
|
@ -66,14 +66,14 @@ private:
|
|||
* fHeader.EntryCount(); }
|
||||
|
||||
const char* _PrintGUID(const guid_t& id);
|
||||
void _Dump(const efi_table_header& header);
|
||||
void _Dump(const gpt_table_header& header);
|
||||
void _DumpPartitions();
|
||||
|
||||
private:
|
||||
uint32 fBlockSize;
|
||||
status_t fStatus;
|
||||
efi_table_header fHeader;
|
||||
efi_table_header fBackupHeader;
|
||||
gpt_table_header fHeader;
|
||||
gpt_table_header fBackupHeader;
|
||||
uint8* fEntries;
|
||||
bool fDirty;
|
||||
};
|
||||
|
|
|
@ -20,7 +20,7 @@ if $(TARGET_ARCH) = "x86" || $(TARGET_ARCH) = "x86_64" {
|
|||
}
|
||||
|
||||
KernelAddon efi_gpt :
|
||||
efi_gpt.cpp
|
||||
gpt.cpp
|
||||
Header.cpp
|
||||
crc32.cpp
|
||||
utility.cpp
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
*/
|
||||
|
||||
|
||||
#include "efi_gpt.h"
|
||||
#include "gpt.h"
|
||||
|
||||
#include <KernelExport.h>
|
||||
#include <disk_device_manager/ddm_modules.h>
|
||||
|
@ -115,7 +115,7 @@ efi_gpt_scan_partition(int fd, partition_data* partition, void* _cookie)
|
|||
uint32 index = 0;
|
||||
|
||||
for (uint32 i = 0; i < header->EntryCount(); i++) {
|
||||
const efi_partition_entry& entry = header->EntryAt(i);
|
||||
const gpt_partition_entry& entry = header->EntryAt(i);
|
||||
|
||||
if (entry.partition_type == kEmptyGUID)
|
||||
continue;
|
||||
|
@ -378,7 +378,7 @@ efi_gpt_validate_create_child(partition_data* partition, off_t* start,
|
|||
EFI::Header* header = (EFI::Header*)partition->content_cookie;
|
||||
int32 entryIndex = -1;
|
||||
for (uint32 i = 0; i < header->EntryCount(); i++) {
|
||||
const efi_partition_entry& entry = header->EntryAt(i);
|
||||
const gpt_partition_entry& entry = header->EntryAt(i);
|
||||
if (entry.partition_type == kEmptyGUID) {
|
||||
entryIndex = i;
|
||||
break;
|
||||
|
@ -524,7 +524,7 @@ efi_gpt_resize_child(int fd, partition_id partitionID, off_t size,
|
|||
|
||||
update_disk_device_job_progress(job, 0.0);
|
||||
|
||||
efi_partition_entry& entry = header->EntryAt(entryIndex);
|
||||
gpt_partition_entry& entry = header->EntryAt(entryIndex);
|
||||
entry.SetBlockCount(validatedSize / partition->block_size);
|
||||
|
||||
status_t result = header->WriteEntry(fd, entryIndex);
|
||||
|
@ -589,7 +589,7 @@ efi_gpt_move_child(int fd, partition_id partitionID, partition_id childID,
|
|||
|
||||
update_disk_device_job_progress(job, 0.0);
|
||||
|
||||
efi_partition_entry& entry = header->EntryAt(entryIndex);
|
||||
gpt_partition_entry& entry = header->EntryAt(entryIndex);
|
||||
uint64 blockCount = entry.BlockCount();
|
||||
entry.SetStartBlock((validatedOffset - partition->offset)
|
||||
/ partition->block_size);
|
||||
|
@ -639,7 +639,7 @@ efi_gpt_set_name(int fd, partition_id partitionID, const char* name,
|
|||
|
||||
update_disk_device_job_progress(job, 0.0);
|
||||
|
||||
efi_partition_entry& entry = header->EntryAt(entryIndex);
|
||||
gpt_partition_entry& entry = header->EntryAt(entryIndex);
|
||||
to_ucs2(name, strlen(name), entry.name, EFI_PARTITION_NAME_LENGTH);
|
||||
|
||||
status_t result = header->WriteEntry(fd, entryIndex);
|
||||
|
@ -689,7 +689,7 @@ efi_gpt_set_type(int fd, partition_id partitionID, const char* type,
|
|||
|
||||
update_disk_device_job_progress(job, 0.0);
|
||||
|
||||
efi_partition_entry& entry = header->EntryAt(entryIndex);
|
||||
gpt_partition_entry& entry = header->EntryAt(entryIndex);
|
||||
entry.partition_type = typeGUID;
|
||||
|
||||
status_t result = header->WriteEntry(fd, entryIndex);
|
||||
|
@ -815,7 +815,7 @@ efi_gpt_create_child(int fd, partition_id partitionID, off_t offset,
|
|||
if (child == NULL)
|
||||
return B_ERROR;
|
||||
|
||||
efi_partition_entry& entry = header->EntryAt(entryIndex);
|
||||
gpt_partition_entry& entry = header->EntryAt(entryIndex);
|
||||
entry.partition_type = typeGUID;
|
||||
uuid_t uuid;
|
||||
uuid_generate_random(uuid);
|
||||
|
@ -882,8 +882,8 @@ efi_gpt_delete_child(int fd, partition_id partitionID, partition_id childID,
|
|||
if (!delete_partition(childID))
|
||||
return B_ERROR;
|
||||
|
||||
efi_partition_entry& entry = header->EntryAt(entryIndex);
|
||||
memset(&entry, 0, sizeof(efi_partition_entry));
|
||||
gpt_partition_entry& entry = header->EntryAt(entryIndex);
|
||||
memset(&entry, 0, sizeof(gpt_partition_entry));
|
||||
entry.partition_type = kEmptyGUID;
|
||||
|
||||
status_t result = header->WriteEntry(fd, entryIndex);
|
|
@ -12,7 +12,7 @@
|
|||
#include <ByteOrder.h>
|
||||
|
||||
|
||||
struct efi_table_header {
|
||||
struct gpt_table_header {
|
||||
char header[8];
|
||||
uint32 revision;
|
||||
uint32 header_size;
|
||||
|
@ -88,7 +88,7 @@ struct efi_table_header {
|
|||
#define EFI_PARTITION_ENTRY_COUNT 128
|
||||
#define EFI_PARTITION_ENTRY_SIZE 128
|
||||
|
||||
struct efi_partition_entry {
|
||||
struct gpt_partition_entry {
|
||||
guid_t partition_type;
|
||||
guid_t unique_guid;
|
||||
uint64 start_block;
|
|
@ -272,7 +272,7 @@ get_partition_offset(int deviceFD, off_t deviceStart, off_t deviceSize,
|
|||
EFI::Header gptHeader(deviceFD, deviceSize, blockSize);
|
||||
error = gptHeader.InitCheck();
|
||||
if (error == B_OK && partitionIndex < gptHeader.EntryCount()) {
|
||||
efi_partition_entry partition = gptHeader.EntryAt(partitionIndex - 1);
|
||||
gpt_partition_entry partition = gptHeader.EntryAt(partitionIndex - 1);
|
||||
|
||||
static_guid bfs_uuid = {0x42465331, 0x3BA3, 0x10F1,
|
||||
0x802A4861696B7521LL};
|
||||
|
|
|
@ -135,7 +135,7 @@ for platform in [ MultiBootSubDirSetup ] {
|
|||
amiga_rdb.cpp
|
||||
apple.cpp
|
||||
|
||||
efi_gpt.cpp
|
||||
gpt.cpp
|
||||
Header.cpp
|
||||
crc32.cpp
|
||||
utility.cpp
|
||||
|
@ -164,7 +164,7 @@ for platform in [ MultiBootSubDirSetup ] {
|
|||
SEARCH on [ FGristFiles apple.cpp ]
|
||||
= [ FDirName $(HAIKU_TOP) src add-ons kernel partitioning_systems apple ] ;
|
||||
|
||||
SEARCH on [ FGristFiles efi_gpt.cpp Header.cpp crc32.cpp utility.cpp ]
|
||||
SEARCH on [ FGristFiles gpt.cpp Header.cpp crc32.cpp utility.cpp ]
|
||||
= [ FDirName $(HAIKU_TOP) src add-ons kernel partitioning_systems gpt ] ;
|
||||
|
||||
SEARCH on [ FGristFiles intel.cpp PartitionMap.cpp PartitionMapParser.cpp ]
|
||||
|
|
|
@ -414,7 +414,7 @@ device_contains_partition(EfiDevice *device, boot::Partition *partition)
|
|||
return false;
|
||||
|
||||
if (memcmp(deviceHeader, &header->TableHeader(),
|
||||
sizeof(efi_table_header)) != 0)
|
||||
sizeof(gpt_table_header)) != 0)
|
||||
return false;
|
||||
|
||||
// partition->cookie == int partition entry index
|
||||
|
@ -427,7 +427,7 @@ device_contains_partition(EfiDevice *device, boot::Partition *partition)
|
|||
return false;
|
||||
|
||||
if (memcmp(&entries[index], &header->EntryAt(index),
|
||||
sizeof(efi_partition_entry)) != 0)
|
||||
sizeof(gpt_partition_entry)) != 0)
|
||||
return false;
|
||||
|
||||
for (size_t i = 0; i < sizeof(kTypeMap) / sizeof(struct type_map); ++i)
|
||||
|
|
|
@ -46,7 +46,7 @@ SEARCH_SOURCE
|
|||
+= [ FDirName $(HAIKU_TOP) src add-ons kernel partitioning_systems efi ] ;
|
||||
|
||||
Addon <userland>efi_gpt :
|
||||
efi_gpt.cpp
|
||||
gpt.cpp
|
||||
PartitionLocker.cpp
|
||||
: <nogrist>PartitioningSystemsTest libkernelland_emu.so
|
||||
;
|
||||
|
|
|
@ -37,7 +37,7 @@ ObjectDefines
|
|||
amiga_rdb.cpp
|
||||
apple.cpp
|
||||
|
||||
efi_gpt.cpp
|
||||
gpt.cpp
|
||||
Header.cpp
|
||||
crc32.cpp
|
||||
utility.cpp
|
||||
|
@ -104,7 +104,7 @@ SimpleTest BootLoaderTest :
|
|||
amiga_rdb.cpp
|
||||
apple.cpp
|
||||
|
||||
efi_gpt.cpp
|
||||
gpt.cpp
|
||||
Header.cpp
|
||||
crc32.cpp
|
||||
utility.cpp
|
||||
|
@ -153,7 +153,7 @@ SEARCH on [ FGristFiles amiga_rdb.cpp ]
|
|||
SEARCH on [ FGristFiles apple.cpp ]
|
||||
= [ FDirName $(HAIKU_TOP) src add-ons kernel partitioning_systems apple ] ;
|
||||
|
||||
SEARCH on [ FGristFiles efi_gpt.cpp Header.cpp crc32.cpp utility.cpp ]
|
||||
SEARCH on [ FGristFiles gpt.cpp Header.cpp crc32.cpp utility.cpp ]
|
||||
= [ FDirName $(HAIKU_TOP) src add-ons kernel partitioning_systems gpt ] ;
|
||||
|
||||
SEARCH on [ FGristFiles intel.cpp PartitionMap.cpp PartitionMapParser.cpp ]
|
||||
|
|
Loading…
Reference in New Issue