Commit 9fe49c6f authored by Han-Wen Nienhuys's avatar Han-Wen Nienhuys

Run Gofmt.

parent e4dc4c71
...@@ -31,8 +31,8 @@ func main() { ...@@ -31,8 +31,8 @@ func main() {
options := unionfs.AutoUnionFsOptions{ options := unionfs.AutoUnionFsOptions{
UnionFsOptions: ufsOptions, UnionFsOptions: ufsOptions,
MountOptions: fuse.MountOptions{ MountOptions: fuse.MountOptions{
EntryTimeout: 1.0, EntryTimeout: 1.0,
AttrTimeout: 1.0, AttrTimeout: 1.0,
NegativeTimeout: 1.0, NegativeTimeout: 1.0,
}, },
} }
......
...@@ -39,7 +39,7 @@ func main() { ...@@ -39,7 +39,7 @@ func main() {
tot := 0.0 tot := 0.0
totalRuns := *runs + 1 totalRuns := *runs + 1
for j := 0 ; j < totalRuns; j++ { for j := 0; j < totalRuns; j++ {
result := BulkStat(*threads, files) result := BulkStat(*threads, files)
if j > 0 { if j > 0 {
tot += result tot += result
......
...@@ -40,7 +40,7 @@ func main() { ...@@ -40,7 +40,7 @@ func main() {
orig := flag.Arg(1) orig := flag.Arg(1)
loopbackfs := fuse.NewLoopbackFileSystem(orig) loopbackfs := fuse.NewLoopbackFileSystem(orig)
finalFs = loopbackfs finalFs = loopbackfs
debugFs := fuse.NewFileSystemDebug() debugFs := fuse.NewFileSystemDebug()
if *latencies { if *latencies {
timing := fuse.NewTimingFileSystem(finalFs) timing := fuse.NewTimingFileSystem(finalFs)
...@@ -52,8 +52,8 @@ func main() { ...@@ -52,8 +52,8 @@ func main() {
// These options are to be compatible with libfuse defaults, // These options are to be compatible with libfuse defaults,
// making benchmarking easier. // making benchmarking easier.
NegativeTimeout: 1.0, NegativeTimeout: 1.0,
AttrTimeout: 1.0, AttrTimeout: 1.0,
EntryTimeout: 1.0, EntryTimeout: 1.0,
} }
if *latencies { if *latencies {
......
...@@ -15,7 +15,7 @@ func main() { ...@@ -15,7 +15,7 @@ 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.")
latencies := flag.Bool("latencies", false, "record operation latencies.") latencies := flag.Bool("latencies", false, "record operation latencies.")
flag.Parse() flag.Parse()
if flag.NArg() < 2 { if flag.NArg() < 2 {
fmt.Fprintf(os.Stderr, "usage: %s MOUNTPOINT ZIP-FILE\n", os.Args[0]) fmt.Fprintf(os.Stderr, "usage: %s MOUNTPOINT ZIP-FILE\n", os.Args[0])
...@@ -34,7 +34,7 @@ func main() { ...@@ -34,7 +34,7 @@ func main() {
debugFs.FileSystem = fs debugFs.FileSystem = fs
fs = debugFs fs = debugFs
} }
conn := fuse.NewFileSystemConnector(fs, nil) conn := fuse.NewFileSystemConnector(fs, nil)
state := fuse.NewMountState(conn) state := fuse.NewMountState(conn)
...@@ -42,7 +42,7 @@ func main() { ...@@ -42,7 +42,7 @@ func main() {
debugFs.AddFileSystemConnector(conn) debugFs.AddFileSystemConnector(conn)
debugFs.AddMountState(state) debugFs.AddMountState(state)
} }
mountPoint := flag.Arg(0) mountPoint := flag.Arg(0)
state.SetRecordStatistics(*latencies) state.SetRecordStatistics(*latencies)
state.Debug = *debug state.Debug = *debug
......
...@@ -151,14 +151,14 @@ func (me *MountState) newRequest(oldReq *request) *request { ...@@ -151,14 +151,14 @@ func (me *MountState) newRequest(oldReq *request) *request {
me.buffers.FreeBuffer(oldReq.flatData) me.buffers.FreeBuffer(oldReq.flatData)
*oldReq = request{ *oldReq = request{
status: OK, status: OK,
inputBuf: oldReq.inputBuf[0:bufSize], inputBuf: oldReq.inputBuf[0:bufSize],
} }
return oldReq return oldReq
} }
return &request{ return &request{
status: OK, status: OK,
inputBuf: me.buffers.AllocBuffer(bufSize), inputBuf: me.buffers.AllocBuffer(bufSize),
} }
} }
...@@ -214,7 +214,7 @@ func (me *MountState) loop() { ...@@ -214,7 +214,7 @@ func (me *MountState) loop() {
err := me.readRequest(req) err := me.readRequest(req)
if err != nil { if err != nil {
errNo := OsErrorToErrno(err) errNo := OsErrorToErrno(err)
// Retry. // Retry.
if errNo == syscall.ENOENT { if errNo == syscall.ENOENT {
me.discardRequest(req) me.discardRequest(req)
......
...@@ -37,13 +37,13 @@ func doInit(state *MountState, req *request) { ...@@ -37,13 +37,13 @@ func doInit(state *MountState, req *request) {
} }
out := &InitOut{ out := &InitOut{
Major: FUSE_KERNEL_VERSION, Major: FUSE_KERNEL_VERSION,
Minor: FUSE_KERNEL_MINOR_VERSION, Minor: FUSE_KERNEL_MINOR_VERSION,
MaxReadAhead: input.MaxReadAhead, MaxReadAhead: input.MaxReadAhead,
Flags: CAP_ASYNC_READ | CAP_POSIX_LOCKS | CAP_BIG_WRITES, Flags: CAP_ASYNC_READ | CAP_POSIX_LOCKS | CAP_BIG_WRITES,
MaxWrite: maxRead, MaxWrite: maxRead,
CongestionThreshold: _BACKGROUND_TASKS * 3 / 4, CongestionThreshold: _BACKGROUND_TASKS * 3 / 4,
MaxBackground: _BACKGROUND_TASKS, MaxBackground: _BACKGROUND_TASKS,
} }
req.outData = unsafe.Pointer(out) req.outData = unsafe.Pointer(out)
...@@ -423,23 +423,23 @@ func init() { ...@@ -423,23 +423,23 @@ func init() {
} }
for op, f := range map[opcode]castPointerFunc{ for op, f := range map[opcode]castPointerFunc{
FUSE_LOOKUP: func(ptr unsafe.Pointer) interface{} { return (*EntryOut)(ptr) }, FUSE_LOOKUP: func(ptr unsafe.Pointer) interface{} { return (*EntryOut)(ptr) },
FUSE_OPEN: func(ptr unsafe.Pointer) interface{} { return (*EntryOut)(ptr) }, FUSE_OPEN: func(ptr unsafe.Pointer) interface{} { return (*EntryOut)(ptr) },
FUSE_GETATTR: func(ptr unsafe.Pointer) interface{} { return (*AttrOut)(ptr) }, FUSE_GETATTR: func(ptr unsafe.Pointer) interface{} { return (*AttrOut)(ptr) },
} { } {
operationHandlers[op].DecodeOut = f operationHandlers[op].DecodeOut = f
} }
for op, count := range map[opcode]int { for op, count := range map[opcode]int{
FUSE_LOOKUP: 1, FUSE_LOOKUP: 1,
FUSE_RENAME: 2, FUSE_RENAME: 2,
FUSE_SYMLINK: 2, FUSE_SYMLINK: 2,
FUSE_GETXATTR: 1, FUSE_GETXATTR: 1,
FUSE_CREATE: 1, FUSE_CREATE: 1,
FUSE_MKNOD: 1, FUSE_MKNOD: 1,
FUSE_MKDIR: 1, FUSE_MKDIR: 1,
FUSE_UNLINK: 1, FUSE_UNLINK: 1,
FUSE_RMDIR: 1, FUSE_RMDIR: 1,
FUSE_REMOVEXATTR: 1, FUSE_REMOVEXATTR: 1,
} { } {
operationHandlers[op].FileNames = count operationHandlers[op].FileNames = count
......
...@@ -46,7 +46,7 @@ type inode struct { ...@@ -46,7 +46,7 @@ type inode struct {
Name string Name string
LookupCount int LookupCount int
OpenCount int OpenCount int
mount *mountData mount *mountData
} }
// Should be called with treeLock and fileLock held. // Should be called with treeLock and fileLock held.
...@@ -152,7 +152,7 @@ func NewMountOptions() *MountOptions { ...@@ -152,7 +152,7 @@ func NewMountOptions() *MountOptions {
type FileSystemConnector struct { type FileSystemConnector struct {
DefaultRawFileSystem DefaultRawFileSystem
Debug bool Debug bool
//////////////// ////////////////
......
...@@ -8,6 +8,7 @@ import ( ...@@ -8,6 +8,7 @@ import (
"path/filepath" "path/filepath"
"time" "time"
) )
var _ = fmt.Println var _ = fmt.Println
func NewFileSystemConnector(fs FileSystem, opts *MountOptions) (out *FileSystemConnector) { func NewFileSystemConnector(fs FileSystem, opts *MountOptions) (out *FileSystemConnector) {
...@@ -147,7 +148,7 @@ func (me *FileSystemConnector) SetAttr(header *InHeader, input *SetAttrIn) (out ...@@ -147,7 +148,7 @@ func (me *FileSystemConnector) SetAttr(header *InHeader, input *SetAttrIn) (out
if input.Valid&FATTR_MODE != 0 { if input.Valid&FATTR_MODE != 0 {
permissionMask := uint32(07777) permissionMask := uint32(07777)
err = mount.fs.Chmod(fullPath, input.Mode & permissionMask) err = mount.fs.Chmod(fullPath, input.Mode&permissionMask)
} }
if err == OK && (input.Valid&FATTR_UID != 0 || input.Valid&FATTR_GID != 0) { if err == OK && (input.Valid&FATTR_UID != 0 || input.Valid&FATTR_GID != 0) {
// TODO - can we get just FATTR_GID but not FATTR_UID ? // TODO - can we get just FATTR_GID but not FATTR_UID ?
......
...@@ -39,8 +39,8 @@ const ( ...@@ -39,8 +39,8 @@ const (
CAP_BIG_WRITES = (1 << 5) CAP_BIG_WRITES = (1 << 5)
CAP_DONT_MASK = (1 << 6) CAP_DONT_MASK = (1 << 6)
CAP_SPLICE_WRITE = (1 << 7) CAP_SPLICE_WRITE = (1 << 7)
CAP_SPLICE_MOVE = (1 << 8) CAP_SPLICE_MOVE = (1 << 8)
CAP_SPLICE_READ = (1 << 9) CAP_SPLICE_READ = (1 << 9)
FUSE_UNKNOWN_INO = 0xffffffff FUSE_UNKNOWN_INO = 0xffffffff
...@@ -66,7 +66,7 @@ const ( ...@@ -66,7 +66,7 @@ const (
FUSE_POLL_SCHEDULE_NOTIFY = (1 << 0) FUSE_POLL_SCHEDULE_NOTIFY = (1 << 0)
FUSE_MIN_READ_BUFFER = 8192 FUSE_MIN_READ_BUFFER = 8192
CUSE_INIT_INFO_MAX = 4096 CUSE_INIT_INFO_MAX = 4096
S_IFDIR = syscall.S_IFDIR S_IFDIR = syscall.S_IFDIR
S_IFREG = syscall.S_IFREG S_IFREG = syscall.S_IFREG
......
...@@ -4,7 +4,9 @@ import ( ...@@ -4,7 +4,9 @@ import (
"fmt" "fmt"
"github.com/hanwen/go-fuse/fuse" "github.com/hanwen/go-fuse/fuse"
) )
var _ = fmt.Println var _ = fmt.Println
type attrResponse struct { type attrResponse struct {
*fuse.Attr *fuse.Attr
fuse.Status fuse.Status
......
...@@ -60,7 +60,7 @@ func (me *DirCache) setMap(newMap map[string]bool) { ...@@ -60,7 +60,7 @@ func (me *DirCache) setMap(newMap map[string]bool) {
func() { me.DropCache() }) func() { me.DropCache() })
} }
func (me *DirCache) DropCache() { func (me *DirCache) DropCache() {
me.lock.Lock() me.lock.Lock()
me.names = nil me.names = nil
me.lock.Unlock() me.lock.Unlock()
......
...@@ -27,7 +27,7 @@ type TimedCache struct { ...@@ -27,7 +27,7 @@ type TimedCache struct {
cacheMapMutex sync.RWMutex cacheMapMutex sync.RWMutex
cacheMap map[string]*cacheEntry cacheMap map[string]*cacheEntry
PurgeTimer *time.Timer PurgeTimer *time.Timer
} }
const layerCacheTimeoutNs = 1e9 const layerCacheTimeoutNs = 1e9
......
...@@ -154,7 +154,7 @@ func (me *UnionFs) getBranchAttrNoCache(name string) getBranchResult { ...@@ -154,7 +154,7 @@ func (me *UnionFs) getBranchAttrNoCache(name string) getBranchResult {
a, s := fs.GetAttr(name) a, s := fs.GetAttr(name)
if s == fuse.OK { if s == fuse.OK {
if a.Mode & fuse.S_IFDIR != 0 { if a.Mode&fuse.S_IFDIR != 0 {
// Make all directories appear writable // Make all directories appear writable
a.Mode |= 0200 a.Mode |= 0200
} }
...@@ -383,7 +383,7 @@ func (me *UnionFs) Readlink(name string) (out string, code fuse.Status) { ...@@ -383,7 +383,7 @@ func (me *UnionFs) Readlink(name string) (out string, code fuse.Status) {
func IsDir(fs fuse.FileSystem, name string) bool { func IsDir(fs fuse.FileSystem, name string) bool {
a, code := fs.GetAttr(name) a, code := fs.GetAttr(name)
return code == fuse.OK && a.Mode & fuse.S_IFDIR != 0 return code == fuse.OK && a.Mode&fuse.S_IFDIR != 0
} }
func (me *UnionFs) makeDirTo(name string) fuse.Status { func (me *UnionFs) makeDirTo(name string) fuse.Status {
......
...@@ -138,18 +138,18 @@ func TestChmod(t *testing.T) { ...@@ -138,18 +138,18 @@ func TestChmod(t *testing.T) {
wd, state := setup(t) wd, state := setup(t)
defer state.Unmount() defer state.Unmount()
ro_fn := wd+"/ro/file" ro_fn := wd + "/ro/file"
m_fn := wd+"/mount/file" m_fn := wd + "/mount/file"
writeToFile(ro_fn, "a") writeToFile(ro_fn, "a")
err := os.Chmod(m_fn, 07070) err := os.Chmod(m_fn, 07070)
CheckSuccess(err) CheckSuccess(err)
fi, err := os.Lstat(m_fn) fi, err := os.Lstat(m_fn)
CheckSuccess(err) CheckSuccess(err)
if fi.Mode & 07777 != 07070 { if fi.Mode&07777 != 07070 {
t.Errorf("Unexpected mode found: %v", fi.Mode) t.Errorf("Unexpected mode found: %v", fi.Mode)
} }
_, err = os.Lstat(wd+"/rw/file") _, err = os.Lstat(wd + "/rw/file")
if err != nil { if err != nil {
t.Errorf("File not promoted") t.Errorf("File not promoted")
} }
...@@ -220,19 +220,19 @@ func TestPromote(t *testing.T) { ...@@ -220,19 +220,19 @@ func TestPromote(t *testing.T) {
wd, state := setup(t) wd, state := setup(t)
defer state.Unmount() defer state.Unmount()
err := os.Mkdir(wd + "/ro/subdir", 0755) err := os.Mkdir(wd+"/ro/subdir", 0755)
CheckSuccess(err) CheckSuccess(err)
writeToFile(wd + "/ro/subdir/file", "content") writeToFile(wd+"/ro/subdir/file", "content")
writeToFile(wd + "/mount/subdir/file", "other-content") writeToFile(wd+"/mount/subdir/file", "other-content")
} }
func TestCreate(t *testing.T) { func TestCreate(t *testing.T) {
wd, state := setup(t) wd, state := setup(t)
defer state.Unmount() defer state.Unmount()
err := os.MkdirAll(wd + "/ro/subdir/sub2", 0755) err := os.MkdirAll(wd+"/ro/subdir/sub2", 0755)
CheckSuccess(err) CheckSuccess(err)
writeToFile(wd + "/mount/subdir/sub2/file", "other-content") writeToFile(wd+"/mount/subdir/sub2/file", "other-content")
_, err = os.Lstat(wd + "/mount/subdir/sub2/file") _, err = os.Lstat(wd + "/mount/subdir/sub2/file")
CheckSuccess(err) CheckSuccess(err)
} }
...@@ -241,10 +241,10 @@ func TestOpenUndeletes(t *testing.T) { ...@@ -241,10 +241,10 @@ func TestOpenUndeletes(t *testing.T) {
wd, state := setup(t) wd, state := setup(t)
defer state.Unmount() defer state.Unmount()
writeToFile(wd + "/ro/file", "X") writeToFile(wd+"/ro/file", "X")
err := os.Remove(wd + "/mount/file") err := os.Remove(wd + "/mount/file")
CheckSuccess(err) CheckSuccess(err)
writeToFile(wd + "/mount/file", "X") writeToFile(wd+"/mount/file", "X")
_, err = os.Lstat(wd + "/mount/file") _, err = os.Lstat(wd + "/mount/file")
CheckSuccess(err) CheckSuccess(err)
} }
...@@ -282,19 +282,19 @@ func TestRename(t *testing.T) { ...@@ -282,19 +282,19 @@ func TestRename(t *testing.T) {
t.Log("Config", i, c) t.Log("Config", i, c)
wd, state := setup(t) wd, state := setup(t)
if c.f1_ro { if c.f1_ro {
writeToFile(wd + "/ro/file1", "c1") writeToFile(wd+"/ro/file1", "c1")
} }
if c.f1_rw { if c.f1_rw {
writeToFile(wd + "/rw/file1", "c2") writeToFile(wd+"/rw/file1", "c2")
} }
if c.f2_ro { if c.f2_ro {
writeToFile(wd + "/ro/file2", "c3") writeToFile(wd+"/ro/file2", "c3")
} }
if c.f2_rw { if c.f2_rw {
writeToFile(wd + "/rw/file2", "c4") writeToFile(wd+"/rw/file2", "c4")
} }
err := os.Rename(wd + "/mount/file1", wd + "/mount/file2") err := os.Rename(wd+"/mount/file1", wd+"/mount/file2")
CheckSuccess(err) CheckSuccess(err)
_, err = os.Lstat(wd + "/mount/file1") _, err = os.Lstat(wd + "/mount/file1")
...@@ -304,7 +304,7 @@ func TestRename(t *testing.T) { ...@@ -304,7 +304,7 @@ func TestRename(t *testing.T) {
_, err = os.Lstat(wd + "/mount/file2") _, err = os.Lstat(wd + "/mount/file2")
CheckSuccess(err) CheckSuccess(err)
err = os.Rename(wd + "/mount/file2", wd + "/mount/file1") err = os.Rename(wd+"/mount/file2", wd+"/mount/file1")
CheckSuccess(err) CheckSuccess(err)
_, err = os.Lstat(wd + "/mount/file2") _, err = os.Lstat(wd + "/mount/file2")
...@@ -327,9 +327,9 @@ func TestWritableDir(t *testing.T) { ...@@ -327,9 +327,9 @@ func TestWritableDir(t *testing.T) {
err := os.Mkdir(dirname, 0555) err := os.Mkdir(dirname, 0555)
CheckSuccess(err) CheckSuccess(err)
fi, err := os.Lstat(wd+"/mount/subdir") fi, err := os.Lstat(wd + "/mount/subdir")
CheckSuccess(err) CheckSuccess(err)
if fi.Permission() & 0222 == 0 { if fi.Permission()&0222 == 0 {
t.Errorf("unexpected permission %o", fi.Permission()) t.Errorf("unexpected permission %o", fi.Permission())
} }
} }
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