Lines Matching full:gpt

19  *   AGPT, allow override with 'gpt' kernel command line option.
40 * - moved le_efi_guid_to_cpus() back into this file. GPT is the only
42 * - Changed gpt structure names and members to be simpler and more Linux-like.
64 * - Added kernel command line option 'gpt' to override valid PMBR test.
93 /* This allows a kernel command line option 'gpt' to override
104 __setup("gpt", force_gpt_fn);
145 /* set to 0x00000001 (i.e., the LBA of the GPT Partition Header) */ in pmbr_part_valid()
167 * marked out by up to three GPT partitions.
217 pr_debug("GPT: mbr size in lba (%u) different than whole disk (%u).\n", in is_pmbr_valid()
265 * @gpt: GPT header
268 * Allocates space for PTEs based on information found in @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()
298 * alloc_read_gpt_header(): Allocates GPT header, reads into it from disk
302 * Description: returns GPT header on success, NULL on error. Allocates
303 * and fills a GPT header starting at @ from @state->disk.
304 * Note: remember to free gpt when finished with it.
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()
326 * is_gpt_valid() - tests one GPT header and PTEs for validity
328 * @lba: logical block address of the GPT header to test
329 * @gpt: GPT header ptr, filled on return.
333 * If valid, returns pointers to newly allocated GPT header and PTEs.
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()
387 pr_debug("GPT my_lba incorrect: %lld != %lld\n", 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()
398 pr_debug("GPT: first_usable_lba incorrect: %lld > %lld\n", 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()
404 pr_debug("GPT: last_usable_lba incorrect: %lld > %lld\n", 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()
410 pr_debug("GPT: last_usable_lba incorrect: %lld > %lld\n", 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()
471 * compare_gpts() - Search disk for valid GPT headers and PTEs
472 * @pgpt: primary GPT header
473 * @agpt: alternate GPT header
487 pr_warn("GPT:Primary header LBA != Alt. header alternate_lba\n"); in compare_gpts()
488 pr_warn("GPT:%lld != %lld\n", in compare_gpts()
494 pr_warn("GPT:Primary header alternate_lba != Alt. header my_lba\n"); in compare_gpts()
495 pr_warn("GPT:%lld != %lld\n", in compare_gpts()
502 pr_warn("GPT:first_usable_lbas don't match.\n"); in compare_gpts()
503 pr_warn("GPT:%lld != %lld\n", in compare_gpts()
510 pr_warn("GPT:last_usable_lbas don't match.\n"); in compare_gpts()
511 pr_warn("GPT:%lld != %lld\n", in compare_gpts()
517 pr_warn("GPT:disk_guids don't match.\n"); in compare_gpts()
522 pr_warn("GPT:num_partition_entries don't match: " in compare_gpts()
530 pr_warn("GPT:sizeof_partition_entry values don't match: " in compare_gpts()
538 pr_warn("GPT:partition_entry_array_crc32 values don't match: " in compare_gpts()
545 pr_warn("GPT:Primary header thinks Alt. header is not at the end of the disk.\n"); in compare_gpts()
546 pr_warn("GPT:%lld != %lld\n", in compare_gpts()
553 pr_warn("GPT:Alternate GPT header not at the end of the disk.\n"); in compare_gpts()
554 pr_warn("GPT:%lld != %lld\n", in compare_gpts()
561 pr_warn("GPT: Use GNU Parted to correct GPT errors.\n"); in compare_gpts()
566 * find_valid_gpt() - Search disk for valid GPT headers and PTEs
568 * @gpt: GPT header ptr, filled on return.
572 * If valid, returns pointers to newly allocated GPT header and PTEs.
574 * 'gpt' kernel command line option) and finding either the Primary
575 * GPT header and PTEs valid, or the Alternate GPT header and PTEs
576 * valid. If the Primary GPT header is not valid, the Alternate GPT header
577 * is not checked unless the 'gpt' kernel command line option is passed.
579 * the user to decide to use the Alternate GPT.
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()
647 pr_warn("Alternate GPT is invalid, using primary GPT.\n"); in find_valid_gpt()
651 *gpt = agpt; in find_valid_gpt()
655 pr_warn("Primary GPT is invalid, using alternate GPT.\n"); in find_valid_gpt()
664 *gpt = NULL; in find_valid_gpt()
695 * efi_partition - scan for GPT partitions
698 * Description: called from check.c, if the disk contains GPT
705 * We do not create a Linux partition for GPT, but
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()