disk: read up to 4K block when detecting image type
disk: read up to 4K block when detecting image type

This makes detect_image_type do a single read of size 4096 instead of
doing two smaller reads matching the size of the magic values.  This
eliminates one source of misaligned disk access, which is needed to
enable O_DIRECT. It also reduces the number of reads required, although
this probably has very little, if any, performance impact.

In addition, the magic comparison is rewritten to make the endian
conversion more readable - the qcow2 magic number is written in big
endian and the Android sparse disk magic is little endian, but
previously this was unclear since the sparse comparison did a double
big-endian conversion to get to little endian.

BUG=b:184204645
TEST=cargo test -p disk --features=composite-disk

Change-Id: I35ae0a6c415d3cf69733a5c6288b99a4cfb30e2f
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2824810
Reviewed-by: Dylan Reid <c791bfe44996c1eed9c7149a0c5f12a86d58eb85@chromium.org>
Reviewed-by: Junichi Uekawa <6bd240a6ce32463e272bb69c685a8e946b33ac05@chromium.org>
Tested-by: kokoro <2ac7b1f3fa578934c95181d4272be0d3bca00121@google.com>
Commit-Queue: Daniel Verkamp <72bc170b46ec491f7bdd4359a1c0bfed274de40c@chromium.org>

google/crosvm,google/crosvm,google/crosvm,google/crosvm