mount: Implement statfs interface so df works - fixes #894

The data returned is not related to the files on the remote, but
apparently samba needs it.
This commit is contained in:
Nick Craig-Wood 2016-11-20 22:54:03 +00:00
parent 0b562bcabc
commit c41b67ea08
2 changed files with 21 additions and 0 deletions

View file

@ -8,6 +8,7 @@ import (
"bazil.org/fuse" "bazil.org/fuse"
fusefs "bazil.org/fuse/fs" fusefs "bazil.org/fuse/fs"
"github.com/ncw/rclone/fs" "github.com/ncw/rclone/fs"
"golang.org/x/net/context"
) )
// FS represents the top level filing system // FS represents the top level filing system
@ -97,3 +98,22 @@ func mount(f fs.Fs, mountpoint string) (<-chan error, error) {
return errChan, nil 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
vendor/bazil.org/fuse/fuse.go generated vendored
View file

@ -1262,6 +1262,7 @@ func (r *StatfsRequest) Respond(resp *StatfsResponse) {
Bfree: resp.Bfree, Bfree: resp.Bfree,
Bavail: resp.Bavail, Bavail: resp.Bavail,
Files: resp.Files, Files: resp.Files,
Ffree: resp.Ffree,
Bsize: resp.Bsize, Bsize: resp.Bsize,
Namelen: resp.Namelen, Namelen: resp.Namelen,
Frsize: resp.Frsize, Frsize: resp.Frsize,