mirror of
git://sourceware.org/git/lvm2.git
synced 2025-01-02 01:18:26 +03:00
fix libblkid BLOCK_SIZE check
This commit is contained in:
parent
6ea3654868
commit
9fbad5bb0f
@ -649,37 +649,25 @@ out:
|
|||||||
#ifdef BLKID_WIPING_SUPPORT
|
#ifdef BLKID_WIPING_SUPPORT
|
||||||
int get_fs_block_size(struct device *dev, uint32_t *fs_block_size)
|
int get_fs_block_size(struct device *dev, uint32_t *fs_block_size)
|
||||||
{
|
{
|
||||||
blkid_probe probe = NULL;
|
char *block_size_str = NULL;
|
||||||
const char *block_size_str = NULL;
|
|
||||||
uint64_t block_size_val;
|
uint64_t block_size_val;
|
||||||
int r = 0;
|
|
||||||
|
|
||||||
*fs_block_size = 0;
|
if ((block_size_str = blkid_get_tag_value(NULL, "BLOCK_SIZE", dev_name(dev)))) {
|
||||||
|
block_size_val = strtoull(block_size_str, NULL, 10);
|
||||||
if (!(probe = blkid_new_probe_from_filename(dev_name(dev)))) {
|
*fs_block_size = (uint32_t)block_size_val;
|
||||||
log_error("Failed to create a new blkid probe for device %s.", dev_name(dev));
|
free(block_size_str);
|
||||||
goto out;
|
log_debug("Found blkid BLOCK_SIZE %u for fs on %s", *fs_block_size, dev_name(dev));
|
||||||
|
return 1;
|
||||||
|
} else {
|
||||||
|
log_debug("No blkid BLOCK_SIZE for fs on %s", dev_name(dev));
|
||||||
|
*fs_block_size = 0;
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
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
|
#else
|
||||||
int get_fs_block_size(struct device *dev, uint32_t *fs_block_size)
|
int get_fs_block_size(struct device *dev, uint32_t *fs_block_size)
|
||||||
{
|
{
|
||||||
|
log_debug("Disabled blkid BLOCK_SIZE for fs.");
|
||||||
*fs_block_size = 0;
|
*fs_block_size = 0;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user