fixup! Remove the sysdep interface since it is fixed at compilation time
fixup! Remove the sysdep interface since it is fixed at compilation time

fixes indentation
Stops using partclone's head buffer to read the blocks

That buffer is not present in image format 0002.

Signed-off-by: Patryck Rouleau <pfrouleau@gmail.com>
Rewrite partclone's image_head as image_desc as a first step to support format 0002

This rewrite image_desc as three sub-struct to facilitate support for format 0002,
in which the fields are organised differently. Only the "head" struct has the same
size.

Also make the alignment padding explicit by disabling the packing done by
the compiler when defining partclone's structs.

Signed-off-by: Patryck Rouleau <pfrouleau@gmail.com>
Update the code to work with image_desc_v2

This change makes the support of both version sameless. Only the
initialization code have to deal with the difference between image_desc_v1
and image_desc_v2. The rest of the code always uses image_options_v2.

Signed-off-by: Patryck Rouleau <pfrouleau@gmail.com>
Extract some functions from v1_init() to make them available for futur v2_init()

The functions extracted are:
- init_crc32_table()
- init_omode()
- alloc_v1_context()

Signed-off-by: Patryck Rouleau <pfrouleau@gmail.com>
Check the image's head validity when it is read

Signed-off-by: Patryck Rouleau <pfrouleau@gmail.com>
Extract v1_read_bitmap() from v1_verify()

Also create read_bitmap_byte() to be reused with format 0002.

Signed-off-by: Patryck Rouleau <pfrouleau@gmail.com>
Extract generate_usedblocks_map() from v1_verify()

Signed-off-by: Patryck Rouleau <pfrouleau@gmail.com>
Implement v2_init() to read image 0002 description

Also include definition of stubs for the other v2 functions. They will be
implemented in the following commits.

Signed-off-by: Patryck Rouleau <pfrouleau@gmail.com>
Define image_handle.i_dispatch as const to get ride of a compilation warning

Signed-off-by: Patryck Rouleau <pfrouleau@gmail.com>
Define v?_crc32() just under init_crc32_table()

This make possible to call v?_crc32() sooner in the code.

Signed-off-by: Patryck Rouleau <pfrouleau@gmail.com>
Convert the blocks's usage map to a true bitmap format to use less RAM

In partclone's image format 0001, the blocks's usage map is recorded by
using 1 byte per block and libpartclone simple load those. This commit
convert the byte map into a bitmap when reading it. This reduce by ~87%
the amount of RAM used by imagemount.

Signed-off-by: Patryck Rouleau <pfrouleau@gmail.com>
Implements v2_verify() and accompanying read_bitmap_bit()

The blocks's usage map in format 0002 is recorded as a bitmap and can be
absent when all the blocks are in use (like when the file system is not
supported).

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