diff options
Diffstat (limited to 'src/header.c')
-rw-r--r-- | src/header.c | 33 |
1 files changed, 26 insertions, 7 deletions
diff --git a/src/header.c b/src/header.c index e4a7e15..1d5ef3e 100644 --- a/src/header.c +++ b/src/header.c @@ -67,6 +67,25 @@ header_calc_ent_crc (DISK * d, GPT_header * h) } +int +header_check_crc (DISK * d, GPT_header * h) +{ + GPT_header c = *h; + uint32_t crc; + + c.header_crc = 0; + crc = crc32 (0, &c, sizeof (c)); + + if (crc != h->header_crc) + return 0; + + crc = header_calc_ent_crc (d, h); + + + + return ! !(crc == h->partition_entry_crc); +} + void header_show (DISK * d, GPT_header * h) { @@ -211,17 +230,17 @@ headers_get_one (DISK * d) disk_read (d, buf, 1, 1); memcpy (&ret.header, buf, sizeof (ret.header)); - table_size=ret.header.first_usable_lba; + table_size = ret.header.first_usable_lba; - ret.header.last_usable_lba=lbas-table_size; + ret.header.last_usable_lba = lbas - table_size; - ret.alt_header=ret.header; + ret.alt_header = ret.header; - ret.header.alternate_lba=lbas-1; + ret.header.alternate_lba = lbas - 1; - ret.alt_header.alternate_lba=1; - ret.alt_header.my_lba=lbas-1; - ret.alt_header.partition_entry_lba = (lbas - table_size)+1; + ret.alt_header.alternate_lba = 1; + ret.alt_header.my_lba = lbas - 1; + ret.alt_header.partition_entry_lba = (lbas - table_size) + 1; |