Commit 1d8a9208 authored by Han-Wen Nienhuys's avatar Han-Wen Nienhuys

Run gofmt.

parent e876d09e
......@@ -52,7 +52,6 @@ func BulkStat(parallelism int, files []string) float64 {
return avg
}
func AnalyzeBenchmarkRuns(times []float64) {
sorted := times
sort.Float64s(sorted)
......@@ -102,7 +101,6 @@ func RunBulkStat(runs int, threads int, sleepTime float64, files []string) (resu
return results
}
func CountCpus() int {
var contents [10240]byte
......
......@@ -2,7 +2,7 @@ package fuse
import (
"bufio"
"fmt"
"fmt"
"io/ioutil"
"log"
"os"
......@@ -15,6 +15,7 @@ import (
)
var CheckSuccess = fuse.CheckSuccess
type StatFs struct {
fuse.DefaultFileSystem
entries map[string]*os.FileInfo
......@@ -27,12 +28,12 @@ func (me *StatFs) add(name string, fi os.FileInfo) {
if ok {
return
}
me.entries[name] = &fi
if name == "/" || name == "" {
return
}
dir, base := filepath.Split(name)
dir = strings.TrimRight(dir, "/")
me.dirs[dir] = append(me.dirs[dir], fuse.DirEntry{Name: base, Mode: fi.Mode})
......@@ -64,7 +65,7 @@ func (me *StatFs) OpenDir(name string) (stream chan fuse.DirEntry, status fuse.S
func NewStatFs() *StatFs {
return &StatFs{
entries: make(map[string]*os.FileInfo),
dirs: make(map[string][]fuse.DirEntry),
dirs: make(map[string][]fuse.DirEntry),
}
}
......@@ -94,7 +95,7 @@ func TestNewStatFs(t *testing.T) {
"sub/dir/bar.txt", "sub/marine.txt"} {
fs.add(n, os.FileInfo{Mode: fuse.S_IFREG | 0644})
}
wd, clean := setupFs(fs, nil)
defer clean()
......@@ -125,14 +126,14 @@ func TestNewStatFs(t *testing.T) {
if !fi.IsRegular() {
t.Error("mode", fi)
}
}
}
func BenchmarkThreadedStat(b *testing.B) {
b.StopTimer()
fs := NewStatFs()
wd, _ := os.Getwd()
// Names from OpenJDK 1.6
f, err := os.Open(wd + "/testpaths.txt")
f, err := os.Open(wd + "/testpaths.txt")
CheckSuccess(err)
defer f.Close()
......@@ -144,7 +145,7 @@ func BenchmarkThreadedStat(b *testing.B) {
if line == nil || err != nil {
break
}
fn := string(line)
files = append(files, fn)
......@@ -158,8 +159,8 @@ func BenchmarkThreadedStat(b *testing.B) {
ttl := 0.1
opts := fuse.FileSystemOptions{
EntryTimeout: ttl,
AttrTimeout: ttl,
EntryTimeout: ttl,
AttrTimeout: ttl,
NegativeTimeout: 0.0,
}
wd, clean := setupFs(fs, &opts)
......@@ -171,7 +172,7 @@ func BenchmarkThreadedStat(b *testing.B) {
log.Println("N = ", b.N)
threads := runtime.GOMAXPROCS(0)
results := TestingBOnePass(b, threads, ttl * 1.2, files)
results := TestingBOnePass(b, threads, ttl*1.2, files)
AnalyzeBenchmarkRuns(results)
}
......
......@@ -12,7 +12,6 @@ var _ = fmt.Println
func (me *DefaultRawFileSystem) Init(init *RawFsInit) {
}
func (me *DefaultRawFileSystem) StatFs() *StatfsOut {
return nil
}
......
......@@ -95,7 +95,6 @@ func (me *LoopbackFile) Fsync(*FsyncIn) (code Status) {
return Status(syscall.Fsync(me.File.Fd()))
}
func (me *LoopbackFile) Truncate(size uint64) Status {
return Status(syscall.Ftruncate(me.File.Fd(), int64(size)))
}
......
......@@ -31,7 +31,7 @@ type Handled struct {
// 32 bits version of HandleMap
type int32HandleMap struct {
mutex sync.Mutex
mutex sync.Mutex
handles map[uint32]*Handled
}
......@@ -59,7 +59,6 @@ func (me *int32HandleMap) Forget(handle uint64) *Handled {
return val
}
// 64 bits version of HandleMap
type int64HandleMap struct {
mutex sync.Mutex
......@@ -91,13 +90,12 @@ func NewHandleMap() (hm HandleMap) {
}
case 4:
return &int32HandleMap{
handles: make(map[uint32]*Handled),
handles: make(map[uint32]*Handled),
}
}
return nil
}
func (me *int64HandleMap) Count() int {
me.mutex.Lock()
defer me.mutex.Unlock()
......@@ -136,7 +134,7 @@ func (me *int64HandleMap) Register(obj *Handled) (handle uint64) {
func (me *int64HandleMap) Forget(handle uint64) (val *Handled) {
defer me.verify()
val = DecodeHandle(handle)
me.mutex.Lock()
......
......@@ -163,7 +163,6 @@ func (me *LoopbackFileSystem) Name() string {
return fmt.Sprintf("LoopbackFileSystem(%s)", me.Root)
}
func (me *LoopbackFileSystem) StatFs() *StatfsOut {
s := syscall.Statfs_t{}
errNo := syscall.Statfs(me.Root, &s)
......@@ -171,13 +170,13 @@ func (me *LoopbackFileSystem) StatFs() *StatfsOut {
if errNo == 0 {
return &StatfsOut{
Kstatfs{
Blocks: s.Blocks,
Bsize: uint32(s.Bsize),
Bfree: s.Bfree,
Bavail: s.Bavail,
Files: s.Files,
Ffree: s.Ffree,
Frsize: uint32(s.Frsize),
Blocks: s.Blocks,
Bsize: uint32(s.Bsize),
Bfree: s.Bfree,
Bavail: s.Bavail,
Files: s.Files,
Ffree: s.Ffree,
Frsize: uint32(s.Frsize),
NameLen: uint32(s.Namelen),
},
}
......
......@@ -551,7 +551,6 @@ func randomLengthString(length int) string {
return string(b)
}
func TestLargeDirRead(t *testing.T) {
me := NewTestCase(t)
defer me.Cleanup()
......@@ -657,9 +656,7 @@ func TestStatFs(t *testing.T) {
t.Fatal("statfs mnt", err)
}
if fmt.Sprintf("%v", s2) != fmt.Sprintf("%v", s1) {
if fmt.Sprintf("%v", s2) != fmt.Sprintf("%v", s1) {
t.Error("Mismatch", s1, s2)
}
}
......@@ -6,7 +6,6 @@ import (
"syscall"
)
func TestOsErrorToErrno(t *testing.T) {
errNo := OsErrorToErrno(os.EPERM)
if errNo != syscall.EPERM {
......
......@@ -167,6 +167,6 @@ func init() {
umountBinary = tpath
break
}
}
}
......@@ -5,7 +5,6 @@ import (
"testing"
)
type ownerFs struct {
DefaultFileSystem
}
......@@ -16,13 +15,13 @@ func (me *ownerFs) GetAttr(name string) (*os.FileInfo, Status) {
if name == "" {
return &os.FileInfo{
Mode: S_IFDIR | 0755,
},OK
}, OK
}
return &os.FileInfo{
Mode: S_IFREG | 0644,
Uid: _RANDOM_OWNER,
Gid: _RANDOM_OWNER,
},OK
}, OK
}
func setupOwnerTest(opts *FileSystemOptions) (workdir string, cleanup func()) {
......
......@@ -594,7 +594,7 @@ func (me *FileSystemConnector) Unmount(path string) Status {
me.unsafeUnmountNode(node)
notifyMessage := NotifyInvalInodeOut{
Ino: node.NodeId,
Ino: node.NodeId,
}
me.fsInit.InodeNotify(&notifyMessage)
......
......@@ -93,7 +93,6 @@ func (me *FileSystemConnector) internalLookupWithNode(parent *inode, name string
return out, OK, node
}
func (me *FileSystemConnector) Forget(h *InHeader, input *ForgetIn) {
me.forgetUpdate(h.NodeId, int(input.Nlookup))
}
......@@ -523,4 +522,3 @@ func (me *FileSystemConnector) Ioctl(header *InHeader, input *IoctlIn) (out *Ioc
func (me *FileSystemConnector) StatFs() *StatfsOut {
return me.rootNode.mountPoint.fs.StatFs()
}
......@@ -49,7 +49,6 @@ func (p SwitchedFileSystems) Swap(i, j int) {
p[j] = swFs
}
func NewSwitchFileSystem(fsMap []SwitchedFileSystem) *SwitchFileSystem {
me := &SwitchFileSystem{}
for _, inSwFs := range fsMap {
......
......@@ -49,7 +49,6 @@ func TestSwitchFs(t *testing.T) {
}
}
func TestSwitchFsStrip(t *testing.T) {
fsMap := []SwitchedFileSystem{
SwitchedFileSystem{Prefix: ""},
......
......@@ -216,7 +216,6 @@ func (me *AutoUnionFs) Symlink(pointedTo string, linkName string) (code fuse.Sta
return fuse.EPERM
}
func (me *AutoUnionFs) Unlink(path string) (code fuse.Status) {
comps := strings.Split(path, "/")
if len(comps) != 2 {
......@@ -365,4 +364,3 @@ func (me *AutoUnionFs) OpenDir(name string) (stream chan fuse.DirEntry, status f
func (me *AutoUnionFs) StatFs() *fuse.StatfsOut {
return &fuse.StatfsOut{}
}
......@@ -23,7 +23,6 @@ var testAOpts = AutoUnionFsOptions{
},
}
func WriteFile(name string, contents string) {
err := ioutil.WriteFile(name, []byte(contents), 0644)
CheckSuccess(err)
......
......@@ -12,7 +12,6 @@ import (
var _ = fmt.Print
var _ = log.Print
func modeMapEq(m1, m2 map[string]uint32) bool {
if len(m1) != len(m2) {
return false
......
......@@ -558,7 +558,7 @@ func (me *UnionFs) GetAttr(name string) (a *os.FileInfo, s fuse.Status) {
if name == _DROP_CACHE {
return &os.FileInfo{
Mode: fuse.S_IFREG | 0777,
},fuse.OK
}, fuse.OK
}
if name == me.options.DeletionDirName {
return nil, fuse.ENOENT
......
......@@ -8,7 +8,6 @@ import (
"path/filepath"
)
type MemFile interface {
Stat() *os.FileInfo
Data() []byte
......@@ -72,7 +71,6 @@ func (me *MemTree) FindDir(name string) *MemTree {
return s
}
////////////////////////////////////////////////////////////////
type MemTreeFileSystem struct {
......
......@@ -24,7 +24,6 @@ const (
CONFIG_PREFIX = "config/"
)
////////////////////////////////////////////////////////////////
// MultiZipFs is a path filesystem that mounts zipfiles. It needs a
......
......@@ -13,7 +13,6 @@ var CheckSuccess = fuse.CheckSuccess
const testTtl = 0.1
func setupMzfs() (mountPoint string, cleanup func()) {
fs := NewMultiZipFs()
mountPoint = fuse.MakeTempDir()
......
......@@ -30,7 +30,6 @@ func HeaderToFileInfo(h *tar.Header) *os.FileInfo {
}
}
type TarFile struct {
data []byte
tar.Header
......
......@@ -46,7 +46,6 @@ func (me *ZipFile) Data() []byte {
return data
}
func zipFilesToTree(files []*zip.File) *MemTree {
t := NewMemTree()
for _, f := range files {
......@@ -69,7 +68,6 @@ func zipFilesToTree(files []*zip.File) *MemTree {
return t
}
// NewZipTree creates a new file-system for the zip file named name.
func NewZipTree(name string) (*MemTree, os.Error) {
r, err := zip.OpenReader(name)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment