Page MenuHomeFreeBSD

Fix output of swapinfo in human readable mode
ClosedPublic

Authored by csjp on Feb 19 2020, 5:16 PM.
Tags
None
Referenced Files
F132252295: D23758.id.diff
Wed, Oct 15, 5:17 AM
F132252290: D23758.id68615.diff
Wed, Oct 15, 5:16 AM
F132252288: D23758.id68546.diff
Wed, Oct 15, 5:16 AM
Unknown Object (File)
Tue, Oct 14, 7:39 PM
Unknown Object (File)
Fri, Oct 3, 6:39 PM
Unknown Object (File)
Wed, Oct 1, 1:50 AM
Unknown Object (File)
Thu, Sep 25, 3:44 PM
Unknown Object (File)
Sep 14 2025, 9:08 PM

Details

Summary
  • Implement -h (human readable) for the size of the underlying block disk. Currently, the size of the swap device is unconditionally reported using blocks, even if -h has been used.
  • While here, switch to CONVERT_BLOCKS() instead of CONVERT() which will avoid overflowing size counters (in human readable form see: r196244)
  • Update the column headers to reflect that a size is being reported instead of the block size units being used

I went back through the revision history and didn't see any reason why this was explicitly not done, but this seems more consistent to me.

Test Plan

Before:

$ swapinfo -h
Device 1K-blocks Used Avail Capacity
/dev/gpt/swapfs 1048576 0B 1.0G 0%
$

After:

$ swapinfo -h
Device Size Used Avail Capacity
/dev/gpt/swapfs 1.0G 0B 1.0G 0%
$

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Not Applicable
Unit
Tests Not Applicable