diff --git a/samples/memfs/memfs.go b/samples/memfs/memfs.go index 61c7834..1d4032c 100644 --- a/samples/memfs/memfs.go +++ b/samples/memfs/memfs.go @@ -28,12 +28,6 @@ import ( "github.com/jacobsa/syncutil" ) -// The capacities of the file system, as reported to statfs(2). -const ( - Capacity_Bytes = 1 << 50 - Capacity_Files = 1 << 30 -) - type memFS struct { fuseutil.NotImplementedFileSystem @@ -190,34 +184,6 @@ func (fs *memFS) deallocateInode(id fuseops.InodeID) { // FileSystem methods //////////////////////////////////////////////////////////////////////// -func (fs *memFS) StatFS( - ctx context.Context, - op *fuseops.StatFSOp) (err error) { - fs.mu.Lock() - defer fs.mu.Unlock() - - // Count free/available bytes and inodes. - op.BlockSize = 1 - op.Blocks = Capacity_Bytes - op.BlocksFree = Capacity_Bytes - op.BlocksAvailable = Capacity_Bytes - - op.Inodes = Capacity_Files - op.InodesFree = Capacity_Files - - for _, in := range fs.inodes { - if in == nil { - continue - } - - op.InodesFree-- - op.BlocksFree -= in.attrs.Size - op.BlocksAvailable -= in.attrs.Size - } - - return -} - func (fs *memFS) LookUpInode( ctx context.Context, op *fuseops.LookUpInodeOp) (err error) { diff --git a/samples/memfs/memfs_test.go b/samples/memfs/memfs_test.go index 0a7ea29..7d47c4f 100644 --- a/samples/memfs/memfs_test.go +++ b/samples/memfs/memfs_test.go @@ -1614,27 +1614,3 @@ func (t *MemFSTest) RenameNonExistentFile() { err = os.Rename(path.Join(t.Dir, "foo"), path.Join(t.Dir, "bar")) ExpectThat(err, Error(HasSubstr("no such file"))) } - -func (t *MemFSTest) Statfs() { - var err error - var stat syscall.Statfs_t - - // Write a few bytes of file content. - const content = "taco" - - err = ioutil.WriteFile(path.Join(t.Dir, "foo"), []byte(content), 0400) - AssertEq(nil, err) - - // Stat the file system. - err = syscall.Statfs(t.Dir, &stat) - AssertEq(nil, err) - - ExpectEq(1, stat.Bsize) - - ExpectEq(memfs.Capacity_Bytes, stat.Blocks) - ExpectEq(memfs.Capacity_Bytes-len(content), stat.Bfree) - ExpectEq(stat.Bfree, stat.Bavail) - - ExpectEq(memfs.Capacity_Files, stat.Files) - ExpectEq(memfs.Capacity_Files-2, stat.Ffree) -}