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

Run Gofmt.

parent 39d680ab
// The fuse package provides APIs to implement filesystems in // The fuse package provides APIs to implement filesystems in
// userspace, using libfuse on Linux. // userspace, using libfuse on Linux.
package fuse package fuse
import ( import (
"os" "os"
) )
...@@ -23,7 +24,7 @@ type FileSystem interface { ...@@ -23,7 +24,7 @@ type FileSystem interface {
Chmod(name string, mode uint32) (code Status) Chmod(name string, mode uint32) (code Status)
Chown(name string, uid uint32, gid uint32) (code Status) Chown(name string, uid uint32, gid uint32) (code Status)
Utimens(name string, AtimeNs uint64, MtimeNs uint64) (code Status) Utimens(name string, AtimeNs uint64, MtimeNs uint64) (code Status)
Truncate(name string, offset uint64) (code Status) Truncate(name string, offset uint64) (code Status)
Access(name string, mode uint32) (code Status) Access(name string, mode uint32) (code Status)
...@@ -50,13 +51,13 @@ type FileSystem interface { ...@@ -50,13 +51,13 @@ type FileSystem interface {
// should be updated too. // should be updated too.
Open(name string, flags uint32) (file File, code Status) Open(name string, flags uint32) (file File, code Status)
Create(name string, flags uint32, mode uint32) (file File, code Status) Create(name string, flags uint32, mode uint32) (file File, code Status)
// Flush() gets called as a file opened for read/write. // Flush() gets called as a file opened for read/write.
Flush(name string) Status Flush(name string) Status
// Directory handling // Directory handling
OpenDir(name string) (stream chan DirEntry, code Status) OpenDir(name string) (stream chan DirEntry, code Status)
// Symlinks. // Symlinks.
Symlink(value string, linkName string) (code Status) Symlink(value string, linkName string) (code Status)
Readlink(name string) (string, Status) Readlink(name string) (string, Status)
...@@ -89,7 +90,6 @@ type MountOptions struct { ...@@ -89,7 +90,6 @@ type MountOptions struct {
EntryTimeout float64 EntryTimeout float64
AttrTimeout float64 AttrTimeout float64
NegativeTimeout float64 NegativeTimeout float64
} }
// DefaultFileSystem implements a FileSystem that returns ENOSYS for every operation. // DefaultFileSystem implements a FileSystem that returns ENOSYS for every operation.
......
...@@ -15,6 +15,7 @@ type BufferPool interface { ...@@ -15,6 +15,7 @@ type BufferPool interface {
} }
type GcBufferPool struct { type GcBufferPool struct {
} }
// NewGcBufferPool is just a fallback to the standard allocation routines. // NewGcBufferPool is just a fallback to the standard allocation routines.
......
package fuse package fuse
import ( import (
"os" "os"
"syscall" "syscall"
...@@ -108,4 +109,3 @@ func (me *LoopbackFile) GetAttr() (*os.FileInfo, Status) { ...@@ -108,4 +109,3 @@ func (me *LoopbackFile) GetAttr() (*os.FileInfo, Status) {
} }
return fi, OK return fi, OK
} }
...@@ -11,7 +11,7 @@ import ( ...@@ -11,7 +11,7 @@ import (
type MutableDataFile struct { type MutableDataFile struct {
DefaultFile DefaultFile
data []byte data []byte
os.FileInfo os.FileInfo
GetAttrCalled bool GetAttrCalled bool
......
...@@ -194,12 +194,12 @@ func (me *MountState) handleRequest(req *request) { ...@@ -194,12 +194,12 @@ func (me *MountState) handleRequest(req *request) {
if req.status.Ok() && me.Debug { if req.status.Ok() && me.Debug {
log.Println(req.InputDebug()) log.Println(req.InputDebug())
} }
if req.status.Ok() && req.handler.Func == nil { if req.status.Ok() && req.handler.Func == nil {
log.Printf("Unimplemented opcode %v", req.inHeader.opcode) log.Printf("Unimplemented opcode %v", req.inHeader.opcode)
req.status = ENOSYS req.status = ENOSYS
} }
if req.status.Ok() { if req.status.Ok() {
req.handler.Func(me, req) req.handler.Func(me, req)
} }
...@@ -219,7 +219,7 @@ func (me *MountState) write(req *request) { ...@@ -219,7 +219,7 @@ func (me *MountState) write(req *request) {
if me.Debug { if me.Debug {
log.Println(req.OutputDebug()) log.Println(req.OutputDebug())
} }
if me.LatencyMap != nil { if me.LatencyMap != nil {
req.preWriteNs = time.Nanoseconds() req.preWriteNs = time.Nanoseconds()
} }
......
...@@ -664,4 +664,3 @@ func TestRecursiveMount(t *testing.T) { ...@@ -664,4 +664,3 @@ func TestRecursiveMount(t *testing.T) {
ts.Cleanup() ts.Cleanup()
} }
...@@ -165,4 +165,4 @@ func ioctl(fd int, cmd int, arg uintptr) (int, int) { ...@@ -165,4 +165,4 @@ func ioctl(fd int, cmd int, arg uintptr) (int, int) {
val := int(r0) val := int(r0)
errno := int(e1) errno := int(e1)
return val, errno return val, errno
} }
...@@ -198,7 +198,7 @@ type FileSystemConnector struct { ...@@ -198,7 +198,7 @@ type FileSystemConnector struct {
type fileBridge struct { type fileBridge struct {
*mountData *mountData
*inode *inode
Flags uint32 Flags uint32
Iface interface{} Iface interface{}
} }
...@@ -215,7 +215,7 @@ func (me *FileSystemConnector) Statistics() string { ...@@ -215,7 +215,7 @@ func (me *FileSystemConnector) Statistics() string {
len(me.openFiles), len(me.inodeMap)) len(me.openFiles), len(me.inodeMap))
} }
func (me *FileSystemConnector) unregisterFile(node *inode, handle uint64) (interface{}) { func (me *FileSystemConnector) unregisterFile(node *inode, handle uint64) interface{} {
me.fileLock.Lock() me.fileLock.Lock()
defer me.fileLock.Unlock() defer me.fileLock.Unlock()
b, ok := me.openFiles[handle] b, ok := me.openFiles[handle]
...@@ -233,9 +233,9 @@ func (me *FileSystemConnector) registerFile(node *inode, mount *mountData, f int ...@@ -233,9 +233,9 @@ func (me *FileSystemConnector) registerFile(node *inode, mount *mountData, f int
b := &fileBridge{ b := &fileBridge{
Iface: f, Iface: f,
inode: node, inode: node,
mountData: mount, mountData: mount,
Flags: flags, Flags: flags,
} }
h := uint64(uintptr(unsafe.Pointer(b))) h := uint64(uintptr(unsafe.Pointer(b)))
_, ok := me.openFiles[h] _, ok := me.openFiles[h]
...@@ -248,7 +248,7 @@ func (me *FileSystemConnector) registerFile(node *inode, mount *mountData, f int ...@@ -248,7 +248,7 @@ func (me *FileSystemConnector) registerFile(node *inode, mount *mountData, f int
return h return h
} }
func (me *FileSystemConnector) decodeFileHandle(h uint64) (*fileBridge) { func (me *FileSystemConnector) decodeFileHandle(h uint64) *fileBridge {
b := (*fileBridge)(unsafe.Pointer(uintptr(h))) b := (*fileBridge)(unsafe.Pointer(uintptr(h)))
return b return b
} }
...@@ -438,7 +438,7 @@ func (me *FileSystemConnector) Mount(mountPoint string, fs FileSystem, opts *Mou ...@@ -438,7 +438,7 @@ func (me *FileSystemConnector) Mount(mountPoint string, fs FileSystem, opts *Mou
log.Println("Could not find mountpoint?", mountPoint) log.Println("Could not find mountpoint?", mountPoint)
return ENOENT return ENOENT
} }
if !node.IsDir() { if !node.IsDir() {
return EINVAL return EINVAL
} }
...@@ -526,7 +526,7 @@ func (me *FileSystemConnector) GetPath(nodeid uint64) (path string, mount *mount ...@@ -526,7 +526,7 @@ func (me *FileSystemConnector) GetPath(nodeid uint64) (path string, mount *mount
return p, m, n return p, m, n
} }
func (me *FileSystemConnector) getOpenFileData(nodeid uint64, fh uint64) (f File, m *mountData, p string) { func (me *FileSystemConnector) getOpenFileData(nodeid uint64, fh uint64) (f File, m *mountData, p string) {
if fh != 0 { if fh != 0 {
var bridge *fileBridge var bridge *fileBridge
f, bridge = me.getFile(fh) f, bridge = me.getFile(fh)
......
...@@ -86,7 +86,7 @@ func (me *FileSystemConnector) GetAttr(header *InHeader, input *GetAttrIn) (out ...@@ -86,7 +86,7 @@ func (me *FileSystemConnector) GetAttr(header *InHeader, input *GetAttrIn) (out
if err != OK && err != ENOSYS { if err != OK && err != ENOSYS {
return nil, err return nil, err
} }
if fi != nil { if fi != nil {
out = &AttrOut{} out = &AttrOut{}
CopyFileInfo(fi, &out.Attr) CopyFileInfo(fi, &out.Attr)
...@@ -383,9 +383,9 @@ func (me *FileSystemConnector) Release(header *InHeader, input *ReleaseIn) { ...@@ -383,9 +383,9 @@ func (me *FileSystemConnector) Release(header *InHeader, input *ReleaseIn) {
func (me *FileSystemConnector) Flush(input *FlushIn) Status { func (me *FileSystemConnector) Flush(input *FlushIn) Status {
f, b := me.getFile(input.Fh) f, b := me.getFile(input.Fh)
code := f.Flush() code := f.Flush()
if code.Ok() && b.Flags & O_ANYWRITE != 0 { if code.Ok() && b.Flags&O_ANYWRITE != 0 {
// We only signal releases to the FS if the // We only signal releases to the FS if the
// open could have changed things. // open could have changed things.
var path string var path string
...@@ -469,7 +469,7 @@ func (me *FileSystemConnector) fileDebug(fh uint64, n *inode) { ...@@ -469,7 +469,7 @@ func (me *FileSystemConnector) fileDebug(fh uint64, n *inode) {
} }
func (me *FileSystemConnector) Write(input *WriteIn, data []byte) (written uint32, code Status) { func (me *FileSystemConnector) Write(input *WriteIn, data []byte) (written uint32, code Status) {
f, b := me.getFile(input.Fh) f, b := me.getFile(input.Fh)
if me.Debug { if me.Debug {
me.fileDebug(input.Fh, b.inode) me.fileDebug(input.Fh, b.inode)
} }
...@@ -491,4 +491,3 @@ func (me *FileSystemConnector) Ioctl(header *InHeader, input *IoctlIn) (out *Ioc ...@@ -491,4 +491,3 @@ func (me *FileSystemConnector) Ioctl(header *InHeader, input *IoctlIn) (out *Ioc
} }
return f.Ioctl(input) return f.Ioctl(input)
} }
...@@ -11,16 +11,16 @@ type request struct { ...@@ -11,16 +11,16 @@ type request struct {
inputBuf []byte inputBuf []byte
// These split up inputBuf. // These split up inputBuf.
inHeader *InHeader // generic header inHeader *InHeader // generic header
inData unsafe.Pointer // per op data inData unsafe.Pointer // per op data
arg []byte // flat data. arg []byte // flat data.
filenames []string // filename arguments filenames []string // filename arguments
// Unstructured data, a pointer to the relevant XxxxOut struct. // Unstructured data, a pointer to the relevant XxxxOut struct.
outData unsafe.Pointer outData unsafe.Pointer
status Status status Status
flatData []byte flatData []byte
// Header + structured data for what we send back to the kernel. // Header + structured data for what we send back to the kernel.
// May be followed by flatData. // May be followed by flatData.
outHeaderBytes []byte outHeaderBytes []byte
...@@ -106,7 +106,7 @@ func (me *request) parse() { ...@@ -106,7 +106,7 @@ func (me *request) parse() {
} }
count := me.handler.FileNames count := me.handler.FileNames
if count > 0 { if count > 0 {
if count == 1 { if count == 1 {
me.filenames = []string{string(me.arg[:len(me.arg)-1])} me.filenames = []string{string(me.arg[:len(me.arg)-1])}
} else { } else {
......
...@@ -453,5 +453,3 @@ type NotifyInvalEntryOut struct { ...@@ -453,5 +453,3 @@ type NotifyInvalEntryOut struct {
NameLen uint32 NameLen uint32
Padding uint32 Padding uint32
} }
...@@ -74,30 +74,30 @@ func (me *AutoUnionFs) addAutomaticFs(roots []string) { ...@@ -74,30 +74,30 @@ func (me *AutoUnionFs) addAutomaticFs(roots []string) {
} }
} }
func (me *AutoUnionFs) createFs(name string, roots []string) (*UnionFs, fuse.Status) { func (me *AutoUnionFs) createFs(name string, roots []string) (*UnionFs, fuse.Status) {
me.lock.Lock() me.lock.Lock()
defer me.lock.Unlock() defer me.lock.Unlock()
used := make(map[string]string) used := make(map[string]string)
for workspace, v := range me.knownFileSystems { for workspace, v := range me.knownFileSystems {
used[v.Roots()[0]] = workspace used[v.Roots()[0]] = workspace
} }
workspace, ok := used[roots[0]] workspace, ok := used[roots[0]]
if ok { if ok {
log.Printf("Already have a union FS for directory %s in workspace %s", log.Printf("Already have a union FS for directory %s in workspace %s",
roots[0], workspace) roots[0], workspace)
return nil, fuse.EBUSY return nil, fuse.EBUSY
} }
var gofs *UnionFs var gofs *UnionFs
if me.knownFileSystems[name] == nil { if me.knownFileSystems[name] == nil {
log.Println("Adding UnionFs for roots", roots) log.Println("Adding UnionFs for roots", roots)
gofs = NewUnionFs(roots, me.options.UnionFsOptions) gofs = NewUnionFs(roots, me.options.UnionFsOptions)
me.knownFileSystems[name] = gofs me.knownFileSystems[name] = gofs
} }
return gofs, fuse.OK return gofs, fuse.OK
} }
func (me *AutoUnionFs) rmFs(name string) (code fuse.Status) { func (me *AutoUnionFs) rmFs(name string) (code fuse.Status) {
...@@ -124,7 +124,7 @@ func (me *AutoUnionFs) addFs(name string, roots []string) (code fuse.Status) { ...@@ -124,7 +124,7 @@ func (me *AutoUnionFs) addFs(name string, roots []string) (code fuse.Status) {
log.Println("Illegal name for overlay", roots) log.Println("Illegal name for overlay", roots)
return fuse.EINVAL return fuse.EINVAL
} }
gofs, code := me.createFs(name, roots) gofs, code := me.createFs(name, roots)
if gofs != nil { if gofs != nil {
me.connector.Mount("/"+name, gofs, &me.options.MountOptions) me.connector.Mount("/"+name, gofs, &me.options.MountOptions)
} }
......
...@@ -59,7 +59,7 @@ func setup(t *testing.T) (workdir string, cleanup func()) { ...@@ -59,7 +59,7 @@ func setup(t *testing.T) (workdir string, cleanup func()) {
func TestAutoFsSymlink(t *testing.T) { func TestAutoFsSymlink(t *testing.T) {
wd, clean := setup(t) wd, clean := setup(t)
defer clean() defer clean()
err := os.Mkdir(wd+"/store/foo", 0755) err := os.Mkdir(wd+"/store/foo", 0755)
CheckSuccess(err) CheckSuccess(err)
os.Symlink(wd+"/ro", wd+"/store/foo/READONLY") os.Symlink(wd+"/ro", wd+"/store/foo/READONLY")
...@@ -68,25 +68,25 @@ func TestAutoFsSymlink(t *testing.T) { ...@@ -68,25 +68,25 @@ func TestAutoFsSymlink(t *testing.T) {
err = os.Symlink(wd+"/store/foo", wd+"/mount/config/bar") err = os.Symlink(wd+"/store/foo", wd+"/mount/config/bar")
CheckSuccess(err) CheckSuccess(err)
fi, err := os.Lstat(wd+"/mount/bar/file1") fi, err := os.Lstat(wd + "/mount/bar/file1")
CheckSuccess(err) CheckSuccess(err)
err = os.Remove(wd+"/mount/config/bar") err = os.Remove(wd + "/mount/config/bar")
CheckSuccess(err) CheckSuccess(err)
// Need time for the unmount to be noticed. // Need time for the unmount to be noticed.
log.Println("sleeping...") log.Println("sleeping...")
time.Sleep(entryTtl*2e9) time.Sleep(entryTtl * 2e9)
fi, _ = os.Lstat(wd+"/mount/foo") fi, _ = os.Lstat(wd + "/mount/foo")
if fi != nil { if fi != nil {
t.Error("Should not have file:", fi) t.Error("Should not have file:", fi)
} }
_, err = ioutil.ReadDir(wd+"/mount/config") _, err = ioutil.ReadDir(wd + "/mount/config")
CheckSuccess(err) CheckSuccess(err)
_, err = os.Lstat(wd+"/mount/foo/file1") _, err = os.Lstat(wd + "/mount/foo/file1")
CheckSuccess(err) CheckSuccess(err)
} }
......
...@@ -77,7 +77,7 @@ func getAttr(fs fuse.FileSystem, name string) *attrResponse { ...@@ -77,7 +77,7 @@ func getAttr(fs fuse.FileSystem, name string) *attrResponse {
func openFile(fs fuse.FileSystem, name string) (result *openResponse) { func openFile(fs fuse.FileSystem, name string) (result *openResponse) {
result = &openResponse{} result = &openResponse{}
flags := uint32(os.O_RDONLY) flags := uint32(os.O_RDONLY)
f, code := fs.Open(name, flags) f, code := fs.Open(name, flags)
if !code.Ok() { if !code.Ok() {
result.Status = code result.Status = code
...@@ -88,9 +88,9 @@ func openFile(fs fuse.FileSystem, name string) (result *openResponse) { ...@@ -88,9 +88,9 @@ func openFile(fs fuse.FileSystem, name string) (result *openResponse) {
buf := bytes.NewBuffer(nil) buf := bytes.NewBuffer(nil)
input := fuse.ReadIn{ input := fuse.ReadIn{
Offset: 0, Offset: 0,
Size: 128 * (1<<10), Size: 128 * (1 << 10),
Flags: flags, Flags: flags,
} }
bp := fuse.NewGcBufferPool() bp := fuse.NewGcBufferPool()
...@@ -99,7 +99,7 @@ func openFile(fs fuse.FileSystem, name string) (result *openResponse) { ...@@ -99,7 +99,7 @@ func openFile(fs fuse.FileSystem, name string) (result *openResponse) {
buf.Write(data) buf.Write(data)
if !status.Ok() { if !status.Ok() {
result.Status = status result.Status = status
return return
} }
if len(data) < int(input.Size) { if len(data) < int(input.Size) {
break break
...@@ -181,7 +181,7 @@ func (me *CachingFileSystem) OpenDir(name string) (stream chan fuse.DirEntry, st ...@@ -181,7 +181,7 @@ func (me *CachingFileSystem) OpenDir(name string) (stream chan fuse.DirEntry, st
// Caching file contents easily overflows available memory. // Caching file contents easily overflows available memory.
func (me *CachingFileSystem) DisabledOpen(name string, flags uint32) (f fuse.File, status fuse.Status) { func (me *CachingFileSystem) DisabledOpen(name string, flags uint32) (f fuse.File, status fuse.Status) {
if flags & fuse.O_ANYWRITE != 0 { if flags&fuse.O_ANYWRITE != 0 {
return nil, fuse.EPERM return nil, fuse.EPERM
} }
......
...@@ -30,7 +30,7 @@ func modeMapEq(m1, m2 map[string]uint32) bool { ...@@ -30,7 +30,7 @@ func modeMapEq(m1, m2 map[string]uint32) bool {
func TestCachingFs(t *testing.T) { func TestCachingFs(t *testing.T) {
wd := fuse.MakeTempDir() wd := fuse.MakeTempDir()
defer os.RemoveAll(wd) defer os.RemoveAll(wd)
fs := fuse.NewLoopbackFileSystem(wd) fs := fuse.NewLoopbackFileSystem(wd)
cfs := NewCachingFileSystem(fs, 0) cfs := NewCachingFileSystem(fs, 0)
...@@ -38,11 +38,11 @@ func TestCachingFs(t *testing.T) { ...@@ -38,11 +38,11 @@ func TestCachingFs(t *testing.T) {
fi, code := cfs.GetAttr("orig") fi, code := cfs.GetAttr("orig")
if !code.Ok() { if !code.Ok() {
t.Fatal("GetAttr failure", code) t.Fatal("GetAttr failure", code)
} }
if !fi.IsDirectory() { if !fi.IsDirectory() {
t.Error("unexpected attr", fi) t.Error("unexpected attr", fi)
} }
os.Symlink("orig", wd+"/symlink") os.Symlink("orig", wd+"/symlink")
val, code := cfs.Readlink("symlink") val, code := cfs.Readlink("symlink")
...@@ -64,10 +64,9 @@ func TestCachingFs(t *testing.T) { ...@@ -64,10 +64,9 @@ func TestCachingFs(t *testing.T) {
} }
expected := map[string]uint32{ expected := map[string]uint32{
"symlink": syscall.S_IFLNK, "symlink": syscall.S_IFLNK,
"orig": fuse.S_IFDIR, "orig": fuse.S_IFDIR,
} }
if !modeMapEq(results, expected) { if !modeMapEq(results, expected) {
t.Error("Unexpected readdir result", results, expected) t.Error("Unexpected readdir result", results, expected)
} }
} }
...@@ -94,12 +94,12 @@ func (me *TimedCache) Purge() { ...@@ -94,12 +94,12 @@ func (me *TimedCache) Purge() {
} }
func (me *TimedCache) RecurringPurge() { func (me *TimedCache) RecurringPurge() {
if (me.ttlNs <= 0) { if me.ttlNs <= 0 {
return return
} }
me.Purge() me.Purge()
me.PurgeTimer = time.AfterFunc(me.ttlNs * 5, me.PurgeTimer = time.AfterFunc(me.ttlNs*5,
func() { me.RecurringPurge() }) func() { me.RecurringPurge() })
} }
......
...@@ -371,7 +371,7 @@ func (me *UnionFs) Utimens(name string, atime uint64, mtime uint64) (code fuse.S ...@@ -371,7 +371,7 @@ func (me *UnionFs) Utimens(name string, atime uint64, mtime uint64) (code fuse.S
r.branch = 0 r.branch = 0
} }
if code.Ok() { if code.Ok() {
code = me.fileSystems[0].Utimens(name, atime, mtime) code = me.fileSystems[0].Utimens(name, atime, mtime)
} }
if code.Ok() { if code.Ok() {
r.attr.Atime_ns = int64(atime) r.attr.Atime_ns = int64(atime)
...@@ -497,7 +497,7 @@ func (me *UnionFs) promoteDirsTo(filename string) fuse.Status { ...@@ -497,7 +497,7 @@ func (me *UnionFs) promoteDirsTo(filename string) fuse.Status {
if r.code != fuse.OK { if r.code != fuse.OK {
log.Println("path component does not exist", filename, dirName) log.Println("path component does not exist", filename, dirName)
} }
if r.attr.Mode & fuse.S_IFDIR == 0 { if r.attr.Mode&fuse.S_IFDIR == 0 {
log.Println("path component is not a directory.", dirName, r) log.Println("path component is not a directory.", dirName, r)
return fuse.EPERM return fuse.EPERM
} }
...@@ -511,7 +511,7 @@ func (me *UnionFs) promoteDirsTo(filename string) fuse.Status { ...@@ -511,7 +511,7 @@ func (me *UnionFs) promoteDirsTo(filename string) fuse.Status {
} }
for i, _ := range todo { for i, _ := range todo {
j := len(todo)-i-1 j := len(todo) - i - 1
d := todo[j] d := todo[j]
log.Println("Promoting directory", d) log.Println("Promoting directory", d)
code := me.fileSystems[0].Mkdir(d, 0755) code := me.fileSystems[0].Mkdir(d, 0755)
...@@ -539,9 +539,9 @@ func (me *UnionFs) Create(name string, flags uint32, mode uint32) (fuseFile fuse ...@@ -539,9 +539,9 @@ func (me *UnionFs) Create(name string, flags uint32, mode uint32) (fuseFile fuse
now := time.Nanoseconds() now := time.Nanoseconds()
a := os.FileInfo{ a := os.FileInfo{
Mode: fuse.S_IFREG | mode, Mode: fuse.S_IFREG | mode,
Ctime_ns: now, Ctime_ns: now,
Mtime_ns: now, Mtime_ns: now,
} }
me.branchCache.Set(name, branchResult{&a, fuse.OK, 0}) me.branchCache.Set(name, branchResult{&a, fuse.OK, 0})
} }
......
...@@ -43,8 +43,8 @@ func setupUfs(t *testing.T) (workdir string, cleanup func()) { ...@@ -43,8 +43,8 @@ func setupUfs(t *testing.T) (workdir string, cleanup func()) {
ufs := NewUnionFs(roots, testOpts) ufs := NewUnionFs(roots, testOpts)
opts := &fuse.MountOptions{ opts := &fuse.MountOptions{
EntryTimeout: entryTtl, EntryTimeout: entryTtl,
AttrTimeout: entryTtl, AttrTimeout: entryTtl,
NegativeTimeout: entryTtl, NegativeTimeout: entryTtl,
} }
...@@ -140,13 +140,13 @@ func TestChtimes(t *testing.T) { ...@@ -140,13 +140,13 @@ func TestChtimes(t *testing.T) {
defer clean() defer clean()
writeToFile(wd+"/ro/file", "a") writeToFile(wd+"/ro/file", "a")
err := os.Chtimes(wd + "/ro/file", 42e9, 43e9) err := os.Chtimes(wd+"/ro/file", 42e9, 43e9)
CheckSuccess(err) CheckSuccess(err)
err = os.Chtimes(wd + "/mount/file", 82e9, 83e9) err = os.Chtimes(wd+"/mount/file", 82e9, 83e9)
CheckSuccess(err) CheckSuccess(err)
fi, err := os.Lstat(wd +"/mount/file") fi, err := os.Lstat(wd + "/mount/file")
if fi.Atime_ns != 82e9 || fi.Mtime_ns != 83e9 { if fi.Atime_ns != 82e9 || fi.Mtime_ns != 83e9 {
t.Error("Incorrect timestamp", fi) t.Error("Incorrect timestamp", fi)
} }
...@@ -199,7 +199,7 @@ func TestBasic(t *testing.T) { ...@@ -199,7 +199,7 @@ func TestBasic(t *testing.T) {
t.Errorf("missing file in rw layer", names) t.Errorf("missing file in rw layer", names)
} }
contents := readFromFile(wd+"/mount/new") contents := readFromFile(wd + "/mount/new")
if contents != "new contents" { if contents != "new contents" {
t.Errorf("read mismatch: '%v'", contents) t.Errorf("read mismatch: '%v'", contents)
} }
...@@ -297,7 +297,7 @@ func TestMkdirPromote(t *testing.T) { ...@@ -297,7 +297,7 @@ func TestMkdirPromote(t *testing.T) {
err = os.Mkdir(wd+"/mount/subdir/subdir2/dir3", 0755) err = os.Mkdir(wd+"/mount/subdir/subdir2/dir3", 0755)
CheckSuccess(err) CheckSuccess(err)
fi, _ := os.Lstat(wd+"/rw/subdir/subdir2/dir3") fi, _ := os.Lstat(wd + "/rw/subdir/subdir2/dir3")
CheckSuccess(err) CheckSuccess(err)
if fi == nil || !fi.IsDirectory() { if fi == nil || !fi.IsDirectory() {
t.Error("is not a directory: ", fi) t.Error("is not a directory: ", fi)
...@@ -409,13 +409,13 @@ func TestCopyChmod(t *testing.T) { ...@@ -409,13 +409,13 @@ func TestCopyChmod(t *testing.T) {
fi, err := os.Lstat(fn) fi, err := os.Lstat(fn)
CheckSuccess(err) CheckSuccess(err)
if fi.Mode & 0111 == 0 { if fi.Mode&0111 == 0 {
t.Errorf("1st attr error %o", fi.Mode) t.Errorf("1st attr error %o", fi.Mode)
} }
time.Sleep(entryTtl * 1.1e9) time.Sleep(entryTtl * 1.1e9)
fi, err = os.Lstat(fn) fi, err = os.Lstat(fn)
CheckSuccess(err) CheckSuccess(err)
if fi.Mode & 0111 == 0 { if fi.Mode&0111 == 0 {
t.Errorf("uncached attr error %o", fi.Mode) t.Errorf("uncached attr error %o", fi.Mode)
} }
} }
...@@ -423,7 +423,7 @@ func TestCopyChmod(t *testing.T) { ...@@ -423,7 +423,7 @@ func TestCopyChmod(t *testing.T) {
func abs(dt int64) int64 { func abs(dt int64) int64 {
if dt >= 0 { if dt >= 0 {
return dt return dt
} }
return -dt return -dt
} }
...@@ -445,7 +445,7 @@ func TestTruncateTimestamp(t *testing.T) { ...@@ -445,7 +445,7 @@ func TestTruncateTimestamp(t *testing.T) {
fi, err := os.Lstat(fn) fi, err := os.Lstat(fn)
CheckSuccess(err) CheckSuccess(err)
if abs(truncTs - fi.Mtime_ns) > 0.1e9 { if abs(truncTs-fi.Mtime_ns) > 0.1e9 {
t.Error("timestamp drift", truncTs, fi.Mtime_ns) t.Error("timestamp drift", truncTs, fi.Mtime_ns)
} }
} }
...@@ -17,11 +17,11 @@ func TestZipFs(t *testing.T) { ...@@ -17,11 +17,11 @@ func TestZipFs(t *testing.T) {
connector := fuse.NewFileSystemConnector(zfs, nil) connector := fuse.NewFileSystemConnector(zfs, nil)
mountPoint := fuse.MakeTempDir() mountPoint := fuse.MakeTempDir()
defer os.RemoveAll(mountPoint) defer os.RemoveAll(mountPoint)
state := fuse.NewMountState(connector) state := fuse.NewMountState(connector)
state.Mount(mountPoint) state.Mount(mountPoint)
defer state.Unmount() defer state.Unmount()
go state.Loop(false) go state.Loop(false)
d, err := os.Open(mountPoint) d, err := os.Open(mountPoint)
......
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