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