Add functions to allocate and initialize the bitmap

This make the code a little bit easier to read and maintain.

Signed-off-by: Patryck Rouleau <pfrouleau@gmail.com>
Declare read_bitmap() and initial_image_hdr() in one place

This reduce code duplication and will simplify the modification of their
declaration when they must be updated.

readbitmap() is renamed read_bitmap() to follow the coding standard.

Signed-off-by: Patryck Rouleau <pfrouleau@gmail.com>
Declare fs_opt from fs_common.h instead of declaring it in every fs' implementation

This is simply to reduce code deduplication.

Signed-off-by: Patryck Rouleau <pfrouleau@gmail.com>
Leave the file system implementation to define shared declarations

This help to reduce code duplication and increase code separation. The
code specific to each file system is contained in the related header file.

Signed-off-by: Patryck Rouleau <pfrouleau@gmail.com>
Disable struct's members alignment and regroup the structs' definitions

The compiler automatically align the struct's members on the platform's
memory boundary. This is to prevent a lost of performance when the members
cross the memory boundary of the platform. If the alignment is not disabled,
the image created with a 64 bits version is not usable by a 32 bits version
and vice-versa.

In our case, a padding of 2 bytes is added before block_size to align it
on the next address divisible by 4.

    00000000  70 61 72 74 63 6c 6f 6e  65 2d 69 6d 61 67 65 45  |partclone-imageE|
    00000010  58 54 46 53 00 00 00 00  00 00 00 00 00 00 30 30  |XTFS..........00|
    00000020  30 31 XX XX 00-04-00-00  00-d0-ff-1f-00-00-00-00  |01..............|
    00000030  f4-ff-07-00-00-00-00-00  be-c3-01-00-00-00-00-00  |................|
    00000040  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|

Signed-off-by: Patryck Rouleau <pfrouleau@gmail.com>
Move image_head writing in write_image_head

This change will make the modifications for image version 0002 more
localized.

Signed-off-by: Patryck Rouleau <pfrouleau@gmail.com>
Move bitmap writing in write_image_bitmap()

This change will simplify the implementation of image 0002, in which
the user can choose the bitmap format to be recorded.

Signed-off-by: Patryck Rouleau <pfrouleau@gmail.com>
Move bitmap's signature check in get_image_bitmap()

This change simplify the implementation of image version 0002,
in which we have to read both version.

Signed-off-by: Patryck Rouleau <pfrouleau@gmail.com>
Teach restore_image_hdr() to validate the header he gets from the image

This change is to simplify the handling of various image version.

Signed-off-by: Patryck Rouleau <pfrouleau@gmail.com>