Skip to content

Commit

Permalink
mount: Implement statfs interface so df works - fixes rclone#894
Browse files Browse the repository at this point in the history
The data returned is not related to the files on the remote, but
apparently samba needs it.
  • Loading branch information
ncw committed Nov 20, 2016
1 parent 0b562bc commit c41b67e
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
20 changes: 20 additions & 0 deletions cmd/mount/fs.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"bazil.org/fuse"
fusefs "bazil.org/fuse/fs"
"github.com/ncw/rclone/fs"
"golang.org/x/net/context"
)

// FS represents the top level filing system
Expand Down Expand Up @@ -97,3 +98,22 @@ func mount(f fs.Fs, mountpoint string) (<-chan error, error) {

return errChan, nil
}

// Check interface satsified
var _ fusefs.FSStatfser = (*FS)(nil)

// Statfs is called to obtain file system metadata.
// It should write that data to resp.
func (f *FS) Statfs(ctx context.Context, req *fuse.StatfsRequest, resp *fuse.StatfsResponse) error {
const blockSize = 4096
const fsBlocks = (1 << 50) / blockSize
resp.Blocks = fsBlocks // Total data blocks in file system.
resp.Bfree = fsBlocks // Free blocks in file system.
resp.Bavail = fsBlocks // Free blocks in file system if you're not root.
resp.Files = 1E9 // Total files in file system.
resp.Ffree = 1E9 // Free files in file system.
resp.Bsize = blockSize // Block size
resp.Namelen = 255 // Maximum file name length?
resp.Frsize = blockSize // Fragment size, smallest addressable data size in the file system.
return nil
}
1 change: 1 addition & 0 deletions vendor/bazil.org/fuse/fuse.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit c41b67e

Please sign in to comment.