From be5c5788d4bbef1d02ef6e734342c99bb51cfacd Mon Sep 17 00:00:00 2001 From: Ondrej Kozina Date: Wed, 13 Apr 2022 12:30:06 +0200 Subject: [PATCH] Add support for superblock BLOCK_SIZE property. --- lib/utils_blkid.c | 13 +++++++++++++ lib/utils_blkid.h | 2 ++ 2 files changed, 15 insertions(+) diff --git a/lib/utils_blkid.c b/lib/utils_blkid.c index e0952ede..2e58783b 100644 --- a/lib/utils_blkid.c +++ b/lib/utils_blkid.c @@ -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; +} diff --git a/lib/utils_blkid.h b/lib/utils_blkid.h index 7ed6319d..78fb8679 100644 --- a/lib/utils_blkid.h +++ b/lib/utils_blkid.h @@ -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