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

Drop WrappingFileSystem and WrappingRawFileSystem: inclusion of

FileSystem into the struct already is sufficient.
parent 0b78f354
...@@ -16,12 +16,12 @@ var _ = runtime.GOMAXPROCS ...@@ -16,12 +16,12 @@ var _ = runtime.GOMAXPROCS
var _ = log.Print var _ = log.Print
type PathPrintingFs struct { type PathPrintingFs struct {
fuse.WrappingFileSystem fuse.FileSystem
} }
func (me *PathPrintingFs) GetAttr(name string) (*fuse.Attr, fuse.Status) { func (me *PathPrintingFs) GetAttr(name string) (*fuse.Attr, fuse.Status) {
log.Println(name) log.Println(name)
return me.Original.GetAttr(name) return me.FileSystem.GetAttr(name)
} }
func main() { func main() {
...@@ -57,7 +57,7 @@ func main() { ...@@ -57,7 +57,7 @@ func main() {
} }
if *latencies { if *latencies {
debugFs.Original = finalFs debugFs.FileSystem = finalFs
finalFs = debugFs finalFs = debugFs
} }
......
...@@ -31,7 +31,7 @@ func main() { ...@@ -31,7 +31,7 @@ func main() {
debugFs := fuse.NewFileSystemDebug() debugFs := fuse.NewFileSystemDebug()
if *latencies { if *latencies {
debugFs.Original = fs debugFs.FileSystem = fs
fs = debugFs fs = debugFs
} }
......
...@@ -14,7 +14,6 @@ GOFILES=misc.go\ ...@@ -14,7 +14,6 @@ GOFILES=misc.go\
datafile.go \ datafile.go \
lockingfs.go \ lockingfs.go \
loopback.go \ loopback.go \
wrappedfs.go \
timingfs.go \ timingfs.go \
timingrawfs.go \ timingrawfs.go \
xattr.go \ xattr.go \
......
...@@ -11,7 +11,6 @@ func TestRawFs(t *testing.T) { ...@@ -11,7 +11,6 @@ func TestRawFs(t *testing.T) {
var iface RawFileSystem var iface RawFileSystem
iface = new(DefaultRawFileSystem) iface = new(DefaultRawFileSystem)
iface = new(WrappingRawFileSystem)
iface = new(TimingRawFileSystem) iface = new(TimingRawFileSystem)
_ = iface _ = iface
...@@ -20,7 +19,6 @@ func TestRawFs(t *testing.T) { ...@@ -20,7 +19,6 @@ func TestRawFs(t *testing.T) {
func TestPathFs(t *testing.T) { func TestPathFs(t *testing.T) {
var iface FileSystem var iface FileSystem
iface = new(DefaultFileSystem) iface = new(DefaultFileSystem)
iface = new(WrappingFileSystem)
iface = new(TimingFileSystem) iface = new(TimingFileSystem)
_ = iface _ = iface
......
...@@ -10,336 +10,336 @@ import ( ...@@ -10,336 +10,336 @@ import (
type LockingFileSystem struct { type LockingFileSystem struct {
// Should be public so people reusing can access the wrapped // Should be public so people reusing can access the wrapped
// FS. // FS.
WrappingFileSystem FileSystem
lock sync.Mutex lock sync.Mutex
} }
func NewLockingFileSystem(pfs FileSystem) *LockingFileSystem { func NewLockingFileSystem(pfs FileSystem) *LockingFileSystem {
l := new(LockingFileSystem) l := new(LockingFileSystem)
l.Original = pfs l.FileSystem = pfs
return l return l
} }
func (me *LockingFileSystem) GetAttr(name string) (*Attr, Status) { func (me *LockingFileSystem) GetAttr(name string) (*Attr, Status) {
me.lock.Lock() me.lock.Lock()
defer me.lock.Unlock() defer me.lock.Unlock()
return me.Original.GetAttr(name) return me.FileSystem.GetAttr(name)
} }
func (me *LockingFileSystem) Readlink(name string) (string, Status) { func (me *LockingFileSystem) Readlink(name string) (string, Status) {
me.lock.Lock() me.lock.Lock()
defer me.lock.Unlock() defer me.lock.Unlock()
return me.Original.Readlink(name) return me.FileSystem.Readlink(name)
} }
func (me *LockingFileSystem) Mknod(name string, mode uint32, dev uint32) Status { func (me *LockingFileSystem) Mknod(name string, mode uint32, dev uint32) Status {
me.lock.Lock() me.lock.Lock()
defer me.lock.Unlock() defer me.lock.Unlock()
return me.Original.Mknod(name, mode, dev) return me.FileSystem.Mknod(name, mode, dev)
} }
func (me *LockingFileSystem) Mkdir(name string, mode uint32) Status { func (me *LockingFileSystem) Mkdir(name string, mode uint32) Status {
me.lock.Lock() me.lock.Lock()
defer me.lock.Unlock() defer me.lock.Unlock()
return me.Original.Mkdir(name, mode) return me.FileSystem.Mkdir(name, mode)
} }
func (me *LockingFileSystem) Unlink(name string) (code Status) { func (me *LockingFileSystem) Unlink(name string) (code Status) {
me.lock.Lock() me.lock.Lock()
defer me.lock.Unlock() defer me.lock.Unlock()
return me.Original.Unlink(name) return me.FileSystem.Unlink(name)
} }
func (me *LockingFileSystem) Rmdir(name string) (code Status) { func (me *LockingFileSystem) Rmdir(name string) (code Status) {
me.lock.Lock() me.lock.Lock()
defer me.lock.Unlock() defer me.lock.Unlock()
return me.Original.Rmdir(name) return me.FileSystem.Rmdir(name)
} }
func (me *LockingFileSystem) Symlink(value string, linkName string) (code Status) { func (me *LockingFileSystem) Symlink(value string, linkName string) (code Status) {
me.lock.Lock() me.lock.Lock()
defer me.lock.Unlock() defer me.lock.Unlock()
return me.Original.Symlink(value, linkName) return me.FileSystem.Symlink(value, linkName)
} }
func (me *LockingFileSystem) Rename(oldName string, newName string) (code Status) { func (me *LockingFileSystem) Rename(oldName string, newName string) (code Status) {
me.lock.Lock() me.lock.Lock()
defer me.lock.Unlock() defer me.lock.Unlock()
return me.Original.Rename(oldName, newName) return me.FileSystem.Rename(oldName, newName)
} }
func (me *LockingFileSystem) Link(oldName string, newName string) (code Status) { func (me *LockingFileSystem) Link(oldName string, newName string) (code Status) {
me.lock.Lock() me.lock.Lock()
defer me.lock.Unlock() defer me.lock.Unlock()
return me.Original.Link(oldName, newName) return me.FileSystem.Link(oldName, newName)
} }
func (me *LockingFileSystem) Chmod(name string, mode uint32) (code Status) { func (me *LockingFileSystem) Chmod(name string, mode uint32) (code Status) {
me.lock.Lock() me.lock.Lock()
defer me.lock.Unlock() defer me.lock.Unlock()
return me.Original.Chmod(name, mode) return me.FileSystem.Chmod(name, mode)
} }
func (me *LockingFileSystem) Chown(name string, uid uint32, gid uint32) (code Status) { func (me *LockingFileSystem) Chown(name string, uid uint32, gid uint32) (code Status) {
me.lock.Lock() me.lock.Lock()
defer me.lock.Unlock() defer me.lock.Unlock()
return me.Original.Chown(name, uid, gid) return me.FileSystem.Chown(name, uid, gid)
} }
func (me *LockingFileSystem) Truncate(name string, offset uint64) (code Status) { func (me *LockingFileSystem) Truncate(name string, offset uint64) (code Status) {
me.lock.Lock() me.lock.Lock()
defer me.lock.Unlock() defer me.lock.Unlock()
return me.Original.Truncate(name, offset) return me.FileSystem.Truncate(name, offset)
} }
func (me *LockingFileSystem) Open(name string, flags uint32) (file File, code Status) { func (me *LockingFileSystem) Open(name string, flags uint32) (file File, code Status) {
return me.Original.Open(name, flags) return me.FileSystem.Open(name, flags)
} }
func (me *LockingFileSystem) OpenDir(name string) (stream chan DirEntry, status Status) { func (me *LockingFileSystem) OpenDir(name string) (stream chan DirEntry, status Status) {
me.lock.Lock() me.lock.Lock()
defer me.lock.Unlock() defer me.lock.Unlock()
return me.Original.OpenDir(name) return me.FileSystem.OpenDir(name)
} }
func (me *LockingFileSystem) Mount(conn *FileSystemConnector) Status { func (me *LockingFileSystem) Mount(conn *FileSystemConnector) Status {
me.lock.Lock() me.lock.Lock()
defer me.lock.Unlock() defer me.lock.Unlock()
return me.Original.Mount(conn) return me.FileSystem.Mount(conn)
} }
func (me *LockingFileSystem) Unmount() { func (me *LockingFileSystem) Unmount() {
me.lock.Lock() me.lock.Lock()
defer me.lock.Unlock() defer me.lock.Unlock()
me.Original.Unmount() me.FileSystem.Unmount()
} }
func (me *LockingFileSystem) Access(name string, mode uint32) (code Status) { func (me *LockingFileSystem) Access(name string, mode uint32) (code Status) {
me.lock.Lock() me.lock.Lock()
defer me.lock.Unlock() defer me.lock.Unlock()
return me.Original.Access(name, mode) return me.FileSystem.Access(name, mode)
} }
func (me *LockingFileSystem) Create(name string, flags uint32, mode uint32) (file File, code Status) { func (me *LockingFileSystem) Create(name string, flags uint32, mode uint32) (file File, code Status) {
me.lock.Lock() me.lock.Lock()
defer me.lock.Unlock() defer me.lock.Unlock()
return me.Original.Create(name, flags, mode) return me.FileSystem.Create(name, flags, mode)
} }
func (me *LockingFileSystem) Utimens(name string, AtimeNs uint64, CtimeNs uint64) (code Status) { func (me *LockingFileSystem) Utimens(name string, AtimeNs uint64, CtimeNs uint64) (code Status) {
me.lock.Lock() me.lock.Lock()
defer me.lock.Unlock() defer me.lock.Unlock()
return me.Original.Utimens(name, AtimeNs, CtimeNs) return me.FileSystem.Utimens(name, AtimeNs, CtimeNs)
} }
func (me *LockingFileSystem) GetXAttr(name string, attr string) ([]byte, Status) { func (me *LockingFileSystem) GetXAttr(name string, attr string) ([]byte, Status) {
me.lock.Lock() me.lock.Lock()
defer me.lock.Unlock() defer me.lock.Unlock()
return me.Original.GetXAttr(name, attr) return me.FileSystem.GetXAttr(name, attr)
} }
func (me *LockingFileSystem) SetXAttr(name string, attr string, data []byte, flags int) Status { func (me *LockingFileSystem) SetXAttr(name string, attr string, data []byte, flags int) Status {
me.lock.Lock() me.lock.Lock()
defer me.lock.Unlock() defer me.lock.Unlock()
return me.Original.SetXAttr(name, attr, data, flags) return me.FileSystem.SetXAttr(name, attr, data, flags)
} }
func (me *LockingFileSystem) ListXAttr(name string) ([]string, Status) { func (me *LockingFileSystem) ListXAttr(name string) ([]string, Status) {
me.lock.Lock() me.lock.Lock()
defer me.lock.Unlock() defer me.lock.Unlock()
return me.Original.ListXAttr(name) return me.FileSystem.ListXAttr(name)
} }
func (me *LockingFileSystem) RemoveXAttr(name string, attr string) Status { func (me *LockingFileSystem) RemoveXAttr(name string, attr string) Status {
me.lock.Lock() me.lock.Lock()
defer me.lock.Unlock() defer me.lock.Unlock()
return me.Original.RemoveXAttr(name, attr) return me.FileSystem.RemoveXAttr(name, attr)
} }
//////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////
// Locking raw FS. // Locking raw FS.
type LockingRawFileSystem struct { type LockingRawFileSystem struct {
WrappingRawFileSystem RawFileSystem
lock sync.Mutex lock sync.Mutex
} }
func NewLockingRawFileSystem(rfs RawFileSystem) *LockingRawFileSystem { func NewLockingRawFileSystem(rfs RawFileSystem) *LockingRawFileSystem {
l := &LockingRawFileSystem{} l := &LockingRawFileSystem{}
l.Original = rfs l.RawFileSystem = rfs
return l return l
} }
func (me *LockingRawFileSystem) Destroy(h *InHeader, input *InitIn) { func (me *LockingRawFileSystem) Destroy(h *InHeader, input *InitIn) {
me.lock.Lock() me.lock.Lock()
defer me.lock.Unlock() defer me.lock.Unlock()
me.Original.Destroy(h, input) me.RawFileSystem.Destroy(h, input)
} }
func (me *LockingRawFileSystem) Lookup(h *InHeader, name string) (out *EntryOut, code Status) { func (me *LockingRawFileSystem) Lookup(h *InHeader, name string) (out *EntryOut, code Status) {
me.lock.Lock() me.lock.Lock()
defer me.lock.Unlock() defer me.lock.Unlock()
return me.Original.Lookup(h, name) return me.RawFileSystem.Lookup(h, name)
} }
func (me *LockingRawFileSystem) Forget(h *InHeader, input *ForgetIn) { func (me *LockingRawFileSystem) Forget(h *InHeader, input *ForgetIn) {
me.lock.Lock() me.lock.Lock()
defer me.lock.Unlock() defer me.lock.Unlock()
me.Original.Forget(h, input) me.RawFileSystem.Forget(h, input)
} }
func (me *LockingRawFileSystem) GetAttr(header *InHeader, input *GetAttrIn) (out *AttrOut, code Status) { func (me *LockingRawFileSystem) GetAttr(header *InHeader, input *GetAttrIn) (out *AttrOut, code Status) {
me.lock.Lock() me.lock.Lock()
defer me.lock.Unlock() defer me.lock.Unlock()
return me.Original.GetAttr(header, input) return me.RawFileSystem.GetAttr(header, input)
} }
func (me *LockingRawFileSystem) Open(header *InHeader, input *OpenIn) (flags uint32, handle uint64, status Status) { func (me *LockingRawFileSystem) Open(header *InHeader, input *OpenIn) (flags uint32, handle uint64, status Status) {
me.lock.Lock() me.lock.Lock()
defer me.lock.Unlock() defer me.lock.Unlock()
return me.Original.Open(header, input) return me.RawFileSystem.Open(header, input)
} }
func (me *LockingRawFileSystem) SetAttr(header *InHeader, input *SetAttrIn) (out *AttrOut, code Status) { func (me *LockingRawFileSystem) SetAttr(header *InHeader, input *SetAttrIn) (out *AttrOut, code Status) {
me.lock.Lock() me.lock.Lock()
defer me.lock.Unlock() defer me.lock.Unlock()
return me.Original.SetAttr(header, input) return me.RawFileSystem.SetAttr(header, input)
} }
func (me *LockingRawFileSystem) Readlink(header *InHeader) (out []byte, code Status) { func (me *LockingRawFileSystem) Readlink(header *InHeader) (out []byte, code Status) {
me.lock.Lock() me.lock.Lock()
defer me.lock.Unlock() defer me.lock.Unlock()
return me.Original.Readlink(header) return me.RawFileSystem.Readlink(header)
} }
func (me *LockingRawFileSystem) Mknod(header *InHeader, input *MknodIn, name string) (out *EntryOut, code Status) { func (me *LockingRawFileSystem) Mknod(header *InHeader, input *MknodIn, name string) (out *EntryOut, code Status) {
me.lock.Lock() me.lock.Lock()
defer me.lock.Unlock() defer me.lock.Unlock()
return me.Original.Mknod(header, input, name) return me.RawFileSystem.Mknod(header, input, name)
} }
func (me *LockingRawFileSystem) Mkdir(header *InHeader, input *MkdirIn, name string) (out *EntryOut, code Status) { func (me *LockingRawFileSystem) Mkdir(header *InHeader, input *MkdirIn, name string) (out *EntryOut, code Status) {
me.lock.Lock() me.lock.Lock()
defer me.lock.Unlock() defer me.lock.Unlock()
return me.Original.Mkdir(header, input, name) return me.RawFileSystem.Mkdir(header, input, name)
} }
func (me *LockingRawFileSystem) Unlink(header *InHeader, name string) (code Status) { func (me *LockingRawFileSystem) Unlink(header *InHeader, name string) (code Status) {
me.lock.Lock() me.lock.Lock()
defer me.lock.Unlock() defer me.lock.Unlock()
return me.Original.Unlink(header, name) return me.RawFileSystem.Unlink(header, name)
} }
func (me *LockingRawFileSystem) Rmdir(header *InHeader, name string) (code Status) { func (me *LockingRawFileSystem) Rmdir(header *InHeader, name string) (code Status) {
me.lock.Lock() me.lock.Lock()
defer me.lock.Unlock() defer me.lock.Unlock()
return me.Original.Rmdir(header, name) return me.RawFileSystem.Rmdir(header, name)
} }
func (me *LockingRawFileSystem) Symlink(header *InHeader, pointedTo string, linkName string) (out *EntryOut, code Status) { func (me *LockingRawFileSystem) Symlink(header *InHeader, pointedTo string, linkName string) (out *EntryOut, code Status) {
me.lock.Lock() me.lock.Lock()
defer me.lock.Unlock() defer me.lock.Unlock()
return me.Original.Symlink(header, pointedTo, linkName) return me.RawFileSystem.Symlink(header, pointedTo, linkName)
} }
func (me *LockingRawFileSystem) Rename(header *InHeader, input *RenameIn, oldName string, newName string) (code Status) { func (me *LockingRawFileSystem) Rename(header *InHeader, input *RenameIn, oldName string, newName string) (code Status) {
me.lock.Lock() me.lock.Lock()
defer me.lock.Unlock() defer me.lock.Unlock()
return me.Original.Rename(header, input, oldName, newName) return me.RawFileSystem.Rename(header, input, oldName, newName)
} }
func (me *LockingRawFileSystem) Link(header *InHeader, input *LinkIn, name string) (out *EntryOut, code Status) { func (me *LockingRawFileSystem) Link(header *InHeader, input *LinkIn, name string) (out *EntryOut, code Status) {
me.lock.Lock() me.lock.Lock()
defer me.lock.Unlock() defer me.lock.Unlock()
return me.Original.Link(header, input, name) return me.RawFileSystem.Link(header, input, name)
} }
func (me *LockingRawFileSystem) SetXAttr(header *InHeader, input *SetXAttrIn, attr string, data []byte) Status { func (me *LockingRawFileSystem) SetXAttr(header *InHeader, input *SetXAttrIn, attr string, data []byte) Status {
me.lock.Lock() me.lock.Lock()
defer me.lock.Unlock() defer me.lock.Unlock()
return me.Original.SetXAttr(header, input, attr, data) return me.RawFileSystem.SetXAttr(header, input, attr, data)
} }
func (me *LockingRawFileSystem) GetXAttr(header *InHeader, attr string) (data []byte, code Status) { func (me *LockingRawFileSystem) GetXAttr(header *InHeader, attr string) (data []byte, code Status) {
me.lock.Lock() me.lock.Lock()
defer me.lock.Unlock() defer me.lock.Unlock()
return me.Original.GetXAttr(header, attr) return me.RawFileSystem.GetXAttr(header, attr)
} }
func (me *LockingRawFileSystem) ListXAttr(header *InHeader) (data []byte, code Status) { func (me *LockingRawFileSystem) ListXAttr(header *InHeader) (data []byte, code Status) {
me.lock.Lock() me.lock.Lock()
defer me.lock.Unlock() defer me.lock.Unlock()
return me.Original.ListXAttr(header) return me.RawFileSystem.ListXAttr(header)
} }
func (me *LockingRawFileSystem) RemoveXAttr(header *InHeader, attr string) Status { func (me *LockingRawFileSystem) RemoveXAttr(header *InHeader, attr string) Status {
me.lock.Lock() me.lock.Lock()
defer me.lock.Unlock() defer me.lock.Unlock()
return me.Original.RemoveXAttr(header, attr) return me.RawFileSystem.RemoveXAttr(header, attr)
} }
func (me *LockingRawFileSystem) Access(header *InHeader, input *AccessIn) (code Status) { func (me *LockingRawFileSystem) Access(header *InHeader, input *AccessIn) (code Status) {
me.lock.Lock() me.lock.Lock()
defer me.lock.Unlock() defer me.lock.Unlock()
return me.Original.Access(header, input) return me.RawFileSystem.Access(header, input)
} }
func (me *LockingRawFileSystem) Create(header *InHeader, input *CreateIn, name string) (flags uint32, handle uint64, out *EntryOut, code Status) { func (me *LockingRawFileSystem) Create(header *InHeader, input *CreateIn, name string) (flags uint32, handle uint64, out *EntryOut, code Status) {
me.lock.Lock() me.lock.Lock()
defer me.lock.Unlock() defer me.lock.Unlock()
return me.Original.Create(header, input, name) return me.RawFileSystem.Create(header, input, name)
} }
func (me *LockingRawFileSystem) OpenDir(header *InHeader, input *OpenIn) (flags uint32, h uint64, status Status) { func (me *LockingRawFileSystem) OpenDir(header *InHeader, input *OpenIn) (flags uint32, h uint64, status Status) {
me.lock.Lock() me.lock.Lock()
defer me.lock.Unlock() defer me.lock.Unlock()
return me.Original.OpenDir(header, input) return me.RawFileSystem.OpenDir(header, input)
} }
func (me *LockingRawFileSystem) Release(header *InHeader, input *ReleaseIn) { func (me *LockingRawFileSystem) Release(header *InHeader, input *ReleaseIn) {
me.lock.Lock() me.lock.Lock()
defer me.lock.Unlock() defer me.lock.Unlock()
me.Original.Release(header, input) me.RawFileSystem.Release(header, input)
} }
func (me *LockingRawFileSystem) ReleaseDir(header *InHeader, h *ReleaseIn) { func (me *LockingRawFileSystem) ReleaseDir(header *InHeader, h *ReleaseIn) {
me.lock.Lock() me.lock.Lock()
defer me.lock.Unlock() defer me.lock.Unlock()
me.Original.ReleaseDir(header, h) me.RawFileSystem.ReleaseDir(header, h)
} }
func (me *LockingRawFileSystem) Read(input *ReadIn, bp *BufferPool) ([]byte, Status) { func (me *LockingRawFileSystem) Read(input *ReadIn, bp *BufferPool) ([]byte, Status) {
me.lock.Lock() me.lock.Lock()
defer me.lock.Unlock() defer me.lock.Unlock()
return me.Original.Read(input, bp) return me.RawFileSystem.Read(input, bp)
} }
func (me *LockingRawFileSystem) Write(input *WriteIn, data []byte) (written uint32, code Status) { func (me *LockingRawFileSystem) Write(input *WriteIn, data []byte) (written uint32, code Status) {
me.lock.Lock() me.lock.Lock()
defer me.lock.Unlock() defer me.lock.Unlock()
return me.Original.Write(input, data) return me.RawFileSystem.Write(input, data)
} }
func (me *LockingRawFileSystem) Flush(input *FlushIn) Status { func (me *LockingRawFileSystem) Flush(input *FlushIn) Status {
me.lock.Lock() me.lock.Lock()
defer me.lock.Unlock() defer me.lock.Unlock()
return me.Original.Flush(input) return me.RawFileSystem.Flush(input)
} }
func (me *LockingRawFileSystem) Fsync(input *FsyncIn) (code Status) { func (me *LockingRawFileSystem) Fsync(input *FsyncIn) (code Status) {
me.lock.Lock() me.lock.Lock()
defer me.lock.Unlock() defer me.lock.Unlock()
return me.Original.Fsync(input) return me.RawFileSystem.Fsync(input)
} }
func (me *LockingRawFileSystem) ReadDir(header *InHeader, input *ReadIn) (*DirEntryList, Status) { func (me *LockingRawFileSystem) ReadDir(header *InHeader, input *ReadIn) (*DirEntryList, Status) {
me.lock.Lock() me.lock.Lock()
defer me.lock.Unlock() defer me.lock.Unlock()
return me.Original.ReadDir(header, input) return me.RawFileSystem.ReadDir(header, input)
} }
func (me *LockingRawFileSystem) FsyncDir(header *InHeader, input *FsyncIn) (code Status) { func (me *LockingRawFileSystem) FsyncDir(header *InHeader, input *FsyncIn) (code Status) {
me.lock.Lock() me.lock.Lock()
defer me.lock.Unlock() defer me.lock.Unlock()
return me.Original.FsyncDir(header, input) return me.RawFileSystem.FsyncDir(header, input)
} }
...@@ -27,7 +27,7 @@ type getter func() []byte ...@@ -27,7 +27,7 @@ type getter func() []byte
type FileSystemDebug struct { type FileSystemDebug struct {
sync.RWMutex sync.RWMutex
callbacks map[string]getter callbacks map[string]getter
WrappingFileSystem FileSystem
} }
func NewFileSystemDebug() *FileSystemDebug { func NewFileSystemDebug() *FileSystemDebug {
...@@ -48,7 +48,7 @@ func (me *FileSystemDebug) Open(path string, flags uint32) (fuseFile File, statu ...@@ -48,7 +48,7 @@ func (me *FileSystemDebug) Open(path string, flags uint32) (fuseFile File, statu
if content != nil { if content != nil {
return NewReadOnlyFile(content), OK return NewReadOnlyFile(content), OK
} }
return me.Original.Open(path, flags) return me.FileSystem.Open(path, flags)
} }
func (me *FileSystemDebug) getContent(path string) []byte { func (me *FileSystemDebug) getContent(path string) []byte {
...@@ -68,12 +68,12 @@ func (me *FileSystemDebug) GetXAttr(name string, attr string) ([]byte, Status) { ...@@ -68,12 +68,12 @@ func (me *FileSystemDebug) GetXAttr(name string, attr string) ([]byte, Status) {
if strings.HasPrefix(name, DebugDir) { if strings.HasPrefix(name, DebugDir) {
return nil, syscall.ENODATA return nil, syscall.ENODATA
} }
return me.Original.GetXAttr(name, attr) return me.FileSystem.GetXAttr(name, attr)
} }
func (me *FileSystemDebug) GetAttr(path string) (*Attr, Status) { func (me *FileSystemDebug) GetAttr(path string) (*Attr, Status) {
if !strings.HasPrefix(path, DebugDir) { if !strings.HasPrefix(path, DebugDir) {
return me.Original.GetAttr(path) return me.FileSystem.GetAttr(path)
} }
if path == DebugDir { if path == DebugDir {
return &Attr{ return &Attr{
...@@ -136,7 +136,7 @@ func (me *FileSystemDebug) OpenDir(name string) (stream chan DirEntry, status St ...@@ -136,7 +136,7 @@ func (me *FileSystemDebug) OpenDir(name string) (stream chan DirEntry, status St
close(stream) close(stream)
return stream, OK return stream, OK
} }
return me.Original.OpenDir(name) return me.FileSystem.OpenDir(name)
} }
func (me *FileSystemDebug) AddMountState(state *MountState) { func (me *FileSystemDebug) AddMountState(state *MountState) {
......
...@@ -9,7 +9,7 @@ import ( ...@@ -9,7 +9,7 @@ import (
func TestPathDebug(t *testing.T) { func TestPathDebug(t *testing.T) {
debugFs := NewFileSystemDebug() debugFs := NewFileSystemDebug()
debugFs.Original = &DefaultFileSystem{} debugFs.FileSystem = &DefaultFileSystem{}
debugFs.Add("test-entry", func() []byte { return []byte("test-content") }) debugFs.Add("test-entry", func() []byte { return []byte("test-content") })
connector := NewFileSystemConnector(debugFs, nil) connector := NewFileSystemConnector(debugFs, nil)
......
...@@ -11,7 +11,7 @@ var _ = fmt.Print ...@@ -11,7 +11,7 @@ var _ = fmt.Print
// TimingFileSystem is a wrapper to collect timings for a FileSystem // TimingFileSystem is a wrapper to collect timings for a FileSystem
type TimingFileSystem struct { type TimingFileSystem struct {
WrappingFileSystem FileSystem
*LatencyMap *LatencyMap
} }
...@@ -19,7 +19,7 @@ type TimingFileSystem struct { ...@@ -19,7 +19,7 @@ type TimingFileSystem struct {
func NewTimingFileSystem(fs FileSystem) *TimingFileSystem { func NewTimingFileSystem(fs FileSystem) *TimingFileSystem {
t := new(TimingFileSystem) t := new(TimingFileSystem)
t.LatencyMap = NewLatencyMap() t.LatencyMap = NewLatencyMap()
t.Original = fs t.FileSystem = fs
return t return t
} }
...@@ -46,115 +46,115 @@ func (me *TimingFileSystem) HotPaths(operation string) (paths []string) { ...@@ -46,115 +46,115 @@ func (me *TimingFileSystem) HotPaths(operation string) (paths []string) {
func (me *TimingFileSystem) GetAttr(name string) (*Attr, Status) { func (me *TimingFileSystem) GetAttr(name string) (*Attr, Status) {
defer me.startTimer("GetAttr", name)() defer me.startTimer("GetAttr", name)()
return me.Original.GetAttr(name) return me.FileSystem.GetAttr(name)
} }
func (me *TimingFileSystem) GetXAttr(name string, attr string) ([]byte, Status) { func (me *TimingFileSystem) GetXAttr(name string, attr string) ([]byte, Status) {
defer me.startTimer("GetXAttr", name)() defer me.startTimer("GetXAttr", name)()
return me.Original.GetXAttr(name, attr) return me.FileSystem.GetXAttr(name, attr)
} }
func (me *TimingFileSystem) SetXAttr(name string, attr string, data []byte, flags int) Status { func (me *TimingFileSystem) SetXAttr(name string, attr string, data []byte, flags int) Status {
defer me.startTimer("SetXAttr", name)() defer me.startTimer("SetXAttr", name)()
return me.Original.SetXAttr(name, attr, data, flags) return me.FileSystem.SetXAttr(name, attr, data, flags)
} }
func (me *TimingFileSystem) ListXAttr(name string) ([]string, Status) { func (me *TimingFileSystem) ListXAttr(name string) ([]string, Status) {
defer me.startTimer("ListXAttr", name)() defer me.startTimer("ListXAttr", name)()
return me.Original.ListXAttr(name) return me.FileSystem.ListXAttr(name)
} }
func (me *TimingFileSystem) RemoveXAttr(name string, attr string) Status { func (me *TimingFileSystem) RemoveXAttr(name string, attr string) Status {
defer me.startTimer("RemoveXAttr", name)() defer me.startTimer("RemoveXAttr", name)()
return me.Original.RemoveXAttr(name, attr) return me.FileSystem.RemoveXAttr(name, attr)
} }
func (me *TimingFileSystem) Readlink(name string) (string, Status) { func (me *TimingFileSystem) Readlink(name string) (string, Status) {
defer me.startTimer("Readlink", name)() defer me.startTimer("Readlink", name)()
return me.Original.Readlink(name) return me.FileSystem.Readlink(name)
} }
func (me *TimingFileSystem) Mknod(name string, mode uint32, dev uint32) Status { func (me *TimingFileSystem) Mknod(name string, mode uint32, dev uint32) Status {
defer me.startTimer("Mknod", name)() defer me.startTimer("Mknod", name)()
return me.Original.Mknod(name, mode, dev) return me.FileSystem.Mknod(name, mode, dev)
} }
func (me *TimingFileSystem) Mkdir(name string, mode uint32) Status { func (me *TimingFileSystem) Mkdir(name string, mode uint32) Status {
defer me.startTimer("Mkdir", name)() defer me.startTimer("Mkdir", name)()
return me.Original.Mkdir(name, mode) return me.FileSystem.Mkdir(name, mode)
} }
func (me *TimingFileSystem) Unlink(name string) (code Status) { func (me *TimingFileSystem) Unlink(name string) (code Status) {
defer me.startTimer("Unlink", name)() defer me.startTimer("Unlink", name)()
return me.Original.Unlink(name) return me.FileSystem.Unlink(name)
} }
func (me *TimingFileSystem) Rmdir(name string) (code Status) { func (me *TimingFileSystem) Rmdir(name string) (code Status) {
defer me.startTimer("Rmdir", name)() defer me.startTimer("Rmdir", name)()
return me.Original.Rmdir(name) return me.FileSystem.Rmdir(name)
} }
func (me *TimingFileSystem) Symlink(value string, linkName string) (code Status) { func (me *TimingFileSystem) Symlink(value string, linkName string) (code Status) {
defer me.startTimer("Symlink", linkName)() defer me.startTimer("Symlink", linkName)()
return me.Original.Symlink(value, linkName) return me.FileSystem.Symlink(value, linkName)
} }
func (me *TimingFileSystem) Rename(oldName string, newName string) (code Status) { func (me *TimingFileSystem) Rename(oldName string, newName string) (code Status) {
defer me.startTimer("Rename", oldName)() defer me.startTimer("Rename", oldName)()
return me.Original.Rename(oldName, newName) return me.FileSystem.Rename(oldName, newName)
} }
func (me *TimingFileSystem) Link(oldName string, newName string) (code Status) { func (me *TimingFileSystem) Link(oldName string, newName string) (code Status) {
defer me.startTimer("Link", newName)() defer me.startTimer("Link", newName)()
return me.Original.Link(oldName, newName) return me.FileSystem.Link(oldName, newName)
} }
func (me *TimingFileSystem) Chmod(name string, mode uint32) (code Status) { func (me *TimingFileSystem) Chmod(name string, mode uint32) (code Status) {
defer me.startTimer("Chmod", name)() defer me.startTimer("Chmod", name)()
return me.Original.Chmod(name, mode) return me.FileSystem.Chmod(name, mode)
} }
func (me *TimingFileSystem) Chown(name string, uid uint32, gid uint32) (code Status) { func (me *TimingFileSystem) Chown(name string, uid uint32, gid uint32) (code Status) {
defer me.startTimer("Chown", name)() defer me.startTimer("Chown", name)()
return me.Original.Chown(name, uid, gid) return me.FileSystem.Chown(name, uid, gid)
} }
func (me *TimingFileSystem) Truncate(name string, offset uint64) (code Status) { func (me *TimingFileSystem) Truncate(name string, offset uint64) (code Status) {
defer me.startTimer("Truncate", name)() defer me.startTimer("Truncate", name)()
return me.Original.Truncate(name, offset) return me.FileSystem.Truncate(name, offset)
} }
func (me *TimingFileSystem) Open(name string, flags uint32) (file File, code Status) { func (me *TimingFileSystem) Open(name string, flags uint32) (file File, code Status) {
defer me.startTimer("Open", name)() defer me.startTimer("Open", name)()
return me.Original.Open(name, flags) return me.FileSystem.Open(name, flags)
} }
func (me *TimingFileSystem) OpenDir(name string) (stream chan DirEntry, status Status) { func (me *TimingFileSystem) OpenDir(name string) (stream chan DirEntry, status Status) {
defer me.startTimer("OpenDir", name)() defer me.startTimer("OpenDir", name)()
return me.Original.OpenDir(name) return me.FileSystem.OpenDir(name)
} }
func (me *TimingFileSystem) Mount(conn *FileSystemConnector) Status { func (me *TimingFileSystem) Mount(conn *FileSystemConnector) Status {
defer me.startTimer("Mount", "")() defer me.startTimer("Mount", "")()
return me.Original.Mount(conn) return me.FileSystem.Mount(conn)
} }
func (me *TimingFileSystem) Unmount() { func (me *TimingFileSystem) Unmount() {
defer me.startTimer("Unmount", "")() defer me.startTimer("Unmount", "")()
me.Original.Unmount() me.FileSystem.Unmount()
} }
func (me *TimingFileSystem) Access(name string, mode uint32) (code Status) { func (me *TimingFileSystem) Access(name string, mode uint32) (code Status) {
defer me.startTimer("Access", name)() defer me.startTimer("Access", name)()
return me.Original.Access(name, mode) return me.FileSystem.Access(name, mode)
} }
func (me *TimingFileSystem) Create(name string, flags uint32, mode uint32) (file File, code Status) { func (me *TimingFileSystem) Create(name string, flags uint32, mode uint32) (file File, code Status) {
defer me.startTimer("Create", name)() defer me.startTimer("Create", name)()
return me.Original.Create(name, flags, mode) return me.FileSystem.Create(name, flags, mode)
} }
func (me *TimingFileSystem) Utimens(name string, AtimeNs uint64, CtimeNs uint64) (code Status) { func (me *TimingFileSystem) Utimens(name string, AtimeNs uint64, CtimeNs uint64) (code Status) {
defer me.startTimer("Utimens", name)() defer me.startTimer("Utimens", name)()
return me.Original.Utimens(name, AtimeNs, CtimeNs) return me.FileSystem.Utimens(name, AtimeNs, CtimeNs)
} }
...@@ -6,14 +6,14 @@ import ( ...@@ -6,14 +6,14 @@ import (
// TimingRawFileSystem is a wrapper to collect timings for a RawFileSystem // TimingRawFileSystem is a wrapper to collect timings for a RawFileSystem
type TimingRawFileSystem struct { type TimingRawFileSystem struct {
WrappingRawFileSystem RawFileSystem
*LatencyMap *LatencyMap
} }
func NewTimingRawFileSystem(fs RawFileSystem) *TimingRawFileSystem { func NewTimingRawFileSystem(fs RawFileSystem) *TimingRawFileSystem {
t := new(TimingRawFileSystem) t := new(TimingRawFileSystem)
t.Original = fs t.RawFileSystem = fs
t.LatencyMap = NewLatencyMap() t.LatencyMap = NewLatencyMap()
return t return t
} }
...@@ -33,145 +33,145 @@ func (me *TimingRawFileSystem) Latencies() map[string]float64 { ...@@ -33,145 +33,145 @@ func (me *TimingRawFileSystem) Latencies() map[string]float64 {
func (me *TimingRawFileSystem) Destroy(h *InHeader, input *InitIn) { func (me *TimingRawFileSystem) Destroy(h *InHeader, input *InitIn) {
defer me.startTimer("Destroy")() defer me.startTimer("Destroy")()
me.Original.Destroy(h, input) me.RawFileSystem.Destroy(h, input)
} }
func (me *TimingRawFileSystem) Lookup(h *InHeader, name string) (out *EntryOut, code Status) { func (me *TimingRawFileSystem) Lookup(h *InHeader, name string) (out *EntryOut, code Status) {
defer me.startTimer("Lookup")() defer me.startTimer("Lookup")()
return me.Original.Lookup(h, name) return me.RawFileSystem.Lookup(h, name)
} }
func (me *TimingRawFileSystem) Forget(h *InHeader, input *ForgetIn) { func (me *TimingRawFileSystem) Forget(h *InHeader, input *ForgetIn) {
defer me.startTimer("Forget")() defer me.startTimer("Forget")()
me.Original.Forget(h, input) me.RawFileSystem.Forget(h, input)
} }
func (me *TimingRawFileSystem) GetAttr(header *InHeader, input *GetAttrIn) (out *AttrOut, code Status) { func (me *TimingRawFileSystem) GetAttr(header *InHeader, input *GetAttrIn) (out *AttrOut, code Status) {
defer me.startTimer("GetAttr")() defer me.startTimer("GetAttr")()
return me.Original.GetAttr(header, input) return me.RawFileSystem.GetAttr(header, input)
} }
func (me *TimingRawFileSystem) Open(header *InHeader, input *OpenIn) (flags uint32, handle uint64, status Status) { func (me *TimingRawFileSystem) Open(header *InHeader, input *OpenIn) (flags uint32, handle uint64, status Status) {
defer me.startTimer("Open")() defer me.startTimer("Open")()
return me.Original.Open(header, input) return me.RawFileSystem.Open(header, input)
} }
func (me *TimingRawFileSystem) SetAttr(header *InHeader, input *SetAttrIn) (out *AttrOut, code Status) { func (me *TimingRawFileSystem) SetAttr(header *InHeader, input *SetAttrIn) (out *AttrOut, code Status) {
defer me.startTimer("SetAttr")() defer me.startTimer("SetAttr")()
return me.Original.SetAttr(header, input) return me.RawFileSystem.SetAttr(header, input)
} }
func (me *TimingRawFileSystem) Readlink(header *InHeader) (out []byte, code Status) { func (me *TimingRawFileSystem) Readlink(header *InHeader) (out []byte, code Status) {
defer me.startTimer("Readlink")() defer me.startTimer("Readlink")()
return me.Original.Readlink(header) return me.RawFileSystem.Readlink(header)
} }
func (me *TimingRawFileSystem) Mknod(header *InHeader, input *MknodIn, name string) (out *EntryOut, code Status) { func (me *TimingRawFileSystem) Mknod(header *InHeader, input *MknodIn, name string) (out *EntryOut, code Status) {
defer me.startTimer("Mknod")() defer me.startTimer("Mknod")()
return me.Original.Mknod(header, input, name) return me.RawFileSystem.Mknod(header, input, name)
} }
func (me *TimingRawFileSystem) Mkdir(header *InHeader, input *MkdirIn, name string) (out *EntryOut, code Status) { func (me *TimingRawFileSystem) Mkdir(header *InHeader, input *MkdirIn, name string) (out *EntryOut, code Status) {
defer me.startTimer("Mkdir")() defer me.startTimer("Mkdir")()
return me.Original.Mkdir(header, input, name) return me.RawFileSystem.Mkdir(header, input, name)
} }
func (me *TimingRawFileSystem) Unlink(header *InHeader, name string) (code Status) { func (me *TimingRawFileSystem) Unlink(header *InHeader, name string) (code Status) {
defer me.startTimer("Unlink")() defer me.startTimer("Unlink")()
return me.Original.Unlink(header, name) return me.RawFileSystem.Unlink(header, name)
} }
func (me *TimingRawFileSystem) Rmdir(header *InHeader, name string) (code Status) { func (me *TimingRawFileSystem) Rmdir(header *InHeader, name string) (code Status) {
defer me.startTimer("Rmdir")() defer me.startTimer("Rmdir")()
return me.Original.Rmdir(header, name) return me.RawFileSystem.Rmdir(header, name)
} }
func (me *TimingRawFileSystem) Symlink(header *InHeader, pointedTo string, linkName string) (out *EntryOut, code Status) { func (me *TimingRawFileSystem) Symlink(header *InHeader, pointedTo string, linkName string) (out *EntryOut, code Status) {
defer me.startTimer("Symlink")() defer me.startTimer("Symlink")()
return me.Original.Symlink(header, pointedTo, linkName) return me.RawFileSystem.Symlink(header, pointedTo, linkName)
} }
func (me *TimingRawFileSystem) Rename(header *InHeader, input *RenameIn, oldName string, newName string) (code Status) { func (me *TimingRawFileSystem) Rename(header *InHeader, input *RenameIn, oldName string, newName string) (code Status) {
defer me.startTimer("Rename")() defer me.startTimer("Rename")()
return me.Original.Rename(header, input, oldName, newName) return me.RawFileSystem.Rename(header, input, oldName, newName)
} }
func (me *TimingRawFileSystem) Link(header *InHeader, input *LinkIn, name string) (out *EntryOut, code Status) { func (me *TimingRawFileSystem) Link(header *InHeader, input *LinkIn, name string) (out *EntryOut, code Status) {
defer me.startTimer("Link")() defer me.startTimer("Link")()
return me.Original.Link(header, input, name) return me.RawFileSystem.Link(header, input, name)
} }
func (me *TimingRawFileSystem) SetXAttr(header *InHeader, input *SetXAttrIn, attr string, data []byte) Status { func (me *TimingRawFileSystem) SetXAttr(header *InHeader, input *SetXAttrIn, attr string, data []byte) Status {
defer me.startTimer("SetXAttr")() defer me.startTimer("SetXAttr")()
return me.Original.SetXAttr(header, input, attr, data) return me.RawFileSystem.SetXAttr(header, input, attr, data)
} }
func (me *TimingRawFileSystem) GetXAttr(header *InHeader, attr string) (data []byte, code Status) { func (me *TimingRawFileSystem) GetXAttr(header *InHeader, attr string) (data []byte, code Status) {
defer me.startTimer("GetXAttr")() defer me.startTimer("GetXAttr")()
return me.Original.GetXAttr(header, attr) return me.RawFileSystem.GetXAttr(header, attr)
} }
func (me *TimingRawFileSystem) ListXAttr(header *InHeader) (data []byte, code Status) { func (me *TimingRawFileSystem) ListXAttr(header *InHeader) (data []byte, code Status) {
defer me.startTimer("ListXAttr")() defer me.startTimer("ListXAttr")()
return me.Original.ListXAttr(header) return me.RawFileSystem.ListXAttr(header)
} }
func (me *TimingRawFileSystem) RemoveXAttr(header *InHeader, attr string) Status { func (me *TimingRawFileSystem) RemoveXAttr(header *InHeader, attr string) Status {
defer me.startTimer("RemoveXAttr")() defer me.startTimer("RemoveXAttr")()
return me.Original.RemoveXAttr(header, attr) return me.RawFileSystem.RemoveXAttr(header, attr)
} }
func (me *TimingRawFileSystem) Access(header *InHeader, input *AccessIn) (code Status) { func (me *TimingRawFileSystem) Access(header *InHeader, input *AccessIn) (code Status) {
defer me.startTimer("Access")() defer me.startTimer("Access")()
return me.Original.Access(header, input) return me.RawFileSystem.Access(header, input)
} }
func (me *TimingRawFileSystem) Create(header *InHeader, input *CreateIn, name string) (flags uint32, handle uint64, out *EntryOut, code Status) { func (me *TimingRawFileSystem) Create(header *InHeader, input *CreateIn, name string) (flags uint32, handle uint64, out *EntryOut, code Status) {
defer me.startTimer("Create")() defer me.startTimer("Create")()
return me.Original.Create(header, input, name) return me.RawFileSystem.Create(header, input, name)
} }
func (me *TimingRawFileSystem) OpenDir(header *InHeader, input *OpenIn) (flags uint32, handle uint64, status Status) { func (me *TimingRawFileSystem) OpenDir(header *InHeader, input *OpenIn) (flags uint32, handle uint64, status Status) {
defer me.startTimer("OpenDir")() defer me.startTimer("OpenDir")()
return me.Original.OpenDir(header, input) return me.RawFileSystem.OpenDir(header, input)
} }
func (me *TimingRawFileSystem) Release(header *InHeader, input *ReleaseIn) { func (me *TimingRawFileSystem) Release(header *InHeader, input *ReleaseIn) {
defer me.startTimer("Release")() defer me.startTimer("Release")()
me.Original.Release(header, input) me.RawFileSystem.Release(header, input)
} }
func (me *TimingRawFileSystem) Read(input *ReadIn, bp *BufferPool) ([]byte, Status) { func (me *TimingRawFileSystem) Read(input *ReadIn, bp *BufferPool) ([]byte, Status) {
defer me.startTimer("Read")() defer me.startTimer("Read")()
return me.Original.Read(input, bp) return me.RawFileSystem.Read(input, bp)
} }
func (me *TimingRawFileSystem) Write(input *WriteIn, data []byte) (written uint32, code Status) { func (me *TimingRawFileSystem) Write(input *WriteIn, data []byte) (written uint32, code Status) {
defer me.startTimer("Write")() defer me.startTimer("Write")()
return me.Original.Write(input, data) return me.RawFileSystem.Write(input, data)
} }
func (me *TimingRawFileSystem) Flush(input *FlushIn) Status { func (me *TimingRawFileSystem) Flush(input *FlushIn) Status {
defer me.startTimer("Flush")() defer me.startTimer("Flush")()
return me.Original.Flush(input) return me.RawFileSystem.Flush(input)
} }
func (me *TimingRawFileSystem) Fsync(input *FsyncIn) (code Status) { func (me *TimingRawFileSystem) Fsync(input *FsyncIn) (code Status) {
defer me.startTimer("Fsync")() defer me.startTimer("Fsync")()
return me.Original.Fsync(input) return me.RawFileSystem.Fsync(input)
} }
func (me *TimingRawFileSystem) ReadDir(header *InHeader, input *ReadIn) (*DirEntryList, Status) { func (me *TimingRawFileSystem) ReadDir(header *InHeader, input *ReadIn) (*DirEntryList, Status) {
defer me.startTimer("ReadDir")() defer me.startTimer("ReadDir")()
return me.Original.ReadDir(header, input) return me.RawFileSystem.ReadDir(header, input)
} }
func (me *TimingRawFileSystem) ReleaseDir(header *InHeader, input *ReleaseIn) { func (me *TimingRawFileSystem) ReleaseDir(header *InHeader, input *ReleaseIn) {
defer me.startTimer("ReleaseDir")() defer me.startTimer("ReleaseDir")()
me.Original.ReleaseDir(header, input) me.RawFileSystem.ReleaseDir(header, input)
} }
func (me *TimingRawFileSystem) FsyncDir(header *InHeader, input *FsyncIn) (code Status) { func (me *TimingRawFileSystem) FsyncDir(header *InHeader, input *FsyncIn) (code Status) {
defer me.startTimer("FsyncDir")() defer me.startTimer("FsyncDir")()
return me.Original.FsyncDir(header, input) return me.RawFileSystem.FsyncDir(header, input)
} }
package fuse
type WrappingFileSystem struct {
// Should be public so people reusing can access the wrapped
// FS.
Original FileSystem
}
func (me *WrappingFileSystem) GetAttr(name string) (*Attr, Status) {
return me.Original.GetAttr(name)
}
func (me *WrappingFileSystem) Readlink(name string) (string, Status) {
return me.Original.Readlink(name)
}
func (me *WrappingFileSystem) Mknod(name string, mode uint32, dev uint32) Status {
return me.Original.Mknod(name, mode, dev)
}
func (me *WrappingFileSystem) Mkdir(name string, mode uint32) Status {
return me.Original.Mkdir(name, mode)
}
func (me *WrappingFileSystem) Unlink(name string) (code Status) {
return me.Original.Unlink(name)
}
func (me *WrappingFileSystem) Rmdir(name string) (code Status) {
return me.Original.Rmdir(name)
}
func (me *WrappingFileSystem) Symlink(value string, linkName string) (code Status) {
return me.Original.Symlink(value, linkName)
}
func (me *WrappingFileSystem) Rename(oldName string, newName string) (code Status) {
return me.Original.Rename(oldName, newName)
}
func (me *WrappingFileSystem) Link(oldName string, newName string) (code Status) {
return me.Original.Link(oldName, newName)
}
func (me *WrappingFileSystem) Chmod(name string, mode uint32) (code Status) {
return me.Original.Chmod(name, mode)
}
func (me *WrappingFileSystem) Chown(name string, uid uint32, gid uint32) (code Status) {
return me.Original.Chown(name, uid, gid)
}
func (me *WrappingFileSystem) Truncate(name string, offset uint64) (code Status) {
return me.Original.Truncate(name, offset)
}
func (me *WrappingFileSystem) Open(name string, flags uint32) (file File, code Status) {
return me.Original.Open(name, flags)
}
func (me *WrappingFileSystem) OpenDir(name string) (stream chan DirEntry, status Status) {
return me.Original.OpenDir(name)
}
func (me *WrappingFileSystem) Mount(conn *FileSystemConnector) Status {
return me.Original.Mount(conn)
}
func (me *WrappingFileSystem) Unmount() {
me.Original.Unmount()
}
func (me *WrappingFileSystem) Access(name string, mode uint32) (code Status) {
return me.Original.Access(name, mode)
}
func (me *WrappingFileSystem) Create(name string, flags uint32, mode uint32) (file File, code Status) {
return me.Original.Create(name, flags, mode)
}
func (me *WrappingFileSystem) Utimens(name string, AtimeNs uint64, CtimeNs uint64) (code Status) {
return me.Original.Utimens(name, AtimeNs, CtimeNs)
}
func (me *WrappingFileSystem) GetXAttr(name string, attr string) ([]byte, Status) {
return me.Original.GetXAttr(name, attr)
}
func (me *WrappingFileSystem) SetXAttr(name string, attr string, data []byte, flags int) Status {
return me.Original.SetXAttr(name, attr, data, flags)
}
func (me *WrappingFileSystem) ListXAttr(name string) ([]string, Status) {
return me.Original.ListXAttr(name)
}
func (me *WrappingFileSystem) RemoveXAttr(name string, attr string) Status {
return me.Original.RemoveXAttr(name, attr)
}
////////////////////////////////////////////////////////////////
// Wrapping raw FS.
type WrappingRawFileSystem struct {
Original RawFileSystem
}
func (me *WrappingRawFileSystem) Destroy(h *InHeader, input *InitIn) {
me.Original.Destroy(h, input)
}
func (me *WrappingRawFileSystem) Lookup(h *InHeader, name string) (out *EntryOut, code Status) {
return me.Original.Lookup(h, name)
}
func (me *WrappingRawFileSystem) Forget(h *InHeader, input *ForgetIn) {
me.Original.Forget(h, input)
}
func (me *WrappingRawFileSystem) GetAttr(header *InHeader, input *GetAttrIn) (out *AttrOut, code Status) {
return me.Original.GetAttr(header, input)
}
func (me *WrappingRawFileSystem) Open(header *InHeader, input *OpenIn) (flags uint32, handle uint64, status Status) {
return me.Original.Open(header, input)
}
func (me *WrappingRawFileSystem) SetAttr(header *InHeader, input *SetAttrIn) (out *AttrOut, code Status) {
return me.Original.SetAttr(header, input)
}
func (me *WrappingRawFileSystem) Readlink(header *InHeader) (out []byte, code Status) {
return me.Original.Readlink(header)
}
func (me *WrappingRawFileSystem) Mknod(header *InHeader, input *MknodIn, name string) (out *EntryOut, code Status) {
return me.Original.Mknod(header, input, name)
}
func (me *WrappingRawFileSystem) Mkdir(header *InHeader, input *MkdirIn, name string) (out *EntryOut, code Status) {
return me.Original.Mkdir(header, input, name)
}
func (me *WrappingRawFileSystem) Unlink(header *InHeader, name string) (code Status) {
return me.Original.Unlink(header, name)
}
func (me *WrappingRawFileSystem) Rmdir(header *InHeader, name string) (code Status) {
return me.Original.Rmdir(header, name)
}
func (me *WrappingRawFileSystem) Symlink(header *InHeader, pointedTo string, linkName string) (out *EntryOut, code Status) {
return me.Original.Symlink(header, pointedTo, linkName)
}
func (me *WrappingRawFileSystem) Rename(header *InHeader, input *RenameIn, oldName string, newName string) (code Status) {
return me.Original.Rename(header, input, oldName, newName)
}
func (me *WrappingRawFileSystem) Link(header *InHeader, input *LinkIn, name string) (out *EntryOut, code Status) {
return me.Original.Link(header, input, name)
}
func (me *WrappingRawFileSystem) SetXAttr(header *InHeader, input *SetXAttrIn, attr string, data []byte) Status {
return me.Original.SetXAttr(header, input, attr, data)
}
func (me *WrappingRawFileSystem) GetXAttr(header *InHeader, attr string) (data []byte, code Status) {
return me.Original.GetXAttr(header, attr)
}
func (me *WrappingRawFileSystem) ListXAttr(header *InHeader) (data []byte, code Status) {
return me.Original.ListXAttr(header)
}
func (me *WrappingRawFileSystem) RemoveXAttr(header *InHeader, attr string) Status {
return me.Original.RemoveXAttr(header, attr)
}
func (me *WrappingRawFileSystem) Access(header *InHeader, input *AccessIn) (code Status) {
return me.Original.Access(header, input)
}
func (me *WrappingRawFileSystem) Create(header *InHeader, input *CreateIn, name string) (flags uint32, handle uint64, out *EntryOut, code Status) {
return me.Original.Create(header, input, name)
}
func (me *WrappingRawFileSystem) OpenDir(header *InHeader, input *OpenIn) (flags uint32, handle uint64, status Status) {
return me.Original.OpenDir(header, input)
}
func (me *WrappingRawFileSystem) Release(header *InHeader, input *ReleaseIn) {
me.Original.Release(header, input)
}
func (me *WrappingRawFileSystem) Read(input *ReadIn, bp *BufferPool) ([]byte, Status) {
return me.Original.Read(input, bp)
}
func (me *WrappingRawFileSystem) Write(input *WriteIn, data []byte) (written uint32, code Status) {
return me.Original.Write(input, data)
}
func (me *WrappingRawFileSystem) Flush(input *FlushIn) Status {
return me.Original.Flush(input)
}
func (me *WrappingRawFileSystem) Fsync(input *FsyncIn) (code Status) {
return me.Original.Fsync(input)
}
func (me *WrappingRawFileSystem) ReadDir(header *InHeader, input *ReadIn) (*DirEntryList, Status) {
return me.Original.ReadDir(header, input)
}
func (me *WrappingRawFileSystem) ReleaseDir(header *InHeader, input *ReleaseIn) {
me.Original.ReleaseDir(header, input)
}
func (me *WrappingRawFileSystem) FsyncDir(header *InHeader, input *FsyncIn) (code Status) {
return me.Original.FsyncDir(header, input)
}
...@@ -22,7 +22,7 @@ type linkResponse struct { ...@@ -22,7 +22,7 @@ type linkResponse struct {
// Caches readdir and getattr() // Caches readdir and getattr()
type CachingFileSystem struct { type CachingFileSystem struct {
fuse.WrappingFileSystem fuse.FileSystem
attributesLock sync.RWMutex attributesLock sync.RWMutex
attributes map[string]attrResponse attributes map[string]attrResponse
...@@ -36,7 +36,7 @@ type CachingFileSystem struct { ...@@ -36,7 +36,7 @@ type CachingFileSystem struct {
func NewCachingFileSystem(pfs fuse.FileSystem) *CachingFileSystem { func NewCachingFileSystem(pfs fuse.FileSystem) *CachingFileSystem {
c := new(CachingFileSystem) c := new(CachingFileSystem)
c.Original = pfs c.FileSystem = pfs
c.attributes = make(map[string]attrResponse) c.attributes = make(map[string]attrResponse)
c.dirs = make(map[string]dirResponse) c.dirs = make(map[string]dirResponse)
c.links = make(map[string]linkResponse) c.links = make(map[string]linkResponse)
...@@ -53,7 +53,7 @@ func (me *CachingFileSystem) GetAttr(name string) (*fuse.Attr, fuse.Status) { ...@@ -53,7 +53,7 @@ func (me *CachingFileSystem) GetAttr(name string) (*fuse.Attr, fuse.Status) {
} }
var r attrResponse var r attrResponse
r.attr, r.code = me.Original.GetAttr(name) r.attr, r.code = me.FileSystem.GetAttr(name)
// TODO - could do async. // TODO - could do async.
me.attributesLock.Lock() me.attributesLock.Lock()
...@@ -72,7 +72,7 @@ func (me *CachingFileSystem) Readlink(name string) (string, fuse.Status) { ...@@ -72,7 +72,7 @@ func (me *CachingFileSystem) Readlink(name string) (string, fuse.Status) {
return v.linkContent, v.code return v.linkContent, v.code
} }
v.linkContent, v.code = me.Original.Readlink(name) v.linkContent, v.code = me.FileSystem.Readlink(name)
// TODO - could do async. // TODO - could do async.
me.linksLock.Lock() me.linksLock.Lock()
...@@ -88,7 +88,7 @@ func (me *CachingFileSystem) OpenDir(name string) (stream chan fuse.DirEntry, st ...@@ -88,7 +88,7 @@ func (me *CachingFileSystem) OpenDir(name string) (stream chan fuse.DirEntry, st
me.dirsLock.RUnlock() me.dirsLock.RUnlock()
if !ok { if !ok {
origStream, code := me.Original.OpenDir(name) origStream, code := me.FileSystem.OpenDir(name)
if code != fuse.OK { if code != fuse.OK {
return nil, code return nil, code
} }
......
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