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

Run gofmt.

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