Lines Matching defs:gpt

11 #include "gpt.h"
23 int CheckParameters(GptData *gpt)
26 if (gpt->sector_bytes != SECTOR_SIZE)
34 if (gpt->gpt_drive_sectors == 0 ||
35 (!(gpt->flags & GPT_FLAG_EXTERNAL) &&
36 gpt->gpt_drive_sectors != gpt->streaming_drive_sectors)) {
45 if (gpt->gpt_drive_sectors <
237 int GptSanityCheck(GptData *gpt)
240 GptHeader *header1 = (GptHeader *)(gpt->primary_header);
241 GptHeader *header2 = (GptHeader *)(gpt->secondary_header);
242 GptEntry *entries1 = (GptEntry *)(gpt->primary_entries);
243 GptEntry *entries2 = (GptEntry *)(gpt->secondary_entries);
246 gpt->valid_headers = 0;
247 gpt->valid_entries = 0;
249 retval = CheckParameters(gpt);
254 if (0 == CheckHeader(header1, 0, gpt->streaming_drive_sectors,
255 gpt->gpt_drive_sectors, gpt->flags)) {
256 gpt->valid_headers |= MASK_PRIMARY;
259 if (0 == CheckHeader(header2, 1, gpt->streaming_drive_sectors,
260 gpt->gpt_drive_sectors, gpt->flags)) {
261 gpt->valid_headers |= MASK_SECONDARY;
266 if (!gpt->valid_headers)
277 gpt->valid_entries |= MASK_PRIMARY;
279 gpt->valid_entries |= MASK_SECONDARY;
285 if (MASK_BOTH == gpt->valid_headers && !gpt->valid_entries) {
287 gpt->valid_entries |= MASK_PRIMARY;
289 gpt->valid_entries |= MASK_SECONDARY;
290 if (gpt->valid_entries) {
296 gpt->valid_headers &= ~MASK_PRIMARY;
301 if (!gpt->valid_entries)
308 if (MASK_BOTH == gpt->valid_headers &&
310 gpt->valid_headers &= ~MASK_SECONDARY;
315 void GptRepair(GptData *gpt)
317 GptHeader *header1 = (GptHeader *)(gpt->primary_header);
318 GptHeader *header2 = (GptHeader *)(gpt->secondary_header);
319 GptEntry *entries1 = (GptEntry *)(gpt->primary_entries);
320 GptEntry *entries2 = (GptEntry *)(gpt->secondary_entries);
324 if (MASK_NONE == gpt->valid_headers || MASK_NONE == gpt->valid_entries)
328 if (MASK_PRIMARY == gpt->valid_headers) {
331 header2->my_lba = gpt->gpt_drive_sectors - GPT_HEADER_SECTORS;
335 gpt->modified |= GPT_MODIFIED_HEADER2;
337 else if (MASK_SECONDARY == gpt->valid_headers) {
342 gpt->streaming_drive_sectors - GPT_HEADER_SECTORS;
346 gpt->modified |= GPT_MODIFIED_HEADER1;
348 gpt->valid_headers = MASK_BOTH;
352 if (MASK_PRIMARY == gpt->valid_entries) {
355 gpt->modified |= GPT_MODIFIED_ENTRIES2;
357 else if (MASK_SECONDARY == gpt->valid_entries) {
360 gpt->modified |= GPT_MODIFIED_ENTRIES1;
362 gpt->valid_entries = MASK_BOTH;
406 void GetCurrentKernelUniqueGuid(GptData *gpt, void *dest)
408 GptEntry *entries = (GptEntry *)gpt->primary_entries;
409 GptEntry *e = entries + gpt->current_kernel;
413 void GptModified(GptData *gpt) {
414 GptHeader *header = (GptHeader *)gpt->primary_header;
417 header->entries_crc32 = Crc32(gpt->primary_entries,
421 gpt->modified |= GPT_MODIFIED_HEADER1 | GPT_MODIFIED_ENTRIES1;
428 gpt->valid_headers = MASK_PRIMARY;
429 gpt->valid_entries = MASK_PRIMARY;
430 GptRepair(gpt);