Report offsets when wiping device signatures.

Fixes: #489.
This commit is contained in:
Ondrej Kozina
2019-10-08 13:46:52 +02:00
committed by Milan Broz
parent 99c4e83994
commit 86bb4ea8f2
3 changed files with 20 additions and 4 deletions

View File

@@ -307,3 +307,17 @@ int blk_supported(void)
#endif
return r;
}
off_t blk_get_offset(struct blkid_handle *h)
{
const char *offset;
off_t offset_value = -1;
#ifdef HAVE_BLKID
if (blk_is_superblock(h)) {
if (!blkid_probe_lookup_value(h->pr, "SBMAGIC_OFFSET", &offset, NULL))
offset_value = strtoll(offset, NULL, 10);
} else if (blk_is_partition(h) && !blkid_probe_lookup_value(h->pr, "PTMAGIC_OFFSET", &offset, NULL))
offset_value = strtoll(offset, NULL, 10);
#endif
return offset_value;
}