diff --git a/lib/utils_blkid.c b/lib/utils_blkid.c index eaa0f9b3..24961b49 100644 --- a/lib/utils_blkid.c +++ b/lib/utils_blkid.c @@ -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; +} diff --git a/lib/utils_blkid.h b/lib/utils_blkid.h index ee001a18..bd8c3a98 100644 --- a/lib/utils_blkid.h +++ b/lib/utils_blkid.h @@ -59,4 +59,6 @@ int blk_do_wipe(struct blkid_handle *h); int blk_supported(void); +off_t blk_get_offset(struct blkid_handle *h); + #endif diff --git a/src/utils_tools.c b/src/utils_tools.c index 60378277..4f7f79fb 100644 --- a/src/utils_tools.c +++ b/src/utils_tools.c @@ -563,11 +563,11 @@ int tools_wipe_all_signatures(const char *path) while ((pr = blk_probe(h)) < PRB_EMPTY) { if (blk_is_partition(h)) - log_verbose("Existing '%s' partition signature on device %s will be wiped.", - blk_get_partition_type(h), path); + log_verbose("Existing '%s' partition signature (offset: %" PRIi64 " bytes) on device %s will be wiped.", + blk_get_partition_type(h), blk_get_offset(h), path); if (blk_is_superblock(h)) - log_verbose("Existing '%s' superblock signature on device %s will be wiped.", - blk_get_superblock_type(h), path); + log_verbose("Existing '%s' superblock signature (offset: %" PRIi64 " bytes) on device %s will be wiped.", + blk_get_superblock_type(h), blk_get_offset(h), path); if (blk_do_wipe(h)) { log_err(_("Failed to wipe device signature.")); r = -EINVAL;