libfiemap_writer: Handle dm stacking more accurately.

Right now we completely unwind a device-mapper stacking, but this will
produce incorrect results if the stack doesn't have a 1:1 block mapping.
For example, extents against a dynamic partition will be invalid if used
against the underlying block device (super). In this case, abort the
device-mapper unwinding early, and leave it to the caller to decide if
the device is valid.

In addition to fixing a potentially serious bug, this will allow us to
test gsid by simulating various device types (FBE vs FDE, for example).

Bug: 134536978
Test: fiemap_writer_test gtest
Change-Id: I8164e2b71c4868f5494e17e08d209b65fa0ed4ef
3 files changed