Skip to content

Commit

Permalink
fuse: fix free space reporting on Darwin
Browse files Browse the repository at this point in the history
We usually were off by a factor of 256.
Fixes rfjakob/gocryptfs#375
  • Loading branch information
rfjakob authored and hanwen committed Mar 19, 2019
1 parent 0074c95 commit 161a164
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions fuse/types_darwin.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,4 +153,14 @@ func (s *StatfsOut) FromStatfsT(statfs *syscall.Statfs_t) {
s.Ffree = statfs.Ffree
s.Bsize = uint32(statfs.Iosize) // Iosize translates to Bsize: the optimal transfer size.
s.Frsize = s.Bsize // Bsize translates to Frsize: the minimum transfer size.

// The block counts are in units of statfs.Bsize.
// If s.Bsize != statfs.Bsize, we have to recalculate the block counts
// accordingly (s.Bsize is usually 256*statfs.Bsize).
if s.Bsize > statfs.Bsize {
adj := uint64(s.Bsize / statfs.Bsize)
s.Blocks /= adj
s.Bfree /= adj
s.Bavail /= adj
}
}

0 comments on commit 161a164

Please sign in to comment.