Fix Linux Sector count Fact (#81246)

* Use sectorsize fact in disk size calc rather than hardcoded 512

* Added conversion for sysfs sectorcount to real sector count
pull/83437/head
Luke Davidson 6 months ago committed by GitHub
parent a9b902f579
commit 72a5957720
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -794,12 +794,12 @@ class LinuxHardware(Hardware):
part['links'][link_type] = link_values.get(partname, [])
part['start'] = get_file_content(part_sysdir + "/start", 0)
part['sectors'] = get_file_content(part_sysdir + "/size", 0)
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']) * 512.0))
# sysfs sectorcount assumes 512 blocksize. Convert using the correct sectorsize
part['sectors'] = int(get_file_content(part_sysdir + "/size", 0)) * 512 // int(part['sectorsize'])
part['size'] = bytes_to_human(float(part['sectors']) * float(part['sectorsize']))
part['uuid'] = get_partition_uuid(partname)
self.get_holders(part, part_sysdir)
@ -813,13 +813,14 @@ class LinuxHardware(Hardware):
if m:
d['scheduler_mode'] = m.group(2)
d['sectors'] = get_file_content(sysdir + "/size")
if not d['sectors']:
d['sectors'] = 0
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']) * 512.0)
# sysfs sectorcount assumes 512 blocksize. Convert using the correct sectorsize
d['sectors'] = int(get_file_content(sysdir + "/size")) * 512 // int(d['sectorsize'])
if not d['sectors']:
d['sectors'] = 0
d['size'] = bytes_to_human(float(d['sectors']) * float(d['sectorsize']))
d['host'] = ""

Loading…
Cancel
Save