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

Gofmt.

parent bf30f7b8
......@@ -13,7 +13,6 @@ import (
"time"
)
func ReadLines(name string) []string {
f, err := os.Open(name)
if err != nil {
......
......@@ -157,7 +157,7 @@ func BenchmarkCFuseThreadedStat(b *testing.B) {
mountPoint)
cmd.Env = append(os.Environ(),
fmt.Sprintf("STATFS_INPUT=%s", f.Name()),
fmt.Sprintf("STATFS_DELAY_USEC=%d", delay / time.Microsecond))
fmt.Sprintf("STATFS_DELAY_USEC=%d", delay/time.Microsecond))
cmd.Start()
bin, err := exec.LookPath("fusermount")
......
......@@ -73,5 +73,5 @@ func main() {
gofs.SetFileSystemConnector(conn)
state.Loop()
time.Sleep(1 *time.Second)
time.Sleep(1 * time.Second)
}
......@@ -3,8 +3,8 @@ package main
import (
"flag"
"fmt"
"github.com/hanwen/go-fuse/fuse"
"github.com/hanwen/go-fuse/benchmark"
"github.com/hanwen/go-fuse/fuse"
"io"
"log"
"os"
......
......@@ -77,7 +77,6 @@ type FsNode interface {
StatFs() *StatfsOut
}
// A filesystem API that uses paths rather than inodes. A minimal
// file system should have at least a functional GetAttr method.
// Typically, each call happens in its own goroutine, so take care to
......@@ -171,7 +170,7 @@ type File interface {
// The methods below may be called on closed files, due to
// concurrency. In that case, you should return EBADF.
Truncate(size uint64) Status
GetAttr(out *Attr) (Status)
GetAttr(out *Attr) Status
Chown(uid uint32, gid uint32) Status
Chmod(perms uint32) Status
Utimens(atimeNs int64, mtimeNs int64) Status
......@@ -288,7 +287,7 @@ type RawFileSystem interface {
// Directory handling
OpenDir(out *raw.OpenOut, header *raw.InHeader, input *raw.OpenIn) (status Status)
ReadDir(out *DirEntryList, header *raw.InHeader, input *ReadIn) (Status)
ReadDir(out *DirEntryList, header *raw.InHeader, input *ReadIn) Status
ReleaseDir(header *raw.InHeader, input *raw.ReleaseIn)
FsyncDir(header *raw.InHeader, input *raw.FsyncIn) (code Status)
......
......@@ -122,7 +122,6 @@ func (p *BufferPoolImpl) AllocBuffer(size uint32) []byte {
}
p.lock.Unlock()
return b
}
......
......@@ -2,12 +2,12 @@ package fuse
import (
"bytes"
"github.com/hanwen/go-fuse/raw"
"io/ioutil"
"log"
"os"
"sync"
"testing"
"github.com/hanwen/go-fuse/raw"
)
var _ = log.Println
......
......@@ -27,7 +27,7 @@ func CopyFile(srcFs, destFs FileSystem, srcFile, destFile string, context *Conte
defer dst.Release()
defer dst.Flush()
buf := make([]byte, 128 * (1 << 10))
buf := make([]byte, 128*(1<<10))
off := int64(0)
for {
res := src.Read(buf, off)
......
......@@ -6,7 +6,6 @@ import (
var _ = RawFileSystem((*DefaultRawFileSystem)(nil))
func (fs *DefaultRawFileSystem) Init(init *RawFsInit) {
}
......@@ -116,7 +115,7 @@ func (fs *DefaultRawFileSystem) Fsync(header *raw.InHeader, input *raw.FsyncIn)
return ENOSYS
}
func (fs *DefaultRawFileSystem) ReadDir(l *DirEntryList, header *raw.InHeader, input *ReadIn) ( Status) {
func (fs *DefaultRawFileSystem) ReadDir(l *DirEntryList, header *raw.InHeader, input *ReadIn) Status {
return ENOSYS
}
......
......@@ -11,6 +11,7 @@ import (
var _ = log.Print
var eightPadding [8]byte
const direntSize = int(unsafe.Sizeof(raw.Dirent{}))
// DirEntry is a type for PathFileSystem and NodeFileSystem to return
......@@ -37,7 +38,7 @@ func (l *DirEntryList) AddDirEntry(e DirEntry) bool {
}
func (l *DirEntryList) Add(name string, inode uint64, mode uint32) bool {
padding := (8 - len(name)&7)&7
padding := (8 - len(name)&7) & 7
delta := padding + direntSize + len(name)
oldLen := len(l.buf)
newLen := delta + oldLen
......@@ -47,9 +48,9 @@ func (l *DirEntryList) Add(name string, inode uint64, mode uint32) bool {
}
l.buf = l.buf[:newLen]
dirent := (*raw.Dirent)(unsafe.Pointer(&l.buf[oldLen]))
dirent.Off = l.offset+1
dirent.Off = l.offset + 1
dirent.Ino = inode
dirent.NameLen= uint32(len(name))
dirent.NameLen = uint32(len(name))
dirent.Typ = ModeToType(mode)
oldLen += direntSize
copy(l.buf[oldLen:], name)
......@@ -70,7 +71,7 @@ func (l *DirEntryList) Bytes() []byte {
////////////////////////////////////////////////////////////////
type rawDir interface {
ReadDir(out *DirEntryList, input *ReadIn) (Status)
ReadDir(out *DirEntryList, input *ReadIn) Status
Release()
}
......
......@@ -104,7 +104,7 @@ func (f *LoopbackFile) Read(buf []byte, off int64) (res ReadResult) {
return ReadResult{
Fd: f.File.Fd(),
FdOff: off,
FdSize:len(buf),
FdSize: len(buf),
Status: OK,
}
}
......
......@@ -65,7 +65,7 @@ func (m *fileSystemMount) fillEntry(out *raw.EntryOut) {
splitDuration(m.options.EntryTimeout, &out.EntryValid, &out.EntryValidNsec)
splitDuration(m.options.AttrTimeout, &out.AttrValid, &out.AttrValidNsec)
m.setOwner(&out.Attr)
if out.Mode & S_IFDIR == 0 && out.Nlink == 0 {
if out.Mode&S_IFDIR == 0 && out.Nlink == 0 {
out.Nlink = 1
}
}
......
......@@ -123,7 +123,7 @@ func (c *FileSystemConnector) OpenDir(out *raw.OpenOut, header *raw.InHeader, in
return OK
}
func (c *FileSystemConnector) ReadDir(l *DirEntryList, header *raw.InHeader, input *ReadIn) (Status) {
func (c *FileSystemConnector) ReadDir(l *DirEntryList, header *raw.InHeader, input *ReadIn) Status {
node := c.toInode(header.NodeId)
opened := node.mount.getOpenedFile(input.Fh)
return opened.dir.ReadDir(l, input)
......@@ -350,7 +350,7 @@ func (c *FileSystemConnector) Write(header *raw.InHeader, input *WriteIn, data [
return opened.WithFlags.File.Write(data, int64(input.Offset))
}
func (c *FileSystemConnector) Read(header *raw.InHeader, input *ReadIn, buf []byte) (ReadResult) {
func (c *FileSystemConnector) Read(header *raw.InHeader, input *ReadIn, buf []byte) ReadResult {
node := c.toInode(header.NodeId)
opened := node.mount.getOpenedFile(input.Fh)
......@@ -372,4 +372,3 @@ func (c *FileSystemConnector) Flush(header *raw.InHeader, input *raw.FlushIn) St
opened := node.mount.getOpenedFile(input.Fh)
return opened.WithFlags.File.Flush()
}
......@@ -296,7 +296,7 @@ func (fs *LockingRawFileSystem) Fsync(header *raw.InHeader, input *raw.FsyncIn)
return fs.RawFileSystem.Fsync(header, input)
}
func (fs *LockingRawFileSystem) ReadDir(out *DirEntryList, header *raw.InHeader, input *ReadIn) (Status) {
func (fs *LockingRawFileSystem) ReadDir(out *DirEntryList, header *raw.InHeader, input *ReadIn) Status {
defer fs.locked()()
return fs.RawFileSystem.ReadDir(out, header, input)
}
......
......@@ -140,7 +140,7 @@ func TestReadLarge(t *testing.T) {
defer ts.Cleanup()
// Add a bit more to test the splicing at the end.
content := make([]byte, 1024*1024 + 43)
content := make([]byte, 1024*1024+43)
for i := range content {
content[i] = byte(i)
}
......
......@@ -48,7 +48,7 @@ func TestMemNodeFsWrite(t *testing.T) {
err := ioutil.WriteFile(wd+"/test", []byte(want), 0644)
CheckSuccess(err)
content, err := ioutil.ReadFile(wd +"/test")
content, err := ioutil.ReadFile(wd + "/test")
if string(content) != want {
t.Fatalf("content mismatch: got %q, want %q", content, want)
}
......
......@@ -49,4 +49,3 @@ func TestLinkAt(t *testing.T) {
t.Fatal("Ino mismatch", s1, s2)
}
}
......@@ -2,8 +2,8 @@ package fuse
import (
"fmt"
"log"
"io"
"log"
"os"
"strings"
"sync"
......@@ -163,7 +163,7 @@ func (ms *MountState) BufferPoolStats() string {
ms.reqMu.Unlock()
s += fmt.Sprintf(" read buffers: %d (sz %d )",
r, ms.opts.MaxWrite/PAGESIZE + 1)
r, ms.opts.MaxWrite/PAGESIZE+1)
return s
}
......@@ -192,7 +192,7 @@ func (ms *MountState) readRequest(exitIdle bool) (req *request, code Status) {
dest = ms.readPool[l-1]
ms.readPool = ms.readPool[:l-1]
} else {
dest = make([]byte, ms.opts.MaxWrite + PAGESIZE)
dest = make([]byte, ms.opts.MaxWrite+PAGESIZE)
}
ms.outstandingReadBufs++
ms.reqReaders++
......@@ -272,7 +272,7 @@ func (ms *MountState) Loop() {
func (ms *MountState) loop(exitIdle bool) {
defer ms.loops.Done()
exit:
exit:
for {
req, errNo := ms.readRequest(exitIdle)
switch errNo {
......@@ -336,7 +336,6 @@ func (ms *MountState) AllocOut(req *request, size uint32) []byte {
return req.bufferPoolOutputBuf
}
func (ms *MountState) write(req *request) Status {
// Forget does not wait for reply.
if req.inHeader.Opcode == _OP_FORGET || req.inHeader.Opcode == _OP_BATCH_FORGET {
......
......@@ -216,7 +216,7 @@ func doForget(state *MountState, req *request) {
func doBatchForget(state *MountState, req *request) {
in := (*raw.BatchForgetIn)(req.inData)
wantBytes := uintptr(in.Count)*unsafe.Sizeof(raw.BatchForgetIn{})
wantBytes := uintptr(in.Count) * unsafe.Sizeof(raw.BatchForgetIn{})
if uintptr(len(req.arg)) < wantBytes {
// We have no return value to complain, so log an error.
log.Printf("Too few bytes for batch forget. Got %d bytes, want %d (%d entries)",
......@@ -568,7 +568,7 @@ func init() {
var r request
sizeOfOutHeader := unsafe.Sizeof(raw.OutHeader{})
for code, h := range operationHandlers {
if h.OutputSize + sizeOfOutHeader > unsafe.Sizeof(r.outBuf) {
if h.OutputSize+sizeOfOutHeader > unsafe.Sizeof(r.outBuf) {
log.Panicf("request output buffer too small: code %v, sz %d + %d %v", code, h.OutputSize, sizeOfOutHeader, h)
}
}
......
......@@ -246,7 +246,7 @@ func (n *pathInode) GetPath() string {
end := len(pathBytes)
for p = n; p.Parent != nil; p = p.Parent {
l := len(p.Name)
copy(pathBytes[end - l:], p.Name)
copy(pathBytes[end-l:], p.Name)
end -= len(p.Name) + 1
if end > 0 {
pathBytes[end] = '/'
......
......@@ -46,7 +46,7 @@ func TestMemoryPressure(t *testing.T) {
os.Lstat(dir)
var wg sync.WaitGroup
for i := 0; i < 10 * _MAX_READERS; i++ {
for i := 0; i < 10*_MAX_READERS; i++ {
wg.Add(1)
go func(x int) {
fn := fmt.Sprintf("%s/%ddir/file%d", dir, x, x)
......@@ -60,10 +60,9 @@ func TestMemoryPressure(t *testing.T) {
time.Sleep(100 * time.Millisecond)
created := state.buffers.createdBuffers + state.outstandingReadBufs
t.Logf("Have %d read bufs", state.outstandingReadBufs)
if created > 2 * _MAX_READERS {
if created > 2*_MAX_READERS {
t.Errorf("created %d buffers, max reader %d", created, _MAX_READERS)
}
wg.Wait()
}
......@@ -198,4 +198,3 @@ func (r *request) serializeHeader() (header []byte) {
copy(header[sizeOfOutHeader:], asSlice)
return header
}
package fuse
import (
"github.com/hanwen/go-fuse/raw"
"os"
"syscall"
"github.com/hanwen/go-fuse/raw"
)
const (
......@@ -41,7 +41,6 @@ const (
EROFS = Status(syscall.EROFS)
)
type Attr raw.Attr
type Owner raw.Owner
......@@ -78,4 +77,3 @@ type WriteIn struct {
Flags uint32
Padding uint32
}
......@@ -17,7 +17,6 @@ var xattrGolden = map[string][]byte{
"user.attr2": []byte("val2")}
var xattrFilename = "filename"
type XAttrTestFs struct {
tester *testing.T
filename string
......
package raw
import (
"fmt"
"os"
......@@ -87,7 +88,6 @@ func (me *BatchForgetIn) String() string {
return fmt.Sprintf("{%d}", me.Count)
}
func (me *MkdirIn) String() string {
return fmt.Sprintf("{0%o (0%o)}", me.Mode, me.Umask)
}
......@@ -127,7 +127,6 @@ func (me *GetAttrIn) String() string {
return fmt.Sprintf("{Fh %d}", me.Fh)
}
func (me *ReleaseIn) String() string {
return fmt.Sprintf("{Fh %d %s %s L%d}",
me.Fh, FlagString(OpenFlagNames, int(me.Flags), ""),
......
......@@ -3,7 +3,6 @@
package raw
type ForgetIn struct {
Nlookup uint64
}
......@@ -18,7 +17,6 @@ type BatchForgetIn struct {
Dummy uint32
}
type MkdirIn struct {
Mode uint32
Umask uint32
......@@ -86,7 +84,6 @@ type GetAttrIn struct {
Fh uint64
}
const RELEASE_FLUSH = (1 << 0)
type ReleaseIn struct {
......@@ -289,7 +286,6 @@ type CreateIn struct {
Padding uint32
}
type NotifyInvalInodeOut struct {
Ino uint64
Off int64
......@@ -370,7 +366,6 @@ type InHeader struct {
Padding uint32
}
type Kstatfs struct {
Blocks uint64
Bfree uint64
......
package splice
import (
"sync"
)
......@@ -46,7 +47,6 @@ func (me *pairPool) used() int {
return me.usedCount
}
func (me *pairPool) get() (p *Pair, err error) {
me.Lock()
defer me.Unlock()
......
......@@ -12,7 +12,6 @@ import (
var _ = log.Println
var maxPipeSize int
var resizable bool
......@@ -86,4 +85,3 @@ func newSplicePair() (p *Pair, err error) {
}
return p, nil
}
......@@ -9,7 +9,7 @@ func TestPairSize(t *testing.T) {
p, _ := Get()
defer Done(p)
p.MaxGrow()
b := make([]byte, p.Cap() + 100)
b := make([]byte, p.Cap()+100)
for i := range b {
b[i] = byte(i)
}
......@@ -26,7 +26,3 @@ func TestPairSize(t *testing.T) {
}
}
......@@ -424,7 +424,7 @@ func (fs *AutoUnionFs) OpenDir(name string, context *fuse.Context) (stream []fus
fs.lock.RLock()
defer fs.lock.RUnlock()
stream = make( []fuse.DirEntry, 0, len(fs.knownFileSystems)+5)
stream = make([]fuse.DirEntry, 0, len(fs.knownFileSystems)+5)
if name == _CONFIG {
for k := range fs.knownFileSystems {
stream = append(stream, fuse.DirEntry{
......
......@@ -89,9 +89,9 @@ func (n *memNode) Deletable() bool {
return false
}
func (n *memNode) GetAttr(out *fuse.Attr, file fuse.File, context *fuse.Context) (fuse.Status) {
func (n *memNode) GetAttr(out *fuse.Attr, file fuse.File, context *fuse.Context) fuse.Status {
if n.Inode().IsDir() {
out.Mode= fuse.S_IFDIR | 0777
out.Mode = fuse.S_IFDIR | 0777
return fuse.OK
}
n.file.Stat(out)
......
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