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

Uniformize writing of FileSystem (was: Filesystem as well).

parent 8caf9e25
...@@ -159,95 +159,95 @@ func (me *DefaultFuseFile) Fsync(*FsyncIn) (code Status) { ...@@ -159,95 +159,95 @@ func (me *DefaultFuseFile) Fsync(*FsyncIn) (code Status) {
} }
//////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////
// DefaultPathFilesystem // DefaultPathFileSystem
func (me *DefaultPathFilesystem) GetAttr(name string) (*Attr, Status) { func (me *DefaultPathFileSystem) GetAttr(name string) (*Attr, Status) {
return nil, ENOSYS return nil, ENOSYS
} }
func (me *DefaultPathFilesystem) GetXAttr(name string, attr string) ([]byte, Status) { func (me *DefaultPathFileSystem) GetXAttr(name string, attr string) ([]byte, Status) {
return nil, ENOSYS return nil, ENOSYS
} }
func (me *DefaultPathFilesystem) SetXAttr(name string, attr string, data []byte, flags int) Status { func (me *DefaultPathFileSystem) SetXAttr(name string, attr string, data []byte, flags int) Status {
return ENOSYS return ENOSYS
} }
func (me *DefaultPathFilesystem) ListXAttr(name string) ([]string, Status) { func (me *DefaultPathFileSystem) ListXAttr(name string) ([]string, Status) {
return nil, ENOSYS return nil, ENOSYS
} }
func (me *DefaultPathFilesystem) RemoveXAttr(name string, attr string) Status { func (me *DefaultPathFileSystem) RemoveXAttr(name string, attr string) Status {
return ENOSYS return ENOSYS
} }
func (me *DefaultPathFilesystem) Readlink(name string) (string, Status) { func (me *DefaultPathFileSystem) Readlink(name string) (string, Status) {
return "", ENOSYS return "", ENOSYS
} }
func (me *DefaultPathFilesystem) Mknod(name string, mode uint32, dev uint32) Status { func (me *DefaultPathFileSystem) Mknod(name string, mode uint32, dev uint32) Status {
return ENOSYS return ENOSYS
} }
func (me *DefaultPathFilesystem) Mkdir(name string, mode uint32) Status { func (me *DefaultPathFileSystem) Mkdir(name string, mode uint32) Status {
return ENOSYS return ENOSYS
} }
func (me *DefaultPathFilesystem) Unlink(name string) (code Status) { func (me *DefaultPathFileSystem) Unlink(name string) (code Status) {
return ENOSYS return ENOSYS
} }
func (me *DefaultPathFilesystem) Rmdir(name string) (code Status) { func (me *DefaultPathFileSystem) Rmdir(name string) (code Status) {
return ENOSYS return ENOSYS
} }
func (me *DefaultPathFilesystem) Symlink(value string, linkName string) (code Status) { func (me *DefaultPathFileSystem) Symlink(value string, linkName string) (code Status) {
return ENOSYS return ENOSYS
} }
func (me *DefaultPathFilesystem) Rename(oldName string, newName string) (code Status) { func (me *DefaultPathFileSystem) Rename(oldName string, newName string) (code Status) {
return ENOSYS return ENOSYS
} }
func (me *DefaultPathFilesystem) Link(oldName string, newName string) (code Status) { func (me *DefaultPathFileSystem) Link(oldName string, newName string) (code Status) {
return ENOSYS return ENOSYS
} }
func (me *DefaultPathFilesystem) Chmod(name string, mode uint32) (code Status) { func (me *DefaultPathFileSystem) Chmod(name string, mode uint32) (code Status) {
return ENOSYS return ENOSYS
} }
func (me *DefaultPathFilesystem) Chown(name string, uid uint32, gid uint32) (code Status) { func (me *DefaultPathFileSystem) Chown(name string, uid uint32, gid uint32) (code Status) {
return ENOSYS return ENOSYS
} }
func (me *DefaultPathFilesystem) Truncate(name string, offset uint64) (code Status) { func (me *DefaultPathFileSystem) Truncate(name string, offset uint64) (code Status) {
return ENOSYS return ENOSYS
} }
func (me *DefaultPathFilesystem) Open(name string, flags uint32) (file FuseFile, code Status) { func (me *DefaultPathFileSystem) Open(name string, flags uint32) (file FuseFile, code Status) {
return nil, ENOSYS return nil, ENOSYS
} }
func (me *DefaultPathFilesystem) OpenDir(name string) (stream chan DirEntry, status Status) { func (me *DefaultPathFileSystem) OpenDir(name string) (stream chan DirEntry, status Status) {
return nil, ENOSYS return nil, ENOSYS
} }
func (me *DefaultPathFilesystem) Mount(conn *PathFileSystemConnector) Status { func (me *DefaultPathFileSystem) Mount(conn *PathFileSystemConnector) Status {
return OK return OK
} }
func (me *DefaultPathFilesystem) Unmount() { func (me *DefaultPathFileSystem) Unmount() {
} }
func (me *DefaultPathFilesystem) Access(name string, mode uint32) (code Status) { func (me *DefaultPathFileSystem) Access(name string, mode uint32) (code Status) {
return ENOSYS return ENOSYS
} }
func (me *DefaultPathFilesystem) Create(name string, flags uint32, mode uint32) (file FuseFile, code Status) { func (me *DefaultPathFileSystem) Create(name string, flags uint32, mode uint32) (file FuseFile, code Status) {
return nil, ENOSYS return nil, ENOSYS
} }
func (me *DefaultPathFilesystem) Utimens(name string, AtimeNs uint64, CtimeNs uint64) (code Status) { func (me *DefaultPathFileSystem) Utimens(name string, AtimeNs uint64, CtimeNs uint64) (code Status) {
return ENOSYS return ENOSYS
} }
package fuse package fuse
// Make sure library supplied Filesystems support the // Make sure library supplied FileSystems support the
// required interface. // required interface.
import ( import (
...@@ -11,17 +11,17 @@ func TestRawFs(t *testing.T) { ...@@ -11,17 +11,17 @@ func TestRawFs(t *testing.T) {
var iface RawFileSystem var iface RawFileSystem
iface = new(DefaultRawFuseFileSystem) iface = new(DefaultRawFuseFileSystem)
iface = new(WrappingRawFilesystem) iface = new(WrappingRawFileSystem)
iface = new(TimingRawFilesystem) iface = new(TimingRawFileSystem)
_ = iface _ = iface
} }
func TestPathFs(t *testing.T) { func TestPathFs(t *testing.T) {
var iface PathFilesystem var iface PathFileSystem
iface = new(DefaultPathFilesystem) iface = new(DefaultPathFileSystem)
iface = new(WrappingPathFilesystem) iface = new(WrappingPathFileSystem)
iface = new(TimingPathFilesystem) iface = new(TimingPathFileSystem)
_ = iface _ = iface
} }
......
...@@ -4,153 +4,153 @@ import ( ...@@ -4,153 +4,153 @@ import (
"sync" "sync"
) )
// This is a wrapper that makes a PathFilesystem threadsafe by // This is a wrapper that makes a PathFileSystem threadsafe by
// trivially locking all operations. For improved performance, you // trivially locking all operations. For improved performance, you
// should probably invent do your own locking inside the file system. // should probably invent do your own locking inside the file system.
type LockingPathFilesystem struct { type LockingPathFileSystem struct {
// Should be public so people reusing can access the wrapped // Should be public so people reusing can access the wrapped
// FS. // FS.
WrappingPathFilesystem WrappingPathFileSystem
lock sync.Mutex lock sync.Mutex
} }
func NewLockingPathFilesystem(pfs PathFilesystem) *LockingPathFilesystem { func NewLockingPathFileSystem(pfs PathFileSystem) *LockingPathFileSystem {
l := new(LockingPathFilesystem) l := new(LockingPathFileSystem)
l.Original = pfs l.Original = pfs
return l return l
} }
func (me *LockingPathFilesystem) GetAttr(name string) (*Attr, Status) { func (me *LockingPathFileSystem) 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.Original.GetAttr(name)
} }
func (me *LockingPathFilesystem) Readlink(name string) (string, Status) { func (me *LockingPathFileSystem) 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.Original.Readlink(name)
} }
func (me *LockingPathFilesystem) Mknod(name string, mode uint32, dev uint32) Status { func (me *LockingPathFileSystem) 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.Original.Mknod(name, mode, dev)
} }
func (me *LockingPathFilesystem) Mkdir(name string, mode uint32) Status { func (me *LockingPathFileSystem) 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.Original.Mkdir(name, mode)
} }
func (me *LockingPathFilesystem) Unlink(name string) (code Status) { func (me *LockingPathFileSystem) 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.Original.Unlink(name)
} }
func (me *LockingPathFilesystem) Rmdir(name string) (code Status) { func (me *LockingPathFileSystem) 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.Original.Rmdir(name)
} }
func (me *LockingPathFilesystem) Symlink(value string, linkName string) (code Status) { func (me *LockingPathFileSystem) 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.Original.Symlink(value, linkName)
} }
func (me *LockingPathFilesystem) Rename(oldName string, newName string) (code Status) { func (me *LockingPathFileSystem) 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.Original.Rename(oldName, newName)
} }
func (me *LockingPathFilesystem) Link(oldName string, newName string) (code Status) { func (me *LockingPathFileSystem) 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.Original.Link(oldName, newName)
} }
func (me *LockingPathFilesystem) Chmod(name string, mode uint32) (code Status) { func (me *LockingPathFileSystem) 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.Original.Chmod(name, mode)
} }
func (me *LockingPathFilesystem) Chown(name string, uid uint32, gid uint32) (code Status) { func (me *LockingPathFileSystem) 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.Original.Chown(name, uid, gid)
} }
func (me *LockingPathFilesystem) Truncate(name string, offset uint64) (code Status) { func (me *LockingPathFileSystem) 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.Original.Truncate(name, offset)
} }
func (me *LockingPathFilesystem) Open(name string, flags uint32) (file FuseFile, code Status) { func (me *LockingPathFileSystem) Open(name string, flags uint32) (file FuseFile, code Status) {
return me.Original.Open(name, flags) return me.Original.Open(name, flags)
} }
func (me *LockingPathFilesystem) OpenDir(name string) (stream chan DirEntry, status Status) { func (me *LockingPathFileSystem) 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.Original.OpenDir(name)
} }
func (me *LockingPathFilesystem) Mount(conn *PathFileSystemConnector) Status { func (me *LockingPathFileSystem) Mount(conn *PathFileSystemConnector) Status {
me.lock.Lock() me.lock.Lock()
defer me.lock.Unlock() defer me.lock.Unlock()
return me.Original.Mount(conn) return me.Original.Mount(conn)
} }
func (me *LockingPathFilesystem) Unmount() { func (me *LockingPathFileSystem) Unmount() {
me.lock.Lock() me.lock.Lock()
defer me.lock.Unlock() defer me.lock.Unlock()
me.Original.Unmount() me.Original.Unmount()
} }
func (me *LockingPathFilesystem) Access(name string, mode uint32) (code Status) { func (me *LockingPathFileSystem) 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.Original.Access(name, mode)
} }
func (me *LockingPathFilesystem) Create(name string, flags uint32, mode uint32) (file FuseFile, code Status) { func (me *LockingPathFileSystem) Create(name string, flags uint32, mode uint32) (file FuseFile, 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.Original.Create(name, flags, mode)
} }
func (me *LockingPathFilesystem) Utimens(name string, AtimeNs uint64, CtimeNs uint64) (code Status) { func (me *LockingPathFileSystem) 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.Original.Utimens(name, AtimeNs, CtimeNs)
} }
func (me *LockingPathFilesystem) GetXAttr(name string, attr string) ([]byte, Status) { func (me *LockingPathFileSystem) 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.Original.GetXAttr(name, attr)
} }
func (me *LockingPathFilesystem) SetXAttr(name string, attr string, data []byte, flags int) Status { func (me *LockingPathFileSystem) 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.Original.SetXAttr(name, attr, data, flags)
} }
func (me *LockingPathFilesystem) ListXAttr(name string) ([]string, Status) { func (me *LockingPathFileSystem) 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.Original.ListXAttr(name)
} }
func (me *LockingPathFilesystem) RemoveXAttr(name string, attr string) Status { func (me *LockingPathFileSystem) 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.Original.RemoveXAttr(name, attr)
...@@ -159,210 +159,210 @@ func (me *LockingPathFilesystem) RemoveXAttr(name string, attr string) Status { ...@@ -159,210 +159,210 @@ func (me *LockingPathFilesystem) RemoveXAttr(name string, attr string) Status {
//////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////
// Locking raw FS. // Locking raw FS.
type LockingRawFilesystem struct { type LockingRawFileSystem struct {
WrappingRawFilesystem WrappingRawFileSystem
lock sync.Mutex lock sync.Mutex
} }
func NewLockingRawFilesystem(rfs RawFileSystem) *LockingRawFilesystem { func NewLockingRawFileSystem(rfs RawFileSystem) *LockingRawFileSystem {
l := &LockingRawFilesystem{} l := &LockingRawFileSystem{}
l.Original = rfs l.Original = rfs
return l return l
} }
func (me *LockingRawFilesystem) Init(h *InHeader, input *InitIn) (*InitOut, Status) { func (me *LockingRawFileSystem) Init(h *InHeader, input *InitIn) (*InitOut, Status) {
me.lock.Lock() me.lock.Lock()
defer me.lock.Unlock() defer me.lock.Unlock()
return me.Original.Init(h, input) return me.Original.Init(h, input)
} }
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.Original.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.Original.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.Original.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.Original.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.Original.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.Original.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.Original.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.Original.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.Original.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.Original.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.Original.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.Original.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.Original.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.Original.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.Original.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.Original.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.Original.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.Original.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.Original.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.Original.Create(header, input, name)
} }
func (me *LockingRawFilesystem) Bmap(header *InHeader, input *BmapIn) (out *BmapOut, code Status) { func (me *LockingRawFileSystem) Bmap(header *InHeader, input *BmapIn) (out *BmapOut, code Status) {
me.lock.Lock() me.lock.Lock()
defer me.lock.Unlock() defer me.lock.Unlock()
return me.Original.Bmap(header, input) return me.Original.Bmap(header, input)
} }
func (me *LockingRawFilesystem) Ioctl(header *InHeader, input *IoctlIn) (out *IoctlOut, code Status) { func (me *LockingRawFileSystem) Ioctl(header *InHeader, input *IoctlIn) (out *IoctlOut, code Status) {
me.lock.Lock() me.lock.Lock()
defer me.lock.Unlock() defer me.lock.Unlock()
return me.Original.Ioctl(header, input) return me.Original.Ioctl(header, input)
} }
func (me *LockingRawFilesystem) Poll(header *InHeader, input *PollIn) (out *PollOut, code Status) { func (me *LockingRawFileSystem) Poll(header *InHeader, input *PollIn) (out *PollOut, code Status) {
me.lock.Lock() me.lock.Lock()
defer me.lock.Unlock() defer me.lock.Unlock()
return me.Original.Poll(header, input) return me.Original.Poll(header, input)
} }
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.Original.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.Original.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.Original.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.Original.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.Original.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.Original.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.Original.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.Original.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.Original.FsyncDir(header, input)
......
...@@ -18,7 +18,7 @@ var _ = log.Println ...@@ -18,7 +18,7 @@ var _ = log.Println
type LoopbackFileSystem struct { type LoopbackFileSystem struct {
root string root string
DefaultPathFilesystem DefaultPathFileSystem
} }
func NewLoopbackFileSystem(root string) (out *LoopbackFileSystem) { func NewLoopbackFileSystem(root string) (out *LoopbackFileSystem) {
......
...@@ -54,16 +54,16 @@ func (me *testCase) Setup(t *testing.T) { ...@@ -54,16 +54,16 @@ func (me *testCase) Setup(t *testing.T) {
me.origSubdir = filepath.Join(me.origDir, subdir) me.origSubdir = filepath.Join(me.origDir, subdir)
me.origSubfile = filepath.Join(me.origSubdir, "subfile") me.origSubfile = filepath.Join(me.origSubdir, "subfile")
var pfs PathFilesystem var pfs PathFileSystem
pfs = NewLoopbackFileSystem(me.origDir) pfs = NewLoopbackFileSystem(me.origDir)
pfs = NewTimingPathFilesystem(pfs) pfs = NewTimingPathFileSystem(pfs)
pfs = NewLockingPathFilesystem(pfs) pfs = NewLockingPathFileSystem(pfs)
var rfs RawFileSystem var rfs RawFileSystem
me.connector = NewPathFileSystemConnector(pfs) me.connector = NewPathFileSystemConnector(pfs)
rfs = me.connector rfs = me.connector
rfs = NewTimingRawFilesystem(rfs) rfs = NewTimingRawFileSystem(rfs)
rfs = NewLockingRawFilesystem(rfs) rfs = NewLockingRawFileSystem(rfs)
me.connector.Debug = true me.connector.Debug = true
me.state = NewMountState(rfs) me.state = NewMountState(rfs)
......
...@@ -5,21 +5,21 @@ import ( ...@@ -5,21 +5,21 @@ import (
var _ = fmt.Println var _ = fmt.Println
type PathFilesystemDebug struct { type PathFileSystemDebug struct {
// TODO - use a generic callback system instead. // TODO - use a generic callback system instead.
Connector *PathFileSystemConnector Connector *PathFileSystemConnector
WrappingPathFilesystem WrappingPathFileSystem
} }
func (me *PathFilesystemDebug) Open(path string, flags uint32) (fuseFile FuseFile, status Status) { func (me *PathFileSystemDebug) Open(path string, flags uint32) (fuseFile FuseFile, status Status) {
if path == ".debug" && me.Connector != nil { if path == ".debug" && me.Connector != nil {
return NewReadOnlyFile([]byte(me.Connector.DebugString())), OK return NewReadOnlyFile([]byte(me.Connector.DebugString())), OK
} }
return me.Original.Open(path, flags) return me.Original.Open(path, flags)
} }
func (me *PathFilesystemDebug) GetAttr(path string) (*Attr, Status) { func (me *PathFileSystemDebug) GetAttr(path string) (*Attr, Status) {
if path == ".debug" && me.Connector != nil { if path == ".debug" && me.Connector != nil {
return &Attr{ return &Attr{
Mode: S_IFREG, Mode: S_IFREG,
......
...@@ -11,7 +11,7 @@ import ( ...@@ -11,7 +11,7 @@ import (
type mountData struct { type mountData struct {
// If non-nil the file system mounted here. // If non-nil the file system mounted here.
fs PathFilesystem fs PathFileSystem
// Protects the variables below. // Protects the variables below.
mutex sync.RWMutex mutex sync.RWMutex
...@@ -20,7 +20,7 @@ type mountData struct { ...@@ -20,7 +20,7 @@ type mountData struct {
unmountPending bool unmountPending bool
} }
func newMount(fs PathFilesystem) *mountData { func newMount(fs PathFileSystem) *mountData {
return &mountData{fs: fs} return &mountData{fs: fs}
} }
...@@ -378,7 +378,7 @@ func EmptyPathFileSystemConnector() (out *PathFileSystemConnector) { ...@@ -378,7 +378,7 @@ func EmptyPathFileSystemConnector() (out *PathFileSystemConnector) {
return out; return out;
} }
func NewPathFileSystemConnector(fs PathFilesystem) (out *PathFileSystemConnector) { func NewPathFileSystemConnector(fs PathFileSystem) (out *PathFileSystemConnector) {
out = EmptyPathFileSystemConnector() out = EmptyPathFileSystemConnector()
if code := out.Mount("/", fs); code != OK { if code := out.Mount("/", fs); code != OK {
panic("root mount failed.") panic("root mount failed.")
...@@ -392,7 +392,7 @@ func (me *PathFileSystemConnector) SetOptions(opts PathFileSystemConnectorOption ...@@ -392,7 +392,7 @@ func (me *PathFileSystemConnector) SetOptions(opts PathFileSystemConnectorOption
me.options = opts me.options = opts
} }
func (me *PathFileSystemConnector) Mount(mountPoint string, fs PathFilesystem) Status { func (me *PathFileSystemConnector) Mount(mountPoint string, fs PathFileSystem) Status {
var node *inode var node *inode
if mountPoint != "/" { if mountPoint != "/" {
......
...@@ -11,9 +11,9 @@ import ( ...@@ -11,9 +11,9 @@ import (
var _ = log.Print var _ = log.Print
var _ = fmt.Print var _ = fmt.Print
// TimingPathFilesystem is a wrapper to collect timings for a PathFilesystem // TimingPathFileSystem is a wrapper to collect timings for a PathFileSystem
type TimingPathFilesystem struct { type TimingPathFileSystem struct {
WrappingPathFilesystem WrappingPathFileSystem
statisticsLock sync.Mutex statisticsLock sync.Mutex
latencies map[string]int64 latencies map[string]int64
...@@ -21,8 +21,8 @@ type TimingPathFilesystem struct { ...@@ -21,8 +21,8 @@ type TimingPathFilesystem struct {
pathCounts map[string]map[string]int64 pathCounts map[string]map[string]int64
} }
func NewTimingPathFilesystem(fs PathFilesystem) *TimingPathFilesystem { func NewTimingPathFileSystem(fs PathFileSystem) *TimingPathFileSystem {
t := new(TimingPathFilesystem) t := new(TimingPathFileSystem)
t.Original = fs t.Original = fs
t.latencies = make(map[string]int64) t.latencies = make(map[string]int64)
t.counts = make(map[string]int64) t.counts = make(map[string]int64)
...@@ -30,7 +30,7 @@ func NewTimingPathFilesystem(fs PathFilesystem) *TimingPathFilesystem { ...@@ -30,7 +30,7 @@ func NewTimingPathFilesystem(fs PathFilesystem) *TimingPathFilesystem {
return t return t
} }
func (me *TimingPathFilesystem) startTimer(name string, arg string) (closure func()) { func (me *TimingPathFileSystem) startTimer(name string, arg string) (closure func()) {
start := time.Nanoseconds() start := time.Nanoseconds()
return func() { return func() {
...@@ -50,7 +50,7 @@ func (me *TimingPathFilesystem) startTimer(name string, arg string) (closure fun ...@@ -50,7 +50,7 @@ func (me *TimingPathFilesystem) startTimer(name string, arg string) (closure fun
} }
} }
func (me *TimingPathFilesystem) OperationCounts() map[string]int64 { func (me *TimingPathFileSystem) OperationCounts() map[string]int64 {
me.statisticsLock.Lock() me.statisticsLock.Lock()
defer me.statisticsLock.Unlock() defer me.statisticsLock.Unlock()
...@@ -61,7 +61,7 @@ func (me *TimingPathFilesystem) OperationCounts() map[string]int64 { ...@@ -61,7 +61,7 @@ func (me *TimingPathFilesystem) OperationCounts() map[string]int64 {
return r return r
} }
func (me *TimingPathFilesystem) Latencies() map[string]float64 { func (me *TimingPathFileSystem) Latencies() map[string]float64 {
me.statisticsLock.Lock() me.statisticsLock.Lock()
defer me.statisticsLock.Unlock() defer me.statisticsLock.Unlock()
...@@ -72,7 +72,7 @@ func (me *TimingPathFilesystem) Latencies() map[string]float64 { ...@@ -72,7 +72,7 @@ func (me *TimingPathFilesystem) Latencies() map[string]float64 {
return r return r
} }
func (me *TimingPathFilesystem) HotPaths(operation string) (paths []string, uniquePaths int) { func (me *TimingPathFileSystem) HotPaths(operation string) (paths []string, uniquePaths int) {
me.statisticsLock.Lock() me.statisticsLock.Lock()
defer me.statisticsLock.Unlock() defer me.statisticsLock.Unlock()
...@@ -86,117 +86,117 @@ func (me *TimingPathFilesystem) HotPaths(operation string) (paths []string, uniq ...@@ -86,117 +86,117 @@ func (me *TimingPathFilesystem) HotPaths(operation string) (paths []string, uniq
return results, len(counts) return results, len(counts)
} }
func (me *TimingPathFilesystem) GetAttr(name string) (*Attr, Status) { func (me *TimingPathFileSystem) GetAttr(name string) (*Attr, Status) {
defer me.startTimer("GetAttr", name)() defer me.startTimer("GetAttr", name)()
return me.Original.GetAttr(name) return me.Original.GetAttr(name)
} }
func (me *TimingPathFilesystem) GetXAttr(name string, attr string) ([]byte, Status) { func (me *TimingPathFileSystem) 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.Original.GetXAttr(name, attr)
} }
func (me *TimingPathFilesystem) SetXAttr(name string, attr string, data []byte, flags int) Status { func (me *TimingPathFileSystem) 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.Original.SetXAttr(name, attr, data, flags)
} }
func (me *TimingPathFilesystem) ListXAttr(name string) ([]string, Status) { func (me *TimingPathFileSystem) ListXAttr(name string) ([]string, Status) {
defer me.startTimer("ListXAttr", name)() defer me.startTimer("ListXAttr", name)()
return me.Original.ListXAttr(name) return me.Original.ListXAttr(name)
} }
func (me *TimingPathFilesystem) RemoveXAttr(name string, attr string) Status { func (me *TimingPathFileSystem) RemoveXAttr(name string, attr string) Status {
defer me.startTimer("RemoveXAttr", name)() defer me.startTimer("RemoveXAttr", name)()
return me.Original.RemoveXAttr(name, attr) return me.Original.RemoveXAttr(name, attr)
} }
func (me *TimingPathFilesystem) Readlink(name string) (string, Status) { func (me *TimingPathFileSystem) Readlink(name string) (string, Status) {
defer me.startTimer("Readlink", name)() defer me.startTimer("Readlink", name)()
return me.Original.Readlink(name) return me.Original.Readlink(name)
} }
func (me *TimingPathFilesystem) Mknod(name string, mode uint32, dev uint32) Status { func (me *TimingPathFileSystem) 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.Original.Mknod(name, mode, dev)
} }
func (me *TimingPathFilesystem) Mkdir(name string, mode uint32) Status { func (me *TimingPathFileSystem) Mkdir(name string, mode uint32) Status {
defer me.startTimer("Mkdir", name)() defer me.startTimer("Mkdir", name)()
return me.Original.Mkdir(name, mode) return me.Original.Mkdir(name, mode)
} }
func (me *TimingPathFilesystem) Unlink(name string) (code Status) { func (me *TimingPathFileSystem) Unlink(name string) (code Status) {
defer me.startTimer("Unlink", name)() defer me.startTimer("Unlink", name)()
return me.Original.Unlink(name) return me.Original.Unlink(name)
} }
func (me *TimingPathFilesystem) Rmdir(name string) (code Status) { func (me *TimingPathFileSystem) Rmdir(name string) (code Status) {
defer me.startTimer("Rmdir", name)() defer me.startTimer("Rmdir", name)()
return me.Original.Rmdir(name) return me.Original.Rmdir(name)
} }
func (me *TimingPathFilesystem) Symlink(value string, linkName string) (code Status) { func (me *TimingPathFileSystem) 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.Original.Symlink(value, linkName)
} }
func (me *TimingPathFilesystem) Rename(oldName string, newName string) (code Status) { func (me *TimingPathFileSystem) 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.Original.Rename(oldName, newName)
} }
func (me *TimingPathFilesystem) Link(oldName string, newName string) (code Status) { func (me *TimingPathFileSystem) 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.Original.Link(oldName, newName)
} }
func (me *TimingPathFilesystem) Chmod(name string, mode uint32) (code Status) { func (me *TimingPathFileSystem) 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.Original.Chmod(name, mode)
} }
func (me *TimingPathFilesystem) Chown(name string, uid uint32, gid uint32) (code Status) { func (me *TimingPathFileSystem) 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.Original.Chown(name, uid, gid)
} }
func (me *TimingPathFilesystem) Truncate(name string, offset uint64) (code Status) { func (me *TimingPathFileSystem) 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.Original.Truncate(name, offset)
} }
func (me *TimingPathFilesystem) Open(name string, flags uint32) (file FuseFile, code Status) { func (me *TimingPathFileSystem) Open(name string, flags uint32) (file FuseFile, code Status) {
defer me.startTimer("Open", name)() defer me.startTimer("Open", name)()
return me.Original.Open(name, flags) return me.Original.Open(name, flags)
} }
func (me *TimingPathFilesystem) OpenDir(name string) (stream chan DirEntry, status Status) { func (me *TimingPathFileSystem) 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.Original.OpenDir(name)
} }
func (me *TimingPathFilesystem) Mount(conn *PathFileSystemConnector) Status { func (me *TimingPathFileSystem) Mount(conn *PathFileSystemConnector) Status {
defer me.startTimer("Mount", "")() defer me.startTimer("Mount", "")()
return me.Original.Mount(conn) return me.Original.Mount(conn)
} }
func (me *TimingPathFilesystem) Unmount() { func (me *TimingPathFileSystem) Unmount() {
defer me.startTimer("Unmount", "")() defer me.startTimer("Unmount", "")()
me.Original.Unmount() me.Original.Unmount()
} }
func (me *TimingPathFilesystem) Access(name string, mode uint32) (code Status) { func (me *TimingPathFileSystem) 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.Original.Access(name, mode)
} }
func (me *TimingPathFilesystem) Create(name string, flags uint32, mode uint32) (file FuseFile, code Status) { func (me *TimingPathFileSystem) Create(name string, flags uint32, mode uint32) (file FuseFile, code Status) {
defer me.startTimer("Create", name)() defer me.startTimer("Create", name)()
return me.Original.Create(name, flags, mode) return me.Original.Create(name, flags, mode)
} }
func (me *TimingPathFilesystem) Utimens(name string, AtimeNs uint64, CtimeNs uint64) (code Status) { func (me *TimingPathFileSystem) 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.Original.Utimens(name, AtimeNs, CtimeNs)
} }
...@@ -5,24 +5,24 @@ import ( ...@@ -5,24 +5,24 @@ import (
"time" "time"
) )
// 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 WrappingRawFileSystem
statisticsLock sync.Mutex statisticsLock sync.Mutex
latencies map[string]int64 latencies map[string]int64
counts map[string]int64 counts map[string]int64
} }
func NewTimingRawFilesystem(fs RawFileSystem) *TimingRawFilesystem { func NewTimingRawFileSystem(fs RawFileSystem) *TimingRawFileSystem {
t := new(TimingRawFilesystem) t := new(TimingRawFileSystem)
t.Original = fs t.Original = fs
t.latencies = make(map[string]int64) t.latencies = make(map[string]int64)
t.counts = make(map[string]int64) t.counts = make(map[string]int64)
return t return t
} }
func (me *TimingRawFilesystem) startTimer(name string) (closure func()) { func (me *TimingRawFileSystem) startTimer(name string) (closure func()) {
start := time.Nanoseconds() start := time.Nanoseconds()
return func() { return func() {
...@@ -35,7 +35,7 @@ func (me *TimingRawFilesystem) startTimer(name string) (closure func()) { ...@@ -35,7 +35,7 @@ func (me *TimingRawFilesystem) startTimer(name string) (closure func()) {
} }
} }
func (me *TimingRawFilesystem) Latencies() map[string]float64 { func (me *TimingRawFileSystem) Latencies() map[string]float64 {
me.statisticsLock.Lock() me.statisticsLock.Lock()
defer me.statisticsLock.Unlock() defer me.statisticsLock.Unlock()
...@@ -46,167 +46,167 @@ func (me *TimingRawFilesystem) Latencies() map[string]float64 { ...@@ -46,167 +46,167 @@ func (me *TimingRawFilesystem) Latencies() map[string]float64 {
return r return r
} }
func (me *TimingRawFilesystem) Init(h *InHeader, input *InitIn) (*InitOut, Status) { func (me *TimingRawFileSystem) Init(h *InHeader, input *InitIn) (*InitOut, Status) {
defer me.startTimer("Init")() defer me.startTimer("Init")()
return me.Original.Init(h, input) return me.Original.Init(h, input)
} }
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.Original.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.Original.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.Original.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.Original.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.Original.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.Original.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.Original.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.Original.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.Original.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.Original.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.Original.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.Original.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.Original.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.Original.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.Original.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.Original.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.Original.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.Original.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.Original.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.Original.Create(header, input, name)
} }
func (me *TimingRawFilesystem) Bmap(header *InHeader, input *BmapIn) (out *BmapOut, code Status) { func (me *TimingRawFileSystem) Bmap(header *InHeader, input *BmapIn) (out *BmapOut, code Status) {
defer me.startTimer("Bmap")() defer me.startTimer("Bmap")()
return me.Original.Bmap(header, input) return me.Original.Bmap(header, input)
} }
func (me *TimingRawFilesystem) Ioctl(header *InHeader, input *IoctlIn) (out *IoctlOut, code Status) { func (me *TimingRawFileSystem) Ioctl(header *InHeader, input *IoctlIn) (out *IoctlOut, code Status) {
defer me.startTimer("Ioctl")() defer me.startTimer("Ioctl")()
return me.Original.Ioctl(header, input) return me.Original.Ioctl(header, input)
} }
func (me *TimingRawFilesystem) Poll(header *InHeader, input *PollIn) (out *PollOut, code Status) { func (me *TimingRawFileSystem) Poll(header *InHeader, input *PollIn) (out *PollOut, code Status) {
defer me.startTimer("Poll")() defer me.startTimer("Poll")()
return me.Original.Poll(header, input) return me.Original.Poll(header, input)
} }
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.Original.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.Original.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.Original.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.Original.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.Original.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.Original.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.Original.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.Original.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.Original.FsyncDir(header, input)
} }
...@@ -558,7 +558,7 @@ type RawFuseDir interface { ...@@ -558,7 +558,7 @@ type RawFuseDir interface {
Release() Release()
} }
type PathFilesystem interface { type PathFileSystem interface {
GetAttr(name string) (*Attr, Status) GetAttr(name string) (*Attr, Status)
Readlink(name string) (string, Status) Readlink(name string) (string, Status)
Mknod(name string, mode uint32, dev uint32) Status Mknod(name string, mode uint32, dev uint32) Status
...@@ -596,6 +596,6 @@ type PathFilesystem interface { ...@@ -596,6 +596,6 @@ type PathFilesystem interface {
// Include this struct in your implementation to inherit default nop // Include this struct in your implementation to inherit default nop
// implementations. // implementations.
type DefaultPathFilesystem struct{} type DefaultPathFileSystem struct{}
type DefaultFuseFile struct{} type DefaultFuseFile struct{}
type DefaultRawFuseFileSystem struct{} type DefaultRawFuseFileSystem struct{}
package fuse package fuse
type WrappingPathFilesystem struct { type WrappingPathFileSystem struct {
// Should be public so people reusing can access the wrapped // Should be public so people reusing can access the wrapped
// FS. // FS.
Original PathFilesystem Original PathFileSystem
} }
func (me *WrappingPathFilesystem) GetAttr(name string) (*Attr, Status) { func (me *WrappingPathFileSystem) GetAttr(name string) (*Attr, Status) {
return me.Original.GetAttr(name) return me.Original.GetAttr(name)
} }
func (me *WrappingPathFilesystem) Readlink(name string) (string, Status) { func (me *WrappingPathFileSystem) Readlink(name string) (string, Status) {
return me.Original.Readlink(name) return me.Original.Readlink(name)
} }
func (me *WrappingPathFilesystem) Mknod(name string, mode uint32, dev uint32) Status { func (me *WrappingPathFileSystem) Mknod(name string, mode uint32, dev uint32) Status {
return me.Original.Mknod(name, mode, dev) return me.Original.Mknod(name, mode, dev)
} }
func (me *WrappingPathFilesystem) Mkdir(name string, mode uint32) Status { func (me *WrappingPathFileSystem) Mkdir(name string, mode uint32) Status {
return me.Original.Mkdir(name, mode) return me.Original.Mkdir(name, mode)
} }
func (me *WrappingPathFilesystem) Unlink(name string) (code Status) { func (me *WrappingPathFileSystem) Unlink(name string) (code Status) {
return me.Original.Unlink(name) return me.Original.Unlink(name)
} }
func (me *WrappingPathFilesystem) Rmdir(name string) (code Status) { func (me *WrappingPathFileSystem) Rmdir(name string) (code Status) {
return me.Original.Rmdir(name) return me.Original.Rmdir(name)
} }
func (me *WrappingPathFilesystem) Symlink(value string, linkName string) (code Status) { func (me *WrappingPathFileSystem) Symlink(value string, linkName string) (code Status) {
return me.Original.Symlink(value, linkName) return me.Original.Symlink(value, linkName)
} }
func (me *WrappingPathFilesystem) Rename(oldName string, newName string) (code Status) { func (me *WrappingPathFileSystem) Rename(oldName string, newName string) (code Status) {
return me.Original.Rename(oldName, newName) return me.Original.Rename(oldName, newName)
} }
func (me *WrappingPathFilesystem) Link(oldName string, newName string) (code Status) { func (me *WrappingPathFileSystem) Link(oldName string, newName string) (code Status) {
return me.Original.Link(oldName, newName) return me.Original.Link(oldName, newName)
} }
func (me *WrappingPathFilesystem) Chmod(name string, mode uint32) (code Status) { func (me *WrappingPathFileSystem) Chmod(name string, mode uint32) (code Status) {
return me.Original.Chmod(name, mode) return me.Original.Chmod(name, mode)
} }
func (me *WrappingPathFilesystem) Chown(name string, uid uint32, gid uint32) (code Status) { func (me *WrappingPathFileSystem) Chown(name string, uid uint32, gid uint32) (code Status) {
return me.Original.Chown(name, uid, gid) return me.Original.Chown(name, uid, gid)
} }
func (me *WrappingPathFilesystem) Truncate(name string, offset uint64) (code Status) { func (me *WrappingPathFileSystem) Truncate(name string, offset uint64) (code Status) {
return me.Original.Truncate(name, offset) return me.Original.Truncate(name, offset)
} }
func (me *WrappingPathFilesystem) Open(name string, flags uint32) (file FuseFile, code Status) { func (me *WrappingPathFileSystem) Open(name string, flags uint32) (file FuseFile, code Status) {
return me.Original.Open(name, flags) return me.Original.Open(name, flags)
} }
func (me *WrappingPathFilesystem) OpenDir(name string) (stream chan DirEntry, status Status) { func (me *WrappingPathFileSystem) OpenDir(name string) (stream chan DirEntry, status Status) {
return me.Original.OpenDir(name) return me.Original.OpenDir(name)
} }
func (me *WrappingPathFilesystem) Mount(conn *PathFileSystemConnector) Status { func (me *WrappingPathFileSystem) Mount(conn *PathFileSystemConnector) Status {
return me.Original.Mount(conn) return me.Original.Mount(conn)
} }
func (me *WrappingPathFilesystem) Unmount() { func (me *WrappingPathFileSystem) Unmount() {
me.Original.Unmount() me.Original.Unmount()
} }
func (me *WrappingPathFilesystem) Access(name string, mode uint32) (code Status) { func (me *WrappingPathFileSystem) Access(name string, mode uint32) (code Status) {
return me.Original.Access(name, mode) return me.Original.Access(name, mode)
} }
func (me *WrappingPathFilesystem) Create(name string, flags uint32, mode uint32) (file FuseFile, code Status) { func (me *WrappingPathFileSystem) Create(name string, flags uint32, mode uint32) (file FuseFile, code Status) {
return me.Original.Create(name, flags, mode) return me.Original.Create(name, flags, mode)
} }
func (me *WrappingPathFilesystem) Utimens(name string, AtimeNs uint64, CtimeNs uint64) (code Status) { func (me *WrappingPathFileSystem) Utimens(name string, AtimeNs uint64, CtimeNs uint64) (code Status) {
return me.Original.Utimens(name, AtimeNs, CtimeNs) return me.Original.Utimens(name, AtimeNs, CtimeNs)
} }
func (me *WrappingPathFilesystem) GetXAttr(name string, attr string) ([]byte, Status) { func (me *WrappingPathFileSystem) GetXAttr(name string, attr string) ([]byte, Status) {
return me.Original.GetXAttr(name, attr) return me.Original.GetXAttr(name, attr)
} }
func (me *WrappingPathFilesystem) SetXAttr(name string, attr string, data []byte, flags int) Status { func (me *WrappingPathFileSystem) SetXAttr(name string, attr string, data []byte, flags int) Status {
return me.Original.SetXAttr(name, attr, data, flags) return me.Original.SetXAttr(name, attr, data, flags)
} }
func (me *WrappingPathFilesystem) ListXAttr(name string) ([]string, Status) { func (me *WrappingPathFileSystem) ListXAttr(name string) ([]string, Status) {
return me.Original.ListXAttr(name) return me.Original.ListXAttr(name)
} }
func (me *WrappingPathFilesystem) RemoveXAttr(name string, attr string) Status { func (me *WrappingPathFileSystem) RemoveXAttr(name string, attr string) Status {
return me.Original.RemoveXAttr(name, attr) return me.Original.RemoveXAttr(name, attr)
} }
//////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////
// Wrapping raw FS. // Wrapping raw FS.
type WrappingRawFilesystem struct { type WrappingRawFileSystem struct {
Original RawFileSystem Original RawFileSystem
} }
func (me *WrappingRawFilesystem) Init(h *InHeader, input *InitIn) (*InitOut, Status) { func (me *WrappingRawFileSystem) Init(h *InHeader, input *InitIn) (*InitOut, Status) {
return me.Original.Init(h, input) return me.Original.Init(h, input)
} }
func (me *WrappingRawFilesystem) Destroy(h *InHeader, input *InitIn) { func (me *WrappingRawFileSystem) Destroy(h *InHeader, input *InitIn) {
me.Original.Destroy(h, input) me.Original.Destroy(h, input)
} }
func (me *WrappingRawFilesystem) Lookup(h *InHeader, name string) (out *EntryOut, code Status) { func (me *WrappingRawFileSystem) Lookup(h *InHeader, name string) (out *EntryOut, code Status) {
return me.Original.Lookup(h, name) return me.Original.Lookup(h, name)
} }
func (me *WrappingRawFilesystem) Forget(h *InHeader, input *ForgetIn) { func (me *WrappingRawFileSystem) Forget(h *InHeader, input *ForgetIn) {
me.Original.Forget(h, input) me.Original.Forget(h, input)
} }
func (me *WrappingRawFilesystem) GetAttr(header *InHeader, input *GetAttrIn) (out *AttrOut, code Status) { func (me *WrappingRawFileSystem) GetAttr(header *InHeader, input *GetAttrIn) (out *AttrOut, code Status) {
return me.Original.GetAttr(header, input) return me.Original.GetAttr(header, input)
} }
func (me *WrappingRawFilesystem) Open(header *InHeader, input *OpenIn) (flags uint32, handle uint64, status Status) { func (me *WrappingRawFileSystem) Open(header *InHeader, input *OpenIn) (flags uint32, handle uint64, status Status) {
return me.Original.Open(header, input) return me.Original.Open(header, input)
} }
func (me *WrappingRawFilesystem) SetAttr(header *InHeader, input *SetAttrIn) (out *AttrOut, code Status) { func (me *WrappingRawFileSystem) SetAttr(header *InHeader, input *SetAttrIn) (out *AttrOut, code Status) {
return me.Original.SetAttr(header, input) return me.Original.SetAttr(header, input)
} }
func (me *WrappingRawFilesystem) Readlink(header *InHeader) (out []byte, code Status) { func (me *WrappingRawFileSystem) Readlink(header *InHeader) (out []byte, code Status) {
return me.Original.Readlink(header) return me.Original.Readlink(header)
} }
func (me *WrappingRawFilesystem) Mknod(header *InHeader, input *MknodIn, name string) (out *EntryOut, code Status) { func (me *WrappingRawFileSystem) Mknod(header *InHeader, input *MknodIn, name string) (out *EntryOut, code Status) {
return me.Original.Mknod(header, input, name) return me.Original.Mknod(header, input, name)
} }
func (me *WrappingRawFilesystem) Mkdir(header *InHeader, input *MkdirIn, name string) (out *EntryOut, code Status) { func (me *WrappingRawFileSystem) Mkdir(header *InHeader, input *MkdirIn, name string) (out *EntryOut, code Status) {
return me.Original.Mkdir(header, input, name) return me.Original.Mkdir(header, input, name)
} }
func (me *WrappingRawFilesystem) Unlink(header *InHeader, name string) (code Status) { func (me *WrappingRawFileSystem) Unlink(header *InHeader, name string) (code Status) {
return me.Original.Unlink(header, name) return me.Original.Unlink(header, name)
} }
func (me *WrappingRawFilesystem) Rmdir(header *InHeader, name string) (code Status) { func (me *WrappingRawFileSystem) Rmdir(header *InHeader, name string) (code Status) {
return me.Original.Rmdir(header, name) return me.Original.Rmdir(header, name)
} }
func (me *WrappingRawFilesystem) Symlink(header *InHeader, pointedTo string, linkName string) (out *EntryOut, code Status) { func (me *WrappingRawFileSystem) Symlink(header *InHeader, pointedTo string, linkName string) (out *EntryOut, code Status) {
return me.Original.Symlink(header, pointedTo, linkName) return me.Original.Symlink(header, pointedTo, linkName)
} }
func (me *WrappingRawFilesystem) Rename(header *InHeader, input *RenameIn, oldName string, newName string) (code Status) { func (me *WrappingRawFileSystem) Rename(header *InHeader, input *RenameIn, oldName string, newName string) (code Status) {
return me.Original.Rename(header, input, oldName, newName) return me.Original.Rename(header, input, oldName, newName)
} }
func (me *WrappingRawFilesystem) Link(header *InHeader, input *LinkIn, name string) (out *EntryOut, code Status) { func (me *WrappingRawFileSystem) Link(header *InHeader, input *LinkIn, name string) (out *EntryOut, code Status) {
return me.Original.Link(header, input, name) return me.Original.Link(header, input, name)
} }
func (me *WrappingRawFilesystem) SetXAttr(header *InHeader, input *SetXAttrIn, attr string, data []byte) Status { func (me *WrappingRawFileSystem) SetXAttr(header *InHeader, input *SetXAttrIn, attr string, data []byte) Status {
return me.Original.SetXAttr(header, input, attr, data) return me.Original.SetXAttr(header, input, attr, data)
} }
func (me *WrappingRawFilesystem) GetXAttr(header *InHeader, attr string) (data []byte, code Status) { func (me *WrappingRawFileSystem) GetXAttr(header *InHeader, attr string) (data []byte, code Status) {
return me.Original.GetXAttr(header, attr) return me.Original.GetXAttr(header, attr)
} }
func (me *WrappingRawFilesystem) ListXAttr(header *InHeader) (data []byte, code Status) { func (me *WrappingRawFileSystem) ListXAttr(header *InHeader) (data []byte, code Status) {
return me.Original.ListXAttr(header) return me.Original.ListXAttr(header)
} }
func (me *WrappingRawFilesystem) RemoveXAttr(header *InHeader, attr string) Status { func (me *WrappingRawFileSystem) RemoveXAttr(header *InHeader, attr string) Status {
return me.Original.RemoveXAttr(header, attr) return me.Original.RemoveXAttr(header, attr)
} }
func (me *WrappingRawFilesystem) Access(header *InHeader, input *AccessIn) (code Status) { func (me *WrappingRawFileSystem) Access(header *InHeader, input *AccessIn) (code Status) {
return me.Original.Access(header, input) return me.Original.Access(header, input)
} }
func (me *WrappingRawFilesystem) Create(header *InHeader, input *CreateIn, name string) (flags uint32, handle uint64, out *EntryOut, code Status) { 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) return me.Original.Create(header, input, name)
} }
func (me *WrappingRawFilesystem) Bmap(header *InHeader, input *BmapIn) (out *BmapOut, code Status) { func (me *WrappingRawFileSystem) Bmap(header *InHeader, input *BmapIn) (out *BmapOut, code Status) {
return me.Original.Bmap(header, input) return me.Original.Bmap(header, input)
} }
func (me *WrappingRawFilesystem) Ioctl(header *InHeader, input *IoctlIn) (out *IoctlOut, code Status) { func (me *WrappingRawFileSystem) Ioctl(header *InHeader, input *IoctlIn) (out *IoctlOut, code Status) {
return me.Original.Ioctl(header, input) return me.Original.Ioctl(header, input)
} }
func (me *WrappingRawFilesystem) Poll(header *InHeader, input *PollIn) (out *PollOut, code Status) { func (me *WrappingRawFileSystem) Poll(header *InHeader, input *PollIn) (out *PollOut, code Status) {
return me.Original.Poll(header, input) return me.Original.Poll(header, input)
} }
func (me *WrappingRawFilesystem) OpenDir(header *InHeader, input *OpenIn) (flags uint32, handle uint64, status Status) { func (me *WrappingRawFileSystem) OpenDir(header *InHeader, input *OpenIn) (flags uint32, handle uint64, status Status) {
return me.Original.OpenDir(header, input) return me.Original.OpenDir(header, input)
} }
func (me *WrappingRawFilesystem) Release(header *InHeader, input *ReleaseIn) { func (me *WrappingRawFileSystem) Release(header *InHeader, input *ReleaseIn) {
me.Original.Release(header, input) me.Original.Release(header, input)
} }
func (me *WrappingRawFilesystem) Read(input *ReadIn, bp *BufferPool) ([]byte, Status) { func (me *WrappingRawFileSystem) Read(input *ReadIn, bp *BufferPool) ([]byte, Status) {
return me.Original.Read(input, bp) return me.Original.Read(input, bp)
} }
func (me *WrappingRawFilesystem) Write(input *WriteIn, data []byte) (written uint32, code Status) { func (me *WrappingRawFileSystem) Write(input *WriteIn, data []byte) (written uint32, code Status) {
return me.Original.Write(input, data) return me.Original.Write(input, data)
} }
func (me *WrappingRawFilesystem) Flush(input *FlushIn) Status { func (me *WrappingRawFileSystem) Flush(input *FlushIn) Status {
return me.Original.Flush(input) return me.Original.Flush(input)
} }
func (me *WrappingRawFilesystem) Fsync(input *FsyncIn) (code Status) { func (me *WrappingRawFileSystem) Fsync(input *FsyncIn) (code Status) {
return me.Original.Fsync(input) return me.Original.Fsync(input)
} }
func (me *WrappingRawFilesystem) ReadDir(header *InHeader, input *ReadIn) (*DirEntryList, Status) { func (me *WrappingRawFileSystem) ReadDir(header *InHeader, input *ReadIn) (*DirEntryList, Status) {
return me.Original.ReadDir(header, input) return me.Original.ReadDir(header, input)
} }
func (me *WrappingRawFilesystem) ReleaseDir(header *InHeader, input *ReleaseIn) { func (me *WrappingRawFileSystem) ReleaseDir(header *InHeader, input *ReleaseIn) {
me.Original.ReleaseDir(header, input) me.Original.ReleaseDir(header, input)
} }
func (me *WrappingRawFilesystem) FsyncDir(header *InHeader, input *FsyncIn) (code Status) { func (me *WrappingRawFileSystem) FsyncDir(header *InHeader, input *FsyncIn) (code Status) {
return me.Original.FsyncDir(header, input) return me.Original.FsyncDir(header, input)
} }
...@@ -15,7 +15,7 @@ type XAttrTestFs struct { ...@@ -15,7 +15,7 @@ type XAttrTestFs struct {
filename string filename string
attrs map[string][]byte attrs map[string][]byte
DefaultPathFilesystem DefaultPathFileSystem
} }
func NewXAttrFs(nm string, m map[string][]byte) *XAttrTestFs { func NewXAttrFs(nm string, m map[string][]byte) *XAttrTestFs {
...@@ -93,7 +93,7 @@ func TestXAttrRead(t *testing.T) { ...@@ -93,7 +93,7 @@ func TestXAttrRead(t *testing.T) {
"user.attr2": []byte("val2")} "user.attr2": []byte("val2")}
xfs := NewXAttrFs(nm, golden) xfs := NewXAttrFs(nm, golden)
connector := NewPathFileSystemConnector(NewLockingPathFilesystem(xfs)) connector := NewPathFileSystemConnector(NewLockingPathFileSystem(xfs))
mountPoint := MakeTempDir() mountPoint := MakeTempDir()
state := NewMountState(connector) state := NewMountState(connector)
......
...@@ -18,10 +18,10 @@ import ( ...@@ -18,10 +18,10 @@ import (
// //
// A union for A/B/C will placed under directory A-B-C. // A union for A/B/C will placed under directory A-B-C.
type AutoUnionFs struct { type AutoUnionFs struct {
fuse.DefaultPathFilesystem fuse.DefaultPathFileSystem
lock sync.RWMutex lock sync.RWMutex
knownFilesystems map[string]*UnionFs knownFileSystems map[string]*UnionFs
root string root string
connector *fuse.PathFileSystemConnector connector *fuse.PathFileSystemConnector
...@@ -35,7 +35,7 @@ type AutoUnionFsOptions struct { ...@@ -35,7 +35,7 @@ type AutoUnionFsOptions struct {
func NewAutoUnionFs(directory string, options AutoUnionFsOptions) *AutoUnionFs { func NewAutoUnionFs(directory string, options AutoUnionFsOptions) *AutoUnionFs {
a := new(AutoUnionFs) a := new(AutoUnionFs)
a.knownFilesystems = make(map[string]*UnionFs) a.knownFileSystems = make(map[string]*UnionFs)
a.options = &options a.options = &options
a.root = directory a.root = directory
return a return a
...@@ -58,10 +58,10 @@ func (me *AutoUnionFs) addFs(roots []string) { ...@@ -58,10 +58,10 @@ func (me *AutoUnionFs) addFs(roots []string) {
me.lock.Lock() me.lock.Lock()
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
} }
me.lock.Unlock() me.lock.Unlock()
...@@ -103,7 +103,7 @@ func (me *AutoUnionFs) Readlink(path string) (out string, code fuse.Status) { ...@@ -103,7 +103,7 @@ func (me *AutoUnionFs) Readlink(path string) (out string, code fuse.Status) {
name := comps[1] name := comps[1]
me.lock.RLock() me.lock.RLock()
defer me.lock.RUnlock() defer me.lock.RUnlock()
fs := me.knownFilesystems[name] fs := me.knownFileSystems[name]
if fs == nil { if fs == nil {
return "", fuse.ENOENT return "", fuse.ENOENT
} }
...@@ -137,7 +137,7 @@ func (me *AutoUnionFs) GetAttr(path string) (*fuse.Attr, fuse.Status) { ...@@ -137,7 +137,7 @@ func (me *AutoUnionFs) GetAttr(path string) (*fuse.Attr, fuse.Status) {
me.lock.RLock() me.lock.RLock()
defer me.lock.RUnlock() defer me.lock.RUnlock()
if len(comps) > 1 && comps[0] == "config" { if len(comps) > 1 && comps[0] == "config" {
fs := me.knownFilesystems[comps[1]] fs := me.knownFileSystems[comps[1]]
if fs == nil { if fs == nil {
return nil, fuse.ENOENT return nil, fuse.ENOENT
...@@ -149,7 +149,7 @@ func (me *AutoUnionFs) GetAttr(path string) (*fuse.Attr, fuse.Status) { ...@@ -149,7 +149,7 @@ func (me *AutoUnionFs) GetAttr(path string) (*fuse.Attr, fuse.Status) {
return a, fuse.OK return a, fuse.OK
} }
if me.knownFilesystems[path] != nil { if me.knownFileSystems[path] != nil {
return &fuse.Attr{ return &fuse.Attr{
Mode: fuse.S_IFDIR | 0755, Mode: fuse.S_IFDIR | 0755,
},fuse.OK },fuse.OK
...@@ -189,8 +189,8 @@ func (me *AutoUnionFs) OpenDir(name string) (stream chan fuse.DirEntry, status f ...@@ -189,8 +189,8 @@ func (me *AutoUnionFs) OpenDir(name string) (stream chan fuse.DirEntry, status f
me.lock.RLock() me.lock.RLock()
defer me.lock.RUnlock() defer me.lock.RUnlock()
stream = make(chan fuse.DirEntry, len(me.knownFilesystems)+5) stream = make(chan fuse.DirEntry, len(me.knownFileSystems)+5)
for k, _ := range me.knownFilesystems { for k, _ := range me.knownFileSystems {
mode := fuse.S_IFDIR | 0755 mode := fuse.S_IFDIR | 0755
if name == "config" { if name == "config" {
mode = syscall.S_IFLNK | 0644 mode = syscall.S_IFLNK | 0644
......
...@@ -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.WrappingPathFilesystem fuse.WrappingPathFileSystem
attributesLock sync.RWMutex attributesLock sync.RWMutex
attributes map[string]attrResponse attributes map[string]attrResponse
...@@ -34,7 +34,7 @@ type CachingFileSystem struct { ...@@ -34,7 +34,7 @@ type CachingFileSystem struct {
links map[string]linkResponse links map[string]linkResponse
} }
func NewCachingFileSystem(pfs fuse.PathFilesystem) *CachingFileSystem { func NewCachingFileSystem(pfs fuse.PathFileSystem) *CachingFileSystem {
c := new(CachingFileSystem) c := new(CachingFileSystem)
c.Original = pfs c.Original = pfs
c.attributes = make(map[string]attrResponse) c.attributes = make(map[string]attrResponse)
......
...@@ -58,12 +58,12 @@ func filePathHash(path string) string { ...@@ -58,12 +58,12 @@ func filePathHash(path string) string {
*/ */
type UnionFs struct { type UnionFs struct {
fuse.DefaultPathFilesystem fuse.DefaultPathFileSystem
branches []*fuse.LoopbackFileSystem branches []*fuse.LoopbackFileSystem
// The same, but as interfaces. // The same, but as interfaces.
fileSystems []fuse.PathFilesystem fileSystems []fuse.PathFileSystem
// A file-existence cache. // A file-existence cache.
deletionCache *DirCache deletionCache *DirCache
...@@ -89,7 +89,7 @@ func NewUnionFs(roots []string, options UnionFsOptions) *UnionFs { ...@@ -89,7 +89,7 @@ func NewUnionFs(roots []string, options UnionFsOptions) *UnionFs {
g.branches = append(g.branches, pt) g.branches = append(g.branches, pt)
// We could use some sort of caching file system here. // We could use some sort of caching file system here.
g.fileSystems = append(g.fileSystems, fuse.PathFilesystem(pt)) g.fileSystems = append(g.fileSystems, fuse.PathFileSystem(pt))
} }
deletionDir := g.deletionDir() deletionDir := g.deletionDir()
...@@ -232,7 +232,7 @@ src *fuse.LoopbackFileSystem) os.Error { ...@@ -232,7 +232,7 @@ src *fuse.LoopbackFileSystem) os.Error {
} }
//////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////
// Below: implement interface for a PathFilesystem. // Below: implement interface for a PathFileSystem.
func (me *UnionFs) Mkdir(path string, mode uint32) (code fuse.Status) { func (me *UnionFs) Mkdir(path string, mode uint32) (code fuse.Status) {
code = me.fileSystems[0].Mkdir(path, mode) code = me.fileSystems[0].Mkdir(path, mode)
...@@ -344,7 +344,7 @@ func (me *UnionFs) OpenDir(directory string) (stream chan fuse.DirEntry, status ...@@ -344,7 +344,7 @@ func (me *UnionFs) OpenDir(directory string) (stream chan fuse.DirEntry, status
for i, l := range me.fileSystems { for i, l := range me.fileSystems {
if i >= dirBranch { if i >= dirBranch {
wg.Add(1) wg.Add(1)
go func(j int, pfs fuse.PathFilesystem) { go func(j int, pfs fuse.PathFileSystem) {
ch, s := pfs.OpenDir(directory) ch, s := pfs.OpenDir(directory)
statuses[j] = s statuses[j] = s
for s == fuse.OK { for s == fuse.OK {
......
...@@ -77,7 +77,7 @@ type MultiZipFs struct { ...@@ -77,7 +77,7 @@ type MultiZipFs struct {
pendingZips map[string]bool pendingZips map[string]bool
zipFileNames map[string]string zipFileNames map[string]string
fuse.DefaultPathFilesystem fuse.DefaultPathFileSystem
} }
func NewMultiZipFs() *MultiZipFs { func NewMultiZipFs() *MultiZipFs {
......
...@@ -75,7 +75,7 @@ type ZipFileFuse struct { ...@@ -75,7 +75,7 @@ type ZipFileFuse struct {
tree *ZipDirTree tree *ZipDirTree
ZipFileName string ZipFileName string
fuse.DefaultPathFilesystem fuse.DefaultPathFileSystem
} }
func zipFilesToTree(files []*zip.File) *ZipDirTree { func zipFilesToTree(files []*zip.File) *ZipDirTree {
......
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