chain/partiter: fix and improve gpt handling in buggy cases
Previous version had some issues in case of error situations, among
those:
- backup gpt header was not read if reading of primary failed
- alternating nature of lba_cur and lba_alt was ignored
This patch fixes this and extends the gpt handling.
The current behavior is:
- try primary header; if unreadable or checksum fails (or sanity checks
fail unless relax flag is set) - try secondary header
- try main partition table referenced in the header that was read; if
it's unreadable or if its crc check fails - try alternative (so if we
managed to read primary header, table at the end would be considered
as alternative - if we managed to read secondary header, table at the
beginning would be treated as such)
Signed-off-by: H. Peter Anvin <hpa@zytor.com>