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

Run gofmt.

parent eb2b2511
...@@ -39,7 +39,7 @@ func main() { ...@@ -39,7 +39,7 @@ func main() {
state.Loop(*threaded) state.Loop(*threaded)
fmt.Println("Finished", state.Stats()) fmt.Println("Finished", state.Stats())
for v := range(expvar.Iter()) { for v := range expvar.Iter() {
if strings.HasPrefix(v.Key, "mount") { if strings.HasPrefix(v.Key, "mount") {
fmt.Printf("%v: %v\n", v.Key, v.Value) fmt.Printf("%v: %v\n", v.Key, v.Value)
} }
......
...@@ -201,7 +201,7 @@ func (self *DummyPathFuse) OpenDir(name string) (stream chan fuse.DirEntry, stat ...@@ -201,7 +201,7 @@ func (self *DummyPathFuse) OpenDir(name string) (stream chan fuse.DirEntry, stat
return nil, fuse.ENOSYS return nil, fuse.ENOSYS
} }
func (self *DummyPathFuse) Mount(conn *fuse.PathFileSystemConnector) (fuse.Status) { func (self *DummyPathFuse) Mount(conn *fuse.PathFileSystemConnector) fuse.Status {
return fuse.OK return fuse.OK
} }
...@@ -219,4 +219,3 @@ func (self *DummyPathFuse) Create(name string, flags uint32, mode uint32) (file ...@@ -219,4 +219,3 @@ func (self *DummyPathFuse) Create(name string, flags uint32, mode uint32) (file
func (self *DummyPathFuse) Utimens(name string, AtimeNs uint64, CtimeNs uint64) (code fuse.Status) { func (self *DummyPathFuse) Utimens(name string, AtimeNs uint64, CtimeNs uint64) (code fuse.Status) {
return fuse.ENOSYS return fuse.ENOSYS
} }
...@@ -25,7 +25,7 @@ func NewPassThroughFuse(root string) (out *PassThroughFuse) { ...@@ -25,7 +25,7 @@ func NewPassThroughFuse(root string) (out *PassThroughFuse) {
return out return out
} }
func (self *PassThroughFuse) Mount(conn *fuse.PathFileSystemConnector) (fuse.Status) { func (self *PassThroughFuse) Mount(conn *fuse.PathFileSystemConnector) fuse.Status {
return fuse.OK return fuse.OK
} }
......
...@@ -601,7 +601,6 @@ func (self *SubmountFileSystem) ReleaseDir(header *fuse.InHeader, f fuse.RawFuse ...@@ -601,7 +601,6 @@ func (self *SubmountFileSystem) ReleaseDir(header *fuse.InHeader, f fuse.RawFuse
} }
//////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////
type SubmountFileSystemTopDir struct { type SubmountFileSystemTopDir struct {
...@@ -638,4 +637,3 @@ func (self *SubmountFileSystemTopDir) ReleaseDir() { ...@@ -638,4 +637,3 @@ func (self *SubmountFileSystemTopDir) ReleaseDir() {
func (self *SubmountFileSystemTopDir) FsyncDir(input *fuse.FsyncIn) (code fuse.Status) { func (self *SubmountFileSystemTopDir) FsyncDir(input *fuse.FsyncIn) (code fuse.Status) {
return fuse.ENOENT return fuse.ENOENT
} }
...@@ -25,7 +25,7 @@ func IntToExponent(z int) uint { ...@@ -25,7 +25,7 @@ func IntToExponent(z int) uint {
} }
if z > (1 << exp) { if z > (1 << exp) {
exp ++ exp++
} }
return exp return exp
} }
...@@ -38,7 +38,7 @@ func NewBufferPool() *BufferPool { ...@@ -38,7 +38,7 @@ func NewBufferPool() *BufferPool {
func (self *BufferPool) String() string { func (self *BufferPool) String() string {
s := "" s := ""
for exp, bufs := range(self.buffersByExponent) { for exp, bufs := range self.buffersByExponent {
s = s + fmt.Sprintf("%d = %d\n", exp, len(bufs)) s = s + fmt.Sprintf("%d = %d\n", exp, len(bufs))
} }
return s return s
...@@ -50,11 +50,11 @@ func (self *BufferPool) getBuffer(sz int) []byte { ...@@ -50,11 +50,11 @@ func (self *BufferPool) getBuffer(sz int) []byte {
self.lock.Lock() self.lock.Lock()
defer self.lock.Unlock() defer self.lock.Unlock()
if (len(self.buffersByExponent) <= int(exponent)) { if len(self.buffersByExponent) <= int(exponent) {
return nil return nil
} }
bufferList := self.buffersByExponent[exponent] bufferList := self.buffersByExponent[exponent]
if (len(bufferList) == 0) { if len(bufferList) == 0 {
return nil return nil
} }
...@@ -69,7 +69,7 @@ func (self *BufferPool) getBuffer(sz int) []byte { ...@@ -69,7 +69,7 @@ func (self *BufferPool) getBuffer(sz int) []byte {
} }
func (self *BufferPool) addBuffer(slice []byte) { func (self *BufferPool) addBuffer(slice []byte) {
if cap(slice) & (PAGESIZE -1) != 0 { if cap(slice)&(PAGESIZE-1) != 0 {
return return
} }
...@@ -106,4 +106,3 @@ func (self *BufferPool) GetBuffer(size uint32) []byte { ...@@ -106,4 +106,3 @@ func (self *BufferPool) GetBuffer(size uint32) []byte {
return make([]byte, size, rounded) return make([]byte, size, rounded)
} }
...@@ -27,7 +27,7 @@ func TestIntToExponent(t *testing.T) { ...@@ -27,7 +27,7 @@ func TestIntToExponent(t *testing.T) {
func TestBufferPool(t *testing.T) { func TestBufferPool(t *testing.T) {
bp := NewBufferPool() bp := NewBufferPool()
b := bp.getBuffer(PAGESIZE-1) b := bp.getBuffer(PAGESIZE - 1)
if b != nil { if b != nil {
t.Error("bp 0") t.Error("bp 0")
} }
...@@ -36,10 +36,10 @@ func TestBufferPool(t *testing.T) { ...@@ -36,10 +36,10 @@ func TestBufferPool(t *testing.T) {
t.Error("bp 1") t.Error("bp 1")
} }
s := make([]byte, PAGESIZE - 1) s := make([]byte, PAGESIZE-1)
bp.addBuffer(s) bp.addBuffer(s)
b = bp.getBuffer(PAGESIZE -1) b = bp.getBuffer(PAGESIZE - 1)
if b != nil { if b != nil {
t.Error("bp 3") t.Error("bp 3")
} }
...@@ -57,21 +57,21 @@ func TestBufferPool(t *testing.T) { ...@@ -57,21 +57,21 @@ func TestBufferPool(t *testing.T) {
} }
bp.addBuffer(make([]byte, 3*PAGESIZE)) bp.addBuffer(make([]byte, 3*PAGESIZE))
b = bp.getBuffer(2*PAGESIZE) b = bp.getBuffer(2 * PAGESIZE)
if b != nil { if b != nil {
t.Error("should fail.") t.Error("should fail.")
} }
b = bp.getBuffer(4*PAGESIZE) b = bp.getBuffer(4 * PAGESIZE)
if b != nil { if b != nil {
t.Error("should fail.") t.Error("should fail.")
} }
bp.addBuffer(make([]byte, 4*PAGESIZE)) bp.addBuffer(make([]byte, 4*PAGESIZE))
fmt.Println(bp) fmt.Println(bp)
b = bp.getBuffer(2*PAGESIZE) b = bp.getBuffer(2 * PAGESIZE)
if b != nil { if b != nil {
t.Error("should fail.") t.Error("should fail.")
} }
b = bp.getBuffer(4*PAGESIZE) b = bp.getBuffer(4 * PAGESIZE)
if b == nil { if b == nil {
t.Error("4*ps should succeed.") t.Error("4*ps should succeed.")
} }
......
...@@ -7,6 +7,7 @@ import ( ...@@ -7,6 +7,7 @@ import (
"fmt" "fmt"
"bytes" "bytes"
) )
var _ = fmt.Print var _ = fmt.Print
// For PathFileSystemConnector. The connector determines inodes. // For PathFileSystemConnector. The connector determines inodes.
type DirEntry struct { type DirEntry struct {
......
...@@ -199,7 +199,7 @@ func (self *MountState) Stats() string { ...@@ -199,7 +199,7 @@ func (self *MountState) Stats() string {
lines = append(lines, lines = append(lines,
fmt.Sprintf("buffers: %v", self.buffers.String())) fmt.Sprintf("buffers: %v", self.buffers.String()))
for v := range(expvar.Iter()) { for v := range expvar.Iter() {
if strings.HasPrefix(v.Key, "mount") { if strings.HasPrefix(v.Key, "mount") {
lines = append(lines, fmt.Sprintf("%v: %v\n", v.Key, v.Value)) lines = append(lines, fmt.Sprintf("%v: %v\n", v.Key, v.Value))
} }
...@@ -221,7 +221,7 @@ func (self *MountState) syncWrite(packet [][]byte) { ...@@ -221,7 +221,7 @@ func (self *MountState) syncWrite(packet [][]byte) {
if err != nil { if err != nil {
self.Error(os.NewError(fmt.Sprintf("writer: Writev %v failed, err: %v", packet, err))) self.Error(os.NewError(fmt.Sprintf("writer: Writev %v failed, err: %v", packet, err)))
} }
for _, v := range(packet) { for _, v := range packet {
self.buffers.addBuffer(v) self.buffers.addBuffer(v)
} }
} }
......
...@@ -264,7 +264,7 @@ func (self *PathFileSystemConnector) findInode(fullPath string) *inodeData { ...@@ -264,7 +264,7 @@ func (self *PathFileSystemConnector) findInode(fullPath string) *inodeData {
defer self.lock.RUnlock() defer self.lock.RUnlock()
node := self.inodePathMapByInode[FUSE_ROOT_ID] node := self.inodePathMapByInode[FUSE_ROOT_ID]
for i, component := range(comps) { for i, component := range comps {
if len(component) == 0 { if len(component) == 0 {
continue continue
} }
...@@ -318,7 +318,7 @@ func (self *PathFileSystemConnector) Mount(path string, fs PathFilesystem) Statu ...@@ -318,7 +318,7 @@ func (self *PathFileSystemConnector) Mount(path string, fs PathFilesystem) Statu
return EBUSY return EBUSY
} }
if node.Type & ModeToType(S_IFDIR) == 0 { if node.Type&ModeToType(S_IFDIR) == 0 {
return EINVAL return EINVAL
} }
...@@ -355,7 +355,7 @@ func (self *PathFileSystemConnector) Unmount(path string) Status { ...@@ -355,7 +355,7 @@ func (self *PathFileSystemConnector) Unmount(path string) Status {
panic(path) panic(path)
} }
if mount.openFiles + mount.openDirs + mount.subMounts > 0 { if mount.openFiles+mount.openDirs+mount.subMounts > 0 {
log.Println("busy: ", mount) log.Println("busy: ", mount)
return EBUSY return EBUSY
} }
......
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