ext4_utils: correctly read block group descriptors on 64bit filesystems

ext4_utils isn't aware of filesystems with the "64bit" feature.  The
64bit feature changes the filesystem-wide block numbers to be 64-bit
instead of 32-bit, and it increases the size of the block group
descriptors.  Apparently we've gotten away with this until now since
ext4 filesystems in Android haven't been using the 64bit feature.

However, change I618a65d7afc63a617f5f2582c93002af7f8e7234 added support
for the metadata_csum feature, and Android enables 64bit whenever
metadata_csum is enabled because it improves the usefulness of
metadata_csum.  Separately, when Cuttlefish is configured to use ext4
and 'launch_cvd -data_policy always_create' is used, the filesystem ends
up with the 64bit feature because the host's mke2fs.conf is used.

vold's encrypt-in-place code doesn't work correctly on 64bit
filesystems, since it uses the block group descriptors to identify
in-use blocks, and ext4_utils mis-reads the descriptors such that
descriptor 'i' gets read into the structs for descriptors 2*i and 2*i+1.
Note that this is a problem even if the filesystem doesn't contain more
than 2^32 blocks (which can still be assumed to be true on Android).

So, fix ext4_utils to correctly read the block group descriptors on both
64bit and !64bit filesystems.

Test: Booted Cuttlefish with ext4 + metadata encryption, both with and
      without the 64bit feature.  Before, it only worked with !64bit.
Change-Id: I0682971e022407f43ccb3b08c997b787d1a9e649
4 files changed