As idmag->kboff can be negative to refer to an offset from the end of
the device, introduce a helper so probers don't have to worry about this
detail.
Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
#define blkid_probe_get_sb(_pr, _mag, type) \
((type *) blkid_probe_get_sb_buffer((_pr), _mag, sizeof(type)))
+extern uint64_t blkid_probe_get_idmag_off(blkid_probe pr, const struct blkid_idmag *mag)
+ __attribute__((nonnull));
+
extern blkid_partlist blkid_probe_get_partlist(blkid_probe pr)
__attribute__((nonnull))
__attribute__((warn_unused_result));
return blkid_probe_get_buffer(pr, off, size);
}
+uint64_t blkid_probe_get_idmag_off(blkid_probe pr, const struct blkid_idmag *mag)
+{
+ if (mag->kboff >= 0)
+ return mag->kboff << 10;
+ else
+ return pr->size - (-mag->kboff << 10);
+}
+
/*
* Check for matching magic value.
* Returns BLKID_PROBE_OK if found, BLKID_PROBE_NONE if not found