Skip to content

Commit

Permalink
Prevent usage exceeding 100% for incorrectly reported values
Browse files Browse the repository at this point in the history
  • Loading branch information
muesli committed Sep 25, 2020
1 parent 892b66e commit b9f0e24
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions table.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,15 @@ func printTable(title string, m []Mount, sortBy int, cols []int) {
var usage, inodeUsage float64
if v.Total > 0 {
usage = float64(v.Used) / float64(v.Total)
if usage > 1.0 {
usage = 1.0
}
}
if v.Inodes > 0 {
inodeUsage = float64(v.InodesUsed) / float64(v.Inodes)
if inodeUsage > 1.0 {
inodeUsage = 1.0
}
}

tab.AppendRow([]interface{}{
Expand Down

0 comments on commit b9f0e24

Please sign in to comment.