OSDN Git Service

libparted: gpt: a smaller device need not render both headers invalid
authorJim Meyering <meyering@redhat.com>
Mon, 9 Jan 2012 08:21:09 +0000 (09:21 +0100)
committerJim Meyering <meyering@redhat.com>
Mon, 9 Jan 2012 11:02:14 +0000 (12:02 +0100)
commit1159193e4648b9264cbe322c575ae1446be5cf48
tree3380abca99c145324758d5566ea7ac294101541e
parent2f1f6c9a808987c288e83a1e91a23e5d6243066c
libparted: gpt: a smaller device need not render both headers invalid

Putting a valid GPT-labeled image on a smaller device, (i.e., one that
truncates the backup GPT header, but that does not impact the primary
one) should not render the primary header invalid.
* libparted/labels/gpt.c (_header_is_valid): Do *not* reject a header
when its last_usable value is larger than the device length.
This reverts part of commit v3.0-10-g99f9c6a, "gpt: don't abort for a
truncated GPT-formatted device".  With this change, running parted in
interactive mode with such an image/device combination will recognize
that only the backup header is corrupt, and will offer to correct it.
Before, it would report that both headers were corrupt.
* tests/t0203-gpt-shortened-device-primary-valid.sh: New file.
* tests/Makefile.am (TESTS): Add it.
libparted/labels/gpt.c
tests/Makefile.am
tests/t0203-gpt-shortened-device-primary-valid.sh [new file with mode: 0755]