mirror of
git://sourceware.org/git/lvm2.git
synced 2024-12-21 13:34:40 +03:00
dev-type: get swap device size from blkid using FSSIZE
blkid does not report FSBLOCKSIZE and FSLASTBLOCK for a swap device, because it is not a proper filesystem and it only contains a header marking such devices for use as a swap device. However, blkid does report FSSIZE for swap devices, so use this field instead to set the "filesystem last block" which is used subsequently for further calculations and conditions.
This commit is contained in:
parent
86a9db05cf
commit
a3f6d2f593
@ -913,16 +913,27 @@ int fs_get_blkid(const char *pathname, struct fs_info *fsi)
|
|||||||
if (!blkid_probe_lookup_value(probe, "BLOCK_SIZE", &str, &len) && len)
|
if (!blkid_probe_lookup_value(probe, "BLOCK_SIZE", &str, &len) && len)
|
||||||
fsi->fs_block_size_bytes = atoi(str);
|
fsi->fs_block_size_bytes = atoi(str);
|
||||||
|
|
||||||
if (!blkid_probe_lookup_value(probe, "FSLASTBLOCK", &str, &len) && len)
|
|
||||||
fslastblock = strtoull(str, NULL, 0);
|
|
||||||
|
|
||||||
if (!blkid_probe_lookup_value(probe, "FSBLOCKSIZE", &str, &len) && len)
|
if (!blkid_probe_lookup_value(probe, "FSBLOCKSIZE", &str, &len) && len)
|
||||||
fsblocksize = (unsigned int)atoi(str);
|
fsblocksize = (unsigned int)atoi(str);
|
||||||
|
|
||||||
blkid_free_probe(probe);
|
if (!strcmp(fsi->fstype, "swap")) {
|
||||||
|
/*
|
||||||
|
* For swap, there's no FSLASTBLOCK.
|
||||||
|
* We can use FSSIZE (size of the usable swap area) + FSBLOCKSIZE (size of the swap header)
|
||||||
|
*/
|
||||||
|
if (!blkid_probe_lookup_value(probe, "FSSIZE", &str, &len) && len)
|
||||||
|
fsi->fs_last_byte = strtoull(str, NULL, 0);
|
||||||
|
|
||||||
|
fsi->fs_last_byte += fsblocksize;
|
||||||
|
} else {
|
||||||
|
if (!blkid_probe_lookup_value(probe, "FSLASTBLOCK", &str, &len) && len)
|
||||||
|
fslastblock = strtoull(str, NULL, 0);
|
||||||
|
|
||||||
if (fslastblock && fsblocksize)
|
if (fslastblock && fsblocksize)
|
||||||
fsi->fs_last_byte = fslastblock * fsblocksize;
|
fsi->fs_last_byte = fslastblock * fsblocksize;
|
||||||
|
}
|
||||||
|
|
||||||
|
blkid_free_probe(probe);
|
||||||
|
|
||||||
log_debug("libblkid TYPE %s BLOCK_SIZE %d FSLASTBLOCK %llu FSBLOCKSIZE %u fs_last_byte %llu",
|
log_debug("libblkid TYPE %s BLOCK_SIZE %d FSLASTBLOCK %llu FSBLOCKSIZE %u fs_last_byte %llu",
|
||||||
fsi->fstype, fsi->fs_block_size_bytes, (unsigned long long)fslastblock, fsblocksize,
|
fsi->fstype, fsi->fs_block_size_bytes, (unsigned long long)fslastblock, fsblocksize,
|
||||||
|
Loading…
Reference in New Issue
Block a user