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

Run Gofmt.

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