Lines Matching refs:gpt
272 gpt_header *gpt) in alloc_read_gpt_entries() argument
277 if (!gpt) in alloc_read_gpt_entries()
280 count = (size_t)le32_to_cpu(gpt->num_partition_entries) * in alloc_read_gpt_entries()
281 le32_to_cpu(gpt->sizeof_partition_entry); in alloc_read_gpt_entries()
288 if (read_lba(state, le64_to_cpu(gpt->partition_entry_lba), in alloc_read_gpt_entries()
309 gpt_header *gpt; in alloc_read_gpt_header() local
312 gpt = kmalloc(ssz, GFP_KERNEL); in alloc_read_gpt_header()
313 if (!gpt) in alloc_read_gpt_header()
316 if (read_lba(state, lba, (u8 *) gpt, ssz) < ssz) { in alloc_read_gpt_header()
317 kfree(gpt); in alloc_read_gpt_header()
318 gpt=NULL; in alloc_read_gpt_header()
322 return gpt; in alloc_read_gpt_header()
336 gpt_header **gpt, gpt_entry **ptes) in is_gpt_valid() argument
343 if (!(*gpt = alloc_read_gpt_header(state, lba))) in is_gpt_valid()
347 if (le64_to_cpu((*gpt)->signature) != GPT_HEADER_SIGNATURE) { in is_gpt_valid()
350 (unsigned long long)le64_to_cpu((*gpt)->signature), in is_gpt_valid()
356 if (le32_to_cpu((*gpt)->header_size) > in is_gpt_valid()
359 le32_to_cpu((*gpt)->header_size), in is_gpt_valid()
365 if (le32_to_cpu((*gpt)->header_size) < sizeof(gpt_header)) { in is_gpt_valid()
367 le32_to_cpu((*gpt)->header_size), in is_gpt_valid()
373 origcrc = le32_to_cpu((*gpt)->header_crc32); in is_gpt_valid()
374 (*gpt)->header_crc32 = 0; in is_gpt_valid()
375 crc = efi_crc32((const unsigned char *) (*gpt), le32_to_cpu((*gpt)->header_size)); in is_gpt_valid()
382 (*gpt)->header_crc32 = cpu_to_le32(origcrc); in is_gpt_valid()
386 if (le64_to_cpu((*gpt)->my_lba) != lba) { in is_gpt_valid()
388 (unsigned long long)le64_to_cpu((*gpt)->my_lba), in is_gpt_valid()
397 if (le64_to_cpu((*gpt)->first_usable_lba) > lastlba) { in is_gpt_valid()
399 (unsigned long long)le64_to_cpu((*gpt)->first_usable_lba), in is_gpt_valid()
403 if (le64_to_cpu((*gpt)->last_usable_lba) > lastlba) { in is_gpt_valid()
405 (unsigned long long)le64_to_cpu((*gpt)->last_usable_lba), in is_gpt_valid()
409 if (le64_to_cpu((*gpt)->last_usable_lba) < le64_to_cpu((*gpt)->first_usable_lba)) { in is_gpt_valid()
411 (unsigned long long)le64_to_cpu((*gpt)->last_usable_lba), in is_gpt_valid()
412 (unsigned long long)le64_to_cpu((*gpt)->first_usable_lba)); in is_gpt_valid()
416 if (le32_to_cpu((*gpt)->sizeof_partition_entry) != sizeof(gpt_entry)) { in is_gpt_valid()
422 pt_size = (u64)le32_to_cpu((*gpt)->num_partition_entries) * in is_gpt_valid()
423 le32_to_cpu((*gpt)->sizeof_partition_entry); in is_gpt_valid()
430 if (!(*ptes = alloc_read_gpt_entries(state, *gpt))) in is_gpt_valid()
436 if (crc != le32_to_cpu((*gpt)->partition_entry_array_crc32)) { in is_gpt_valid()
448 kfree(*gpt); in is_gpt_valid()
449 *gpt = NULL; in is_gpt_valid()
581 static int find_valid_gpt(struct parsed_partitions *state, gpt_header **gpt, in find_valid_gpt() argument
642 *gpt = pgpt; in find_valid_gpt()
651 *gpt = agpt; in find_valid_gpt()
664 *gpt = NULL; in find_valid_gpt()
715 gpt_header *gpt = NULL; in efi_partition() local
720 if (!find_valid_gpt(state, &gpt, &ptes) || !gpt || !ptes) { in efi_partition()
721 kfree(gpt); in efi_partition()
728 for (i = 0; i < le32_to_cpu(gpt->num_partition_entries) && i < state->limit-1; i++) { in efi_partition()
754 kfree(gpt); in efi_partition()