Parse fiemap and return contiguous extents

The extents array returned after a FS_IOC_FIEMAP ioctl may appear more
fragmented than it actually is: a contiguous extent area may be split
into multiple fiemap::fm_extents array elements.

This patch aims at reducing the number of extents stored by merging
those for which:
- There is no extra physical space between two consecutive extents in
the array, and
- The physical distance between two consecutive extents in the array
corresponds to their logical distance (contiguous mapping).

Bug: 144424457
Test: fiemap_writer_test
Change-Id: I3b5b4bc8ffc3f6183ce388d23986812bbe7c1309
Signed-off-by: Alessio Balsini <balsini@google.com>
1 file changed