1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Fix Linux blockdevice size computation (#34475)

Linux' sysfs _always_ reports device size in 512b sector units,
regardless of the device's actual, physical blocksize.
This commit is contained in:
Johannes Truschnigg 2018-01-08 15:18:25 +01:00 committed by Adam Miller
parent 9ed4661860
commit 00d75ff449

View file

@ -601,7 +601,7 @@ class LinuxHardware(Hardware):
part['sectorsize'] = get_file_content(part_sysdir + "/queue/logical_block_size")
if not part['sectorsize']:
part['sectorsize'] = get_file_content(part_sysdir + "/queue/hw_sector_size", 512)
part['size'] = bytes_to_human((float(part['sectors']) * float(part['sectorsize'])))
part['size'] = bytes_to_human((float(part['sectors']) * 512.0))
part['uuid'] = get_partition_uuid(partname)
self.get_holders(part, part_sysdir)
@ -621,7 +621,7 @@ class LinuxHardware(Hardware):
d['sectorsize'] = get_file_content(sysdir + "/queue/logical_block_size")
if not d['sectorsize']:
d['sectorsize'] = get_file_content(sysdir + "/queue/hw_sector_size", 512)
d['size'] = bytes_to_human(float(d['sectors']) * float(d['sectorsize']))
d['size'] = bytes_to_human(float(d['sectors']) * 512.0)
d['host'] = ""