Reverted changes to memfs.

statfs(2) is more involved than I expected, so this calls for its own
sample file system to test in a more focused manner.
geesefs-0-30-9
Aaron Jacobs 2015-09-09 13:21:58 +10:00
parent 212f7cdd8a
commit d435a1a091
2 changed files with 0 additions and 58 deletions

View File

@ -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) {

View File

@ -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)
}