Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source Code:block\partitions\efi.c Create Date:2022-07-28 17:31:35
Last Modify:2020-03-12 14:18:49 Copyright©Brick
home page Tree
Annotation kernel can get tool activityDownload SCCTChinese

Name:s_gpt_valid() - tests one GPT header and PTEs for validity*@state: disk parsed partitions*@lba: logical block address of the GPT header to test*@gpt: GPT header ptr, filled on return.*@ptes: PTEs ptr, filled on return.

Proto:static int is_gpt_valid(struct parsed_partitions *state, u64 lba, gpt_header **gpt, gpt_entry **ptes)

Type:int

Parameter:

TypeParameterName
struct parsed_partitions *state
u64lba
gpt_header **gpt
gpt_entry **ptes
343  If Not ptes Then Return 0
345  If Not (gpt = alloc_read_gpt_header(): Allocates GPT header, reads into it from disk*@state: disk parsed partitions*@lba: the Logical Block Address of the partition table* Description: returns GPT header on success, NULL on error. Allocates) Then Return 0
349  If le64_to_cpu(signature) != GPT_HEADER_SIGNATURE Then
350  pr_debug("GUID Partition Table Header signature is wrong:%lld != %lld\n", (unsignedlonglong)le64_to_cpu(signature), (unsignedlonglong)GPT_HEADER_SIGNATURE)
354  Go to fail
358  If le32_to_cpu(header_size) > bdev_logical_block_size(bdev) Then
360  pr_debug("GUID Partition Table Header size is too large: %u > %u\n", le32_to_cpu(header_size), bdev_logical_block_size(bdev))
363  Go to fail
367  If le32_to_cpu(header_size) < sizeof(gpt_header) Then
368  pr_debug("GUID Partition Table Header size is too small: %u < %zu\n", le32_to_cpu(header_size), sizeof(gpt_header))
371  Go to fail
375  origcrc = le32_to_cpu(header_crc32)
376  header_crc32 = 0
377  crc = _crc32() - EFI version of crc32 function*@buf: buffer to calculate crc32 of*@len: length of buf* Description: Returns EFI-style CRC32 value for @buf* This function uses the little endian Ethernet polynomial
379  If crc != origcrc Then
380  pr_debug("GUID Partition Table Header CRC is wrong: %x != %x\n", crc, origcrc)
382  Go to fail
384  header_crc32 = cpu_to_le32(origcrc)
388  If le64_to_cpu(my_lba) != lba Then
389  pr_debug("GPT my_lba incorrect: %lld != %lld\n", (unsignedlonglong)le64_to_cpu(my_lba), (unsignedlonglong)lba)
392  Go to fail
398  lastlba = last_lba(): return number of last logical block of device*@bdev: block device* Description: Returns last LBA value on success, 0 on error.* This is stored (by sd and ide-geometry) in* the part[0] entry for this disk, and is the number of
399  If le64_to_cpu(first_usable_lba) > lastlba Then
400  pr_debug("GPT: first_usable_lba incorrect: %lld > %lld\n", (unsignedlonglong)le64_to_cpu(first_usable_lba), (unsignedlonglong)lastlba)
403  Go to fail
405  If le64_to_cpu(last_usable_lba) > lastlba Then
406  pr_debug("GPT: last_usable_lba incorrect: %lld > %lld\n", (unsignedlonglong)le64_to_cpu(last_usable_lba), (unsignedlonglong)lastlba)
409  Go to fail
411  If le64_to_cpu(last_usable_lba) < le64_to_cpu(first_usable_lba) Then
412  pr_debug("GPT: last_usable_lba incorrect: %lld > %lld\n", (unsignedlonglong)le64_to_cpu(last_usable_lba), (unsignedlonglong)le64_to_cpu(first_usable_lba))
415  Go to fail
418  If le32_to_cpu(sizeof_partition_entry) != sizeof(gpt_entry) Then
419  pr_debug("GUID Partition Entry Size check failed.\n")
420  Go to fail
424  pt_size = le32_to_cpu(num_partition_entries) * le32_to_cpu(sizeof_partition_entry)
426  If pt_size > Maximum allocatable size Then
427  pr_debug("GUID Partition Table is too large: %llu > %lu bytes\n", (unsignedlonglong)pt_size, Maximum allocatable size )
429  Go to fail
432  If Not (ptes = alloc_read_gpt_entries(): reads partition entries from disk*@state: disk parsed partitions*@gpt: GPT header* Description: Returns ptes on success, NULL on error) Then Go to fail
436  crc = _crc32() - EFI version of crc32 function*@buf: buffer to calculate crc32 of*@len: length of buf* Description: Returns EFI-style CRC32 value for @buf* This function uses the little endian Ethernet polynomial
438  If crc != le32_to_cpu(partition_entry_array_crc32) Then
439  pr_debug("GUID Partition Entry Array CRC check failed.\n")
440  Go to fail_ptes
444  Return 1
446  fail_ptes :
447  kfree( * ptes)
448  * ptes = NULL
449  fail :
450  kfree( * gpt)
451  * gpt = NULL
452  Return 0
Caller
NameDescribe
find_valid_gptd_valid_gpt() - Search disk for valid GPT headers and PTEs*@state: disk parsed partitions*@gpt: GPT header ptr, filled on return.*@ptes: PTEs ptr, filled on return.* Description: Returns 1 if valid, 0 on error.