Exemplo n.º 1
0
// This test is racy. If an external process consumes space while this
// runs, we may see spurious differences between the two statfs() calls.
func TestStatFs(t *testing.T) {
	ts := NewTestCase(t)
	defer ts.Cleanup()

	empty := syscall.Statfs_t{}
	s1 := empty
	err := syscall.Statfs(ts.orig, &s1)
	if err != 0 {
		t.Fatal("statfs orig", err)
	}

	s2 := syscall.Statfs_t{}
	err = syscall.Statfs(ts.mnt, &s2)

	s1.Type = 0
	s2.Type = 0

	s1.Fsid = empty.Fsid
	s2.Fsid = empty.Fsid

	s1.Spare = empty.Spare
	s2.Spare = empty.Spare

	if err != 0 {
		t.Fatal("statfs mnt", err)
	}

	if fmt.Sprintf("%v", s2) != fmt.Sprintf("%v", s1) {
		t.Error("Mismatch", s1, s2)
	}
}
Exemplo n.º 2
0
func clearStatfs(s *syscall.Statfs_t) {
	empty := syscall.Statfs_t{}
	s.Type = 0
	s.Fsid = empty.Fsid
	s.Spare = empty.Spare
	// TODO - figure out what this is for.
	s.Flags = 0
}
func clearStatfs(s *syscall.Statfs_t) {
	empty := syscall.Statfs_t{}

	// FUSE can only set the following fields.
	empty.Blocks = s.Blocks
	empty.Bfree = s.Bfree
	empty.Bavail = s.Bavail
	empty.Files = s.Files
	empty.Ffree = s.Ffree
	empty.Iosize = s.Iosize
	empty.Bsize = s.Bsize
	// Clear out the rest.
	*s = empty
}