Commit aed6ef69 authored by Han-Wen Nienhuys's avatar Han-Wen Nienhuys

Run Gofmt.

parent 2445a2e9
...@@ -8,6 +8,7 @@ import ( ...@@ -8,6 +8,7 @@ import (
"flag" "flag"
"runtime" "runtime"
) )
func main() { func main() {
// Scans the arg list and sets up flags // Scans the arg list and sets up flags
debug := flag.Bool("debug", false, "print debugging messages.") debug := flag.Bool("debug", false, "print debugging messages.")
...@@ -31,7 +32,7 @@ func main() { ...@@ -31,7 +32,7 @@ func main() {
if cpus > 1 { if cpus > 1 {
runtime.GOMAXPROCS(cpus) runtime.GOMAXPROCS(cpus)
} }
fmt.Printf("Mounted %s on %s (threaded=%v, debug=%v, cpus=%v)\n", orig, mountPoint, *threaded, *debug, cpus) fmt.Printf("Mounted %s on %s (threaded=%v, debug=%v, cpus=%v)\n", orig, mountPoint, *threaded, *debug, cpus)
state.Loop(*threaded) state.Loop(*threaded)
} }
This diff is collapsed.
...@@ -34,14 +34,14 @@ func FileExists(name string) bool { ...@@ -34,14 +34,14 @@ func FileExists(name string) bool {
const magicMode uint32 = 0753 const magicMode uint32 = 0753
type testCase struct { type testCase struct {
origDir1 string origDir1 string
origDir2 string origDir2 string
mountDir string mountDir string
testDir string testDir string
tester *testing.T tester *testing.T
fs *SubmountFileSystem fs *SubmountFileSystem
state *fuse.MountState state *fuse.MountState
} }
func (self *testCase) Setup(t *testing.T) { func (self *testCase) Setup(t *testing.T) {
...@@ -55,19 +55,19 @@ func (self *testCase) Setup(t *testing.T) { ...@@ -55,19 +55,19 @@ func (self *testCase) Setup(t *testing.T) {
os.Mkdir(self.origDir1, 0700) os.Mkdir(self.origDir1, 0700)
os.Mkdir(self.origDir2, 0700) os.Mkdir(self.origDir2, 0700)
os.Mkdir(self.mountDir, 0700) os.Mkdir(self.mountDir, 0700)
fs1 := fuse.NewPathFileSystemConnector(NewPassThroughFuse(self.origDir1)) fs1 := fuse.NewPathFileSystemConnector(NewPassThroughFuse(self.origDir1))
fs2 := fuse.NewPathFileSystemConnector(NewPassThroughFuse(self.origDir2)) fs2 := fuse.NewPathFileSystemConnector(NewPassThroughFuse(self.origDir2))
self.fs = NewSubmountFileSystem() self.fs = NewSubmountFileSystem()
attr := fuse.Attr{ attr := fuse.Attr{
Mode: uint32(magicMode), Mode: uint32(magicMode),
} }
self.fs.AddFileSystem("sub1", fs1, attr) self.fs.AddFileSystem("sub1", fs1, attr)
self.fs.AddFileSystem("sub2", fs2, attr) self.fs.AddFileSystem("sub2", fs2, attr)
self.state = fuse.NewMountState(self.fs) self.state = fuse.NewMountState(self.fs)
self.state.Mount(self.mountDir) self.state.Mount(self.mountDir)
...@@ -102,7 +102,7 @@ func (self *testCase) testReaddir() { ...@@ -102,7 +102,7 @@ func (self *testCase) testReaddir() {
if err != nil { if err != nil {
self.tester.Errorf("readdir err %v", err) self.tester.Errorf("readdir err %v", err)
} }
wanted := map[string]bool{ wanted := map[string]bool{
"sub1": true, "sub1": true,
"sub2": true, "sub2": true,
...@@ -116,7 +116,7 @@ func (self *testCase) testReaddir() { ...@@ -116,7 +116,7 @@ func (self *testCase) testReaddir() {
self.tester.Errorf("Unexpected name %v", v.Name) self.tester.Errorf("Unexpected name %v", v.Name)
} }
if v.Mode & 0777 != magicMode { if v.Mode&0777 != magicMode {
self.tester.Errorf("Unexpected mode %o, %v", v.Mode, v) self.tester.Errorf("Unexpected mode %o, %v", v.Mode, v)
} }
} }
...@@ -133,7 +133,7 @@ func (self *testCase) testSubFs() { ...@@ -133,7 +133,7 @@ func (self *testCase) testSubFs() {
mount := path.Join(self.mountDir, fmt.Sprintf("sub%d", i)) mount := path.Join(self.mountDir, fmt.Sprintf("sub%d", i))
name := "testFile" name := "testFile"
mountFile := path.Join(mount, name) mountFile := path.Join(mount, name)
f, err := os.Open(mountFile, os.O_WRONLY, 0) f, err := os.Open(mountFile, os.O_WRONLY, 0)
...@@ -142,9 +142,9 @@ func (self *testCase) testSubFs() { ...@@ -142,9 +142,9 @@ func (self *testCase) testSubFs() {
continue continue
} }
content1 := "booh!" content1 := "booh!"
f, err = os.Open(mountFile, os.O_WRONLY | os.O_CREATE, magicMode) f, err = os.Open(mountFile, os.O_WRONLY|os.O_CREATE, magicMode)
if err != nil { if err != nil {
self.tester.Errorf("Create %v", err) self.tester.Errorf("Create %v", err)
} }
f.Write([]byte(content1)) f.Write([]byte(content1))
...@@ -152,21 +152,21 @@ func (self *testCase) testSubFs() { ...@@ -152,21 +152,21 @@ func (self *testCase) testSubFs() {
err = os.Chmod(mountFile, magicMode) err = os.Chmod(mountFile, magicMode)
if err != nil { if err != nil {
self.tester.Errorf("chmod %v", err) self.tester.Errorf("chmod %v", err)
} }
fi, err := os.Lstat(mountFile) fi, err := os.Lstat(mountFile)
if err != nil { if err != nil {
self.tester.Errorf("Lstat %v", err) self.tester.Errorf("Lstat %v", err)
} else { } else {
if fi.Mode & 0777 != magicMode { if fi.Mode&0777 != magicMode {
self.tester.Errorf("Mode %o", fi.Mode) self.tester.Errorf("Mode %o", fi.Mode)
} }
} }
g, err := os.Open(mountFile, os.O_RDONLY, 0) g, err := os.Open(mountFile, os.O_RDONLY, 0)
if err != nil { if err != nil {
self.tester.Errorf("Open %v", err) self.tester.Errorf("Open %v", err)
} else { } else {
buf := make([]byte, 1024) buf := make([]byte, 1024)
n, err := g.Read(buf) n, err := g.Read(buf)
...@@ -184,7 +184,7 @@ func (self *testCase) testSubFs() { ...@@ -184,7 +184,7 @@ func (self *testCase) testSubFs() {
func (self *testCase) testAddRemove() { func (self *testCase) testAddRemove() {
self.tester.Log("testAddRemove") self.tester.Log("testAddRemove")
attr := fuse.Attr{ attr := fuse.Attr{
Mode:0755, Mode: 0755,
} }
conn := fuse.NewPathFileSystemConnector(NewPassThroughFuse(self.origDir1)) conn := fuse.NewPathFileSystemConnector(NewPassThroughFuse(self.origDir1))
...@@ -197,8 +197,8 @@ func (self *testCase) testAddRemove() { ...@@ -197,8 +197,8 @@ func (self *testCase) testAddRemove() {
if !ok { if !ok {
self.tester.Errorf("AddFileSystem fail") self.tester.Errorf("AddFileSystem fail")
} }
conn.Init(new(fuse.InHeader), new(fuse.InitIn)) conn.Init(new(fuse.InHeader), new(fuse.InitIn))
fi, err := os.Lstat(path.Join(self.mountDir, "third")) fi, err := os.Lstat(path.Join(self.mountDir, "third"))
if err != nil { if err != nil {
self.tester.Errorf("third lstat err %v", err) self.tester.Errorf("third lstat err %v", err)
......
...@@ -14,7 +14,7 @@ import ( ...@@ -14,7 +14,7 @@ import (
// TODO make generic option setting. // TODO make generic option setting.
const ( const (
maxRead = (1 << 16) maxRead = (1 << 16)
bufSize = maxRead + 1024 bufSize = maxRead + 1024
) )
......
...@@ -272,14 +272,14 @@ func Writev(fd int, packet [][]byte) (n int, err os.Error) { ...@@ -272,14 +272,14 @@ func Writev(fd int, packet [][]byte) (n int, err os.Error) {
func CountCpus() int { func CountCpus() int {
var contents [10240]byte var contents [10240]byte
f, err := os.Open("/proc/stat", os.O_RDONLY, 0) f, err := os.Open("/proc/stat", os.O_RDONLY, 0)
defer f.Close() defer f.Close()
if err != nil { if err != nil {
return 1 return 1
} }
n, _ := f.Read(contents[:]) n, _ := f.Read(contents[:])
re, _ := regexp.Compile("\ncpu[0-9]") re, _ := regexp.Compile("\ncpu[0-9]")
return len(re.FindAllString(string(contents[:n]), 100)) return len(re.FindAllString(string(contents[:n]), 100))
} }
...@@ -55,9 +55,9 @@ type TimeoutOptions struct { ...@@ -55,9 +55,9 @@ type TimeoutOptions struct {
func MakeTimeoutOptions() TimeoutOptions { func MakeTimeoutOptions() TimeoutOptions {
return TimeoutOptions{ return TimeoutOptions{
NegativeTimeout: 0.0, NegativeTimeout: 0.0,
AttrTimeout: 1.0, AttrTimeout: 1.0,
EntryTimeout: 1.0, EntryTimeout: 1.0,
} }
} }
......
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