Skip to content

Commit

Permalink
vfs: make df output more consistent on a rclone mount.
Browse files Browse the repository at this point in the history
When 2 values are known among vfs:{free,used,total}, compute the 3rd
  • Loading branch information
Yves G authored and ncw committed Mar 1, 2020
1 parent 2b268f9 commit b1b5e09
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions vfs/vfs.go
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,15 @@ func (vfs *VFS) Statfs() (total, used, free int64) {
if u.Used != nil {
used = *u.Used
}
if total < 0 && free >= 0 && used >= 0 {
total = free + used
}
if free < 0 && total >= 0 && used >= 0 {
free = total - used
}
if used < 0 && total >= 0 && free >= 0 {
used = total - free
}
}
return
}

0 comments on commit b1b5e09

Please sign in to comment.