diff options
Diffstat (limited to 'lib/device/dev-type.c')
-rw-r--r-- | lib/device/dev-type.c | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/lib/device/dev-type.c b/lib/device/dev-type.c index d225d4d90..deb5d6a0f 100644 --- a/lib/device/dev-type.c +++ b/lib/device/dev-type.c @@ -647,6 +647,45 @@ out: } #ifdef BLKID_WIPING_SUPPORT +int get_fs_block_size(struct device *dev, uint32_t *fs_block_size) +{ + blkid_probe probe = NULL; + const char *block_size_str = NULL; + uint64_t block_size_val; + int r = 0; + + *fs_block_size = 0; + + if (!(probe = blkid_new_probe_from_filename(dev_name(dev)))) { + log_error("Failed to create a new blkid probe for device %s.", dev_name(dev)); + goto out; + } + + blkid_probe_enable_partitions(probe, 1); + + (void) blkid_probe_lookup_value(probe, "BLOCK_SIZE", &block_size_str, NULL); + + if (!block_size_str) + goto out; + + block_size_val = strtoull(block_size_str, NULL, 10); + + *fs_block_size = (uint32_t)block_size_val; + r = 1; +out: + if (probe) + blkid_free_probe(probe); + return r; +} +#else +int get_fs_block_size(struct device *dev, uint32_t *fs_block_size) +{ + *fs_block_size = 0; + return 0; +} +#endif + +#ifdef BLKID_WIPING_SUPPORT static inline int _type_in_flag_list(const char *type, uint32_t flag_list) { |