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