From c41b67ea0889e14a56c9a8dec28d8d7050b233e9 Mon Sep 17 00:00:00 2001 From: Nick Craig-Wood Date: Sun, 20 Nov 2016 22:54:03 +0000 Subject: [PATCH] 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. --- cmd/mount/fs.go | 20 ++++++++++++++++++++ vendor/bazil.org/fuse/fuse.go | 1 + 2 files changed, 21 insertions(+) diff --git a/cmd/mount/fs.go b/cmd/mount/fs.go index 523268de3..0e63e7557 100644 --- a/cmd/mount/fs.go +++ b/cmd/mount/fs.go @@ -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 @@ -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 +} diff --git a/vendor/bazil.org/fuse/fuse.go b/vendor/bazil.org/fuse/fuse.go index efd684673..c6173b144 100644 --- a/vendor/bazil.org/fuse/fuse.go +++ b/vendor/bazil.org/fuse/fuse.go @@ -1262,6 +1262,7 @@ func (r *StatfsRequest) Respond(resp *StatfsResponse) { Bfree: resp.Bfree, Bavail: resp.Bavail, Files: resp.Files, + Ffree: resp.Ffree, Bsize: resp.Bsize, Namelen: resp.Namelen, Frsize: resp.Frsize,