chain/partiter: fix and improve gpt handling in buggy cases
commitf964a9772fb580d373b5b3da88f649f50d575a5a
authorMichal Soltys <soltys@ziu.info>
Sun, 29 Jun 2014 19:41:38 +0000 (29 21:41 +0200)
committerH. Peter Anvin <hpa@zytor.com>
Wed, 27 Aug 2014 01:07:16 +0000 (26 18:07 -0700)
tree85b2bd3783e8dc015510f5308d2b2a180fda67b8
parent1ada8a37ae30c2e4283c3e65444ccd72cf8a2e85
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>
com32/chain/partiter.c