2 * Copyright 2007-2013, Axel Dörfler, axeld@pinc-software.de.
3 * Copyright 2009, Michael Lotz, mmlr@mlotz.ch. All rights reserved.
5 * Distributed under the terms of the MIT License.
19 Header(int fd
, uint64 lastBlock
,
22 // constructor for empty header
23 Header(uint64 lastBlock
, uint32 blockSize
);
27 status_t
InitCheck() const;
30 uint64
FirstUsableBlock() const
31 { return fHeader
.FirstUsableBlock(); }
32 uint64
LastUsableBlock() const
33 { return fHeader
.LastUsableBlock(); }
34 const efi_table_header
& TableHeader() const
37 uint32
EntryCount() const
38 { return fHeader
.EntryCount(); }
39 efi_partition_entry
& EntryAt(int32 index
) const
40 { return *(efi_partition_entry
*)(fEntries
41 + fHeader
.EntrySize() * index
); }
44 status_t
WriteEntry(int fd
, uint32 entryIndex
);
45 status_t
Write(int fd
);
50 status_t
_WriteHeader(int fd
);
51 status_t
_Write(int fd
, off_t offset
, const void* data
,
54 void _UpdateCRC(efi_table_header
& header
);
57 status_t
_Read(int fd
, off_t offset
, void* data
,
59 static bool _IsHeaderValid(efi_table_header
& header
,
61 static bool _ValidateHeaderCRC(efi_table_header
& header
);
62 bool _ValidateEntriesCRC() const;
63 void _SetBackupHeaderFromPrimary(uint64 lastBlock
);
64 size_t _EntryArraySize() const
65 { return fHeader
.EntrySize()
66 * fHeader
.EntryCount(); }
68 const char* _PrintGUID(const guid_t
& id
);
69 void _Dump(const efi_table_header
& header
);
70 void _DumpPartitions();
75 efi_table_header fHeader
;
76 efi_table_header fBackupHeader
;
85 #endif // GPT_HEADER_H