github.com/keybase/client/go@v0.0.0-20241007131713-f10651d043c8/kbfs/libfuse/block_size.go (about) 1 // Copyright 2017 Keybase Inc. All rights reserved. 2 // Use of this source code is governed by a BSD 3 // license that can be found in the LICENSE file. 4 // 5 //go:build !windows 6 // +build !windows 7 8 package libfuse 9 10 // fuseBlockSize is the block size used for calculating number of blocks. This 11 // is to make du/df work, and does not reflect in any way the internal block 12 // size (which is variable). 512 is chosen because FUSE seems to assume this 13 // block size all the time, despite BlockSize is provided in Statfs or Attr 14 // response or not. Bazil FUSE's documentation verifies this: 15 // https://github.com/bazil/fuse/blob/371fbbdaa8987b715bdd21d6adc4c9b20155f748/fuse.go#L1320 16 const fuseBlockSize = 512 17 18 func getNumBlocksFromSize(size uint64) uint64 { 19 if size == 0 { 20 return 0 21 } 22 return (size-1)/fuseBlockSize + 1 23 }