Add support for superblock BLOCK_SIZE property.

This commit is contained in:
Ondrej Kozina
2022-04-13 12:30:06 +02:00
committed by Milan Broz
parent f1eea3a4b3
commit be5c5788d4
2 changed files with 15 additions and 0 deletions

View File

@@ -326,3 +326,16 @@ int blk_supported(void)
#endif
return r;
}
unsigned blk_get_block_size(struct blkid_handle *h)
{
const char *data;
unsigned block_size = 0;
#ifdef HAVE_BLKID
if (!blk_is_superblock(h) || !blkid_probe_has_value(h->pr, "BLOCK_SIZE") ||
blkid_probe_lookup_value(h->pr, "BLOCK_SIZE", &data, NULL) ||
sscanf(data, "%u", &block_size) != 1)
block_size = 0;
#endif
return block_size;
}

View File

@@ -62,4 +62,6 @@ int blk_do_wipe(struct blkid_handle *h);
int blk_supported(void);
unsigned blk_get_block_size(struct blkid_handle *h);
#endif