Commit 2c39d5b4 authored by Han-Wen Nienhuys's avatar Han-Wen Nienhuys

Run gofmt.

parent 391ae350
package fuse package fuse
import ( import (
"fmt" "fmt"
"unsafe" "unsafe"
...@@ -64,9 +65,9 @@ func (me *HandleMap) Register(obj *Handled) (handle uint64) { ...@@ -64,9 +65,9 @@ func (me *HandleMap) Register(obj *Handled) (handle uint64) {
check := me.nextFree check := me.nextFree
me.nextFree++ me.nextFree++
if unsafe.Sizeof(obj) == 8 { if unsafe.Sizeof(obj) == 8 {
me.nextFree = me.nextFree & (1 << (64 - 48 + 3) -1) me.nextFree = me.nextFree & (1<<(64-48+3) - 1)
rest := (handle &^ (1<<48 - 1)) | (handle & (1<<3 -1)) rest := (handle &^ (1<<48 - 1)) | (handle & (1<<3 - 1))
if rest != 0 { if rest != 0 {
panic("unaligned ptr or more than 48 bits in address") panic("unaligned ptr or more than 48 bits in address")
} }
...@@ -100,13 +101,13 @@ func (me *HandleMap) Forget(handle uint64) (val *Handled) { ...@@ -100,13 +101,13 @@ func (me *HandleMap) Forget(handle uint64) (val *Handled) {
func DecodeHandle(handle uint64) (val *Handled) { func DecodeHandle(handle uint64) (val *Handled) {
var check uint32 var check uint32
if unsafe.Sizeof(val) == 8 { if unsafe.Sizeof(val) == 8 {
ptrBits := uintptr(handle & (1<<45-1)) ptrBits := uintptr(handle & (1<<45 - 1))
check = uint32(handle >> 45) check = uint32(handle >> 45)
val = (*Handled)(unsafe.Pointer(ptrBits<<3)) val = (*Handled)(unsafe.Pointer(ptrBits << 3))
} }
if unsafe.Sizeof(val) == 4 { if unsafe.Sizeof(val) == 4 {
check = uint32(handle >> 32) check = uint32(handle >> 32)
val = (*Handled)(unsafe.Pointer(uintptr(handle & ((1<<32)-1)))) val = (*Handled)(unsafe.Pointer(uintptr(handle & ((1 << 32) - 1))))
} }
if val.check != check { if val.check != check {
msg := fmt.Sprintf("handle check mismatch; handle has 0x%x, object has 0x%x", msg := fmt.Sprintf("handle check mismatch; handle has 0x%x, object has 0x%x",
...@@ -115,4 +116,3 @@ func DecodeHandle(handle uint64) (val *Handled) { ...@@ -115,4 +116,3 @@ func DecodeHandle(handle uint64) (val *Handled) {
} }
return val return val
} }
...@@ -46,7 +46,7 @@ func TestHandleMapPointerLayout(t *testing.T) { ...@@ -46,7 +46,7 @@ func TestHandleMapPointerLayout(t *testing.T) {
} }
hm := NewHandleMap() hm := NewHandleMap()
bogus := uint64(1) << uint32((8*(unsafe.Sizeof(t) - 1))) bogus := uint64(1) << uint32((8 * (unsafe.Sizeof(t) - 1)))
p := uintptr(bogus) p := uintptr(bogus)
v := (*Handled)(unsafe.Pointer(p)) v := (*Handled)(unsafe.Pointer(p))
defer markSeen("48") defer markSeen("48")
...@@ -79,7 +79,7 @@ func TestHandleMapMultiple(t *testing.T) { ...@@ -79,7 +79,7 @@ func TestHandleMapMultiple(t *testing.T) {
if DecodeHandle(h) != v { if DecodeHandle(h) != v {
t.Fatal("address mismatch") t.Fatal("address mismatch")
} }
if hm.Count() != i + 1 { if hm.Count() != i+1 {
t.Fatal("count error") t.Fatal("count error")
} }
} }
...@@ -91,6 +91,6 @@ func TestHandleMapCheckFail(t *testing.T) { ...@@ -91,6 +91,6 @@ func TestHandleMapCheckFail(t *testing.T) {
v := new(Handled) v := new(Handled)
hm := NewHandleMap() hm := NewHandleMap()
h := hm.Register(v) h := hm.Register(v)
DecodeHandle(h | (uint64(1)<<63)) DecodeHandle(h | (uint64(1) << 63))
t.Error("Borked decode did not panic") t.Error("Borked decode did not panic")
} }
...@@ -16,13 +16,13 @@ func (me *ownerFs) GetAttr(name string) (*os.FileInfo, Status) { ...@@ -16,13 +16,13 @@ func (me *ownerFs) GetAttr(name string) (*os.FileInfo, Status) {
if name == "" { if name == "" {
return &os.FileInfo{ return &os.FileInfo{
Mode: S_IFDIR | 0755, Mode: S_IFDIR | 0755,
}, OK },OK
} }
return &os.FileInfo{ return &os.FileInfo{
Mode: S_IFREG | 0644, Mode: S_IFREG | 0644,
Uid: _RANDOM_OWNER, Uid: _RANDOM_OWNER,
Gid: _RANDOM_OWNER, Gid: _RANDOM_OWNER,
}, OK },OK
} }
func setupOwnerTest(opts *FileSystemOptions) (workdir string, cleanup func()) { func setupOwnerTest(opts *FileSystemOptions) (workdir string, cleanup func()) {
......
...@@ -80,14 +80,14 @@ func (me *FileSystemDebug) GetAttr(path string) (*os.FileInfo, Status) { ...@@ -80,14 +80,14 @@ func (me *FileSystemDebug) GetAttr(path string) (*os.FileInfo, Status) {
if path == DebugDir { if path == DebugDir {
return &os.FileInfo{ return &os.FileInfo{
Mode: S_IFDIR | 0755, Mode: S_IFDIR | 0755,
}, OK },OK
} }
c := me.getContent(path) c := me.getContent(path)
if c != nil { if c != nil {
return &os.FileInfo{ return &os.FileInfo{
Mode: S_IFREG | 0644, Mode: S_IFREG | 0644,
Size: int64(len(c)), Size: int64(len(c)),
}, OK },OK
} }
return nil, ENOENT return nil, ENOENT
} }
......
...@@ -79,7 +79,7 @@ func (me *mountData) setOwner(attr *Attr) { ...@@ -79,7 +79,7 @@ func (me *mountData) setOwner(attr *Attr) {
} }
} }
func (me *mountData) unregisterFileHandle(node *inode, handle uint64) (*openedFile) { func (me *mountData) unregisterFileHandle(node *inode, handle uint64) *openedFile {
obj := me.openFiles.Forget(handle) obj := me.openFiles.Forget(handle)
opened := (*openedFile)(unsafe.Pointer(obj)) opened := (*openedFile)(unsafe.Pointer(obj))
......
...@@ -283,7 +283,7 @@ func (me *AutoUnionFs) GetAttr(path string) (*os.FileInfo, fuse.Status) { ...@@ -283,7 +283,7 @@ func (me *AutoUnionFs) GetAttr(path string) (*os.FileInfo, fuse.Status) {
if me.getUnionFs(path) != nil { if me.getUnionFs(path) != nil {
return &os.FileInfo{ return &os.FileInfo{
Mode: fuse.S_IFDIR | 0755, Mode: fuse.S_IFDIR | 0755,
}, fuse.OK },fuse.OK
} }
return nil, fuse.ENOENT return nil, fuse.ENOENT
......
...@@ -136,10 +136,10 @@ func NewCachingFileSystem(fs fuse.FileSystem, ttlNs int64) *CachingFileSystem { ...@@ -136,10 +136,10 @@ func NewCachingFileSystem(fs fuse.FileSystem, ttlNs int64) *CachingFileSystem {
c.links = NewTimedCache(func(n string) interface{} { return readLink(fs, n) }, ttlNs) c.links = NewTimedCache(func(n string) interface{} { return readLink(fs, n) }, ttlNs)
c.xattr = NewTimedCache(func(n string) interface{} { c.xattr = NewTimedCache(func(n string) interface{} {
return getXAttr(fs, n) return getXAttr(fs, n)
}, ttlNs) },ttlNs)
c.files = NewTimedCache(func(n string) interface{} { c.files = NewTimedCache(func(n string) interface{} {
return openFile(fs, n) return openFile(fs, n)
}, ttlNs) },ttlNs)
return c return c
} }
......
...@@ -571,7 +571,7 @@ func (me *UnionFs) GetAttr(name string) (a *os.FileInfo, s fuse.Status) { ...@@ -571,7 +571,7 @@ func (me *UnionFs) GetAttr(name string) (a *os.FileInfo, s fuse.Status) {
if name == _DROP_CACHE { if name == _DROP_CACHE {
return &os.FileInfo{ return &os.FileInfo{
Mode: fuse.S_IFREG | 0777, Mode: fuse.S_IFREG | 0777,
}, fuse.OK },fuse.OK
} }
if name == me.options.DeletionDirName { if name == me.options.DeletionDirName {
return nil, fuse.ENOENT return nil, fuse.ENOENT
......
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