Commit 5c47ca23 authored by Han-Wen Nienhuys's avatar Han-Wen Nienhuys

Rename PathFileSystem to FileSystem.

parent 9c3ac0b4
...@@ -33,7 +33,7 @@ func main() { ...@@ -33,7 +33,7 @@ func main() {
} }
gofs := unionfs.NewAutoUnionFs(flag.Arg(1), options) gofs := unionfs.NewAutoUnionFs(flag.Arg(1), options)
conn := fuse.NewPathFileSystemConnector(gofs) conn := fuse.NewFileSystemConnector(gofs)
mountState := fuse.NewMountState(conn) mountState := fuse.NewMountState(conn)
mountState.Debug = *debug mountState.Debug = *debug
fmt.Printf("Mounting...\n") fmt.Printf("Mounting...\n")
......
...@@ -16,7 +16,7 @@ var _ = runtime.GOMAXPROCS ...@@ -16,7 +16,7 @@ var _ = runtime.GOMAXPROCS
var _ = log.Print var _ = log.Print
type PathPrintingFs struct { type PathPrintingFs struct {
fuse.WrappingPathFileSystem fuse.WrappingFileSystem
} }
func (me *PathPrintingFs) GetAttr(name string) (*fuse.Attr, fuse.Status) { func (me *PathPrintingFs) GetAttr(name string) (*fuse.Attr, fuse.Status) {
...@@ -35,22 +35,22 @@ func main() { ...@@ -35,22 +35,22 @@ func main() {
os.Exit(2) os.Exit(2)
} }
var fs fuse.PathFileSystem var fs fuse.FileSystem
orig := flag.Arg(1) orig := flag.Arg(1)
loopbackfs := fuse.NewLoopbackFileSystem(orig) loopbackfs := fuse.NewLoopbackFileSystem(orig)
fs = loopbackfs fs = loopbackfs
debugFs := new(fuse.PathFileSystemDebug) debugFs := new(fuse.FileSystemDebug)
debugFs.Original = fs debugFs.Original = fs
fs = debugFs fs = debugFs
timing := fuse.NewTimingPathFileSystem(fs) timing := fuse.NewTimingFileSystem(fs)
fs = timing fs = timing
var opts fuse.PathFileSystemConnectorOptions var opts fuse.FileSystemConnectorOptions
loopbackfs.FillOptions(&opts) loopbackfs.FillOptions(&opts)
conn := fuse.NewPathFileSystemConnector(fs) conn := fuse.NewFileSystemConnector(fs)
debugFs.Connector = conn debugFs.Connector = conn
rawTiming := fuse.NewTimingRawFileSystem(conn) rawTiming := fuse.NewTimingRawFileSystem(conn)
......
...@@ -30,7 +30,7 @@ func main() { ...@@ -30,7 +30,7 @@ func main() {
} }
ufs := unionfs.NewUnionFs(flag.Args()[1:], ufsOptions) ufs := unionfs.NewUnionFs(flag.Args()[1:], ufsOptions)
conn := fuse.NewPathFileSystemConnector(ufs) conn := fuse.NewFileSystemConnector(ufs)
mountState := fuse.NewMountState(conn) mountState := fuse.NewMountState(conn)
mountState.Debug = *debug mountState.Debug = *debug
fmt.Printf("Mounting...\n") fmt.Printf("Mounting...\n")
......
...@@ -22,7 +22,7 @@ func main() { ...@@ -22,7 +22,7 @@ func main() {
} }
fs := zipfs.NewZipArchiveFileSystem(flag.Arg(1)) fs := zipfs.NewZipArchiveFileSystem(flag.Arg(1))
conn := fuse.NewPathFileSystemConnector(fs) conn := fuse.NewFileSystemConnector(fs)
state := fuse.NewMountState(conn) state := fuse.NewMountState(conn)
mountPoint := flag.Arg(0) mountPoint := flag.Arg(0)
......
...@@ -159,95 +159,95 @@ func (me *DefaultFile) Fsync(*FsyncIn) (code Status) { ...@@ -159,95 +159,95 @@ func (me *DefaultFile) Fsync(*FsyncIn) (code Status) {
} }
//////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////
// DefaultPathFileSystem // DefaultFileSystem
func (me *DefaultPathFileSystem) GetAttr(name string) (*Attr, Status) { func (me *DefaultFileSystem) GetAttr(name string) (*Attr, Status) {
return nil, ENOSYS return nil, ENOSYS
} }
func (me *DefaultPathFileSystem) GetXAttr(name string, attr string) ([]byte, Status) { func (me *DefaultFileSystem) 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 *DefaultFileSystem) SetXAttr(name string, attr string, data []byte, flags int) Status {
return ENOSYS return ENOSYS
} }
func (me *DefaultPathFileSystem) ListXAttr(name string) ([]string, Status) { func (me *DefaultFileSystem) ListXAttr(name string) ([]string, Status) {
return nil, ENOSYS return nil, ENOSYS
} }
func (me *DefaultPathFileSystem) RemoveXAttr(name string, attr string) Status { func (me *DefaultFileSystem) RemoveXAttr(name string, attr string) Status {
return ENOSYS return ENOSYS
} }
func (me *DefaultPathFileSystem) Readlink(name string) (string, Status) { func (me *DefaultFileSystem) Readlink(name string) (string, Status) {
return "", ENOSYS return "", ENOSYS
} }
func (me *DefaultPathFileSystem) Mknod(name string, mode uint32, dev uint32) Status { func (me *DefaultFileSystem) Mknod(name string, mode uint32, dev uint32) Status {
return ENOSYS return ENOSYS
} }
func (me *DefaultPathFileSystem) Mkdir(name string, mode uint32) Status { func (me *DefaultFileSystem) Mkdir(name string, mode uint32) Status {
return ENOSYS return ENOSYS
} }
func (me *DefaultPathFileSystem) Unlink(name string) (code Status) { func (me *DefaultFileSystem) Unlink(name string) (code Status) {
return ENOSYS return ENOSYS
} }
func (me *DefaultPathFileSystem) Rmdir(name string) (code Status) { func (me *DefaultFileSystem) Rmdir(name string) (code Status) {
return ENOSYS return ENOSYS
} }
func (me *DefaultPathFileSystem) Symlink(value string, linkName string) (code Status) { func (me *DefaultFileSystem) Symlink(value string, linkName string) (code Status) {
return ENOSYS return ENOSYS
} }
func (me *DefaultPathFileSystem) Rename(oldName string, newName string) (code Status) { func (me *DefaultFileSystem) Rename(oldName string, newName string) (code Status) {
return ENOSYS return ENOSYS
} }
func (me *DefaultPathFileSystem) Link(oldName string, newName string) (code Status) { func (me *DefaultFileSystem) Link(oldName string, newName string) (code Status) {
return ENOSYS return ENOSYS
} }
func (me *DefaultPathFileSystem) Chmod(name string, mode uint32) (code Status) { func (me *DefaultFileSystem) 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 *DefaultFileSystem) 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 *DefaultFileSystem) Truncate(name string, offset uint64) (code Status) {
return ENOSYS return ENOSYS
} }
func (me *DefaultPathFileSystem) Open(name string, flags uint32) (file File, code Status) { func (me *DefaultFileSystem) Open(name string, flags uint32) (file File, code Status) {
return nil, ENOSYS return nil, ENOSYS
} }
func (me *DefaultPathFileSystem) OpenDir(name string) (stream chan DirEntry, status Status) { func (me *DefaultFileSystem) OpenDir(name string) (stream chan DirEntry, status Status) {
return nil, ENOSYS return nil, ENOSYS
} }
func (me *DefaultPathFileSystem) Mount(conn *PathFileSystemConnector) Status { func (me *DefaultFileSystem) Mount(conn *FileSystemConnector) Status {
return OK return OK
} }
func (me *DefaultPathFileSystem) Unmount() { func (me *DefaultFileSystem) Unmount() {
} }
func (me *DefaultPathFileSystem) Access(name string, mode uint32) (code Status) { func (me *DefaultFileSystem) Access(name string, mode uint32) (code Status) {
return ENOSYS return ENOSYS
} }
func (me *DefaultPathFileSystem) Create(name string, flags uint32, mode uint32) (file File, code Status) { func (me *DefaultFileSystem) Create(name string, flags uint32, mode uint32) (file File, code Status) {
return nil, ENOSYS return nil, ENOSYS
} }
func (me *DefaultPathFileSystem) Utimens(name string, AtimeNs uint64, CtimeNs uint64) (code Status) { func (me *DefaultFileSystem) Utimens(name string, AtimeNs uint64, CtimeNs uint64) (code Status) {
return ENOSYS return ENOSYS
} }
...@@ -18,10 +18,10 @@ func TestRawFs(t *testing.T) { ...@@ -18,10 +18,10 @@ func TestRawFs(t *testing.T) {
} }
func TestPathFs(t *testing.T) { func TestPathFs(t *testing.T) {
var iface PathFileSystem var iface FileSystem
iface = new(DefaultPathFileSystem) iface = new(DefaultFileSystem)
iface = new(WrappingPathFileSystem) iface = new(WrappingFileSystem)
iface = new(TimingPathFileSystem) iface = new(TimingFileSystem)
_ = iface _ = iface
} }
......
...@@ -9,7 +9,7 @@ import ( ...@@ -9,7 +9,7 @@ import (
) )
var _ = fmt.Print var _ = fmt.Print
// For PathFileSystemConnector. The connector determines inodes. // For FileSystemConnector. The connector determines inodes.
type DirEntry struct { type DirEntry struct {
Mode uint32 Mode uint32
Name string Name string
......
...@@ -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 FileSystem 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 LockingFileSystem struct {
// Should be public so people reusing can access the wrapped // Should be public so people reusing can access the wrapped
// FS. // FS.
WrappingPathFileSystem WrappingFileSystem
lock sync.Mutex lock sync.Mutex
} }
func NewLockingPathFileSystem(pfs PathFileSystem) *LockingPathFileSystem { func NewLockingFileSystem(pfs FileSystem) *LockingFileSystem {
l := new(LockingPathFileSystem) l := new(LockingFileSystem)
l.Original = pfs l.Original = pfs
return l return l
} }
func (me *LockingPathFileSystem) GetAttr(name string) (*Attr, Status) { func (me *LockingFileSystem) GetAttr(name string) (*Attr, Status) {
me.lock.Lock() me.lock.Lock()
defer me.lock.Unlock() defer me.lock.Unlock()
return me.Original.GetAttr(name) return me.Original.GetAttr(name)
} }
func (me *LockingPathFileSystem) Readlink(name string) (string, Status) { func (me *LockingFileSystem) Readlink(name string) (string, Status) {
me.lock.Lock() me.lock.Lock()
defer me.lock.Unlock() defer me.lock.Unlock()
return me.Original.Readlink(name) return me.Original.Readlink(name)
} }
func (me *LockingPathFileSystem) Mknod(name string, mode uint32, dev uint32) Status { func (me *LockingFileSystem) Mknod(name string, mode uint32, dev uint32) Status {
me.lock.Lock() me.lock.Lock()
defer me.lock.Unlock() defer me.lock.Unlock()
return me.Original.Mknod(name, mode, dev) return me.Original.Mknod(name, mode, dev)
} }
func (me *LockingPathFileSystem) Mkdir(name string, mode uint32) Status { func (me *LockingFileSystem) Mkdir(name string, mode uint32) Status {
me.lock.Lock() me.lock.Lock()
defer me.lock.Unlock() defer me.lock.Unlock()
return me.Original.Mkdir(name, mode) return me.Original.Mkdir(name, mode)
} }
func (me *LockingPathFileSystem) Unlink(name string) (code Status) { func (me *LockingFileSystem) Unlink(name string) (code Status) {
me.lock.Lock() me.lock.Lock()
defer me.lock.Unlock() defer me.lock.Unlock()
return me.Original.Unlink(name) return me.Original.Unlink(name)
} }
func (me *LockingPathFileSystem) Rmdir(name string) (code Status) { func (me *LockingFileSystem) Rmdir(name string) (code Status) {
me.lock.Lock() me.lock.Lock()
defer me.lock.Unlock() defer me.lock.Unlock()
return me.Original.Rmdir(name) return me.Original.Rmdir(name)
} }
func (me *LockingPathFileSystem) Symlink(value string, linkName string) (code Status) { func (me *LockingFileSystem) Symlink(value string, linkName string) (code Status) {
me.lock.Lock() me.lock.Lock()
defer me.lock.Unlock() defer me.lock.Unlock()
return me.Original.Symlink(value, linkName) return me.Original.Symlink(value, linkName)
} }
func (me *LockingPathFileSystem) Rename(oldName string, newName string) (code Status) { func (me *LockingFileSystem) Rename(oldName string, newName string) (code Status) {
me.lock.Lock() me.lock.Lock()
defer me.lock.Unlock() defer me.lock.Unlock()
return me.Original.Rename(oldName, newName) return me.Original.Rename(oldName, newName)
} }
func (me *LockingPathFileSystem) Link(oldName string, newName string) (code Status) { func (me *LockingFileSystem) Link(oldName string, newName string) (code Status) {
me.lock.Lock() me.lock.Lock()
defer me.lock.Unlock() defer me.lock.Unlock()
return me.Original.Link(oldName, newName) return me.Original.Link(oldName, newName)
} }
func (me *LockingPathFileSystem) Chmod(name string, mode uint32) (code Status) { func (me *LockingFileSystem) Chmod(name string, mode uint32) (code Status) {
me.lock.Lock() me.lock.Lock()
defer me.lock.Unlock() defer me.lock.Unlock()
return me.Original.Chmod(name, mode) return me.Original.Chmod(name, mode)
} }
func (me *LockingPathFileSystem) Chown(name string, uid uint32, gid uint32) (code Status) { func (me *LockingFileSystem) Chown(name string, uid uint32, gid uint32) (code Status) {
me.lock.Lock() me.lock.Lock()
defer me.lock.Unlock() defer me.lock.Unlock()
return me.Original.Chown(name, uid, gid) return me.Original.Chown(name, uid, gid)
} }
func (me *LockingPathFileSystem) Truncate(name string, offset uint64) (code Status) { func (me *LockingFileSystem) Truncate(name string, offset uint64) (code Status) {
me.lock.Lock() me.lock.Lock()
defer me.lock.Unlock() defer me.lock.Unlock()
return me.Original.Truncate(name, offset) return me.Original.Truncate(name, offset)
} }
func (me *LockingPathFileSystem) Open(name string, flags uint32) (file File, code Status) { func (me *LockingFileSystem) Open(name string, flags uint32) (file File, code Status) {
return me.Original.Open(name, flags) return me.Original.Open(name, flags)
} }
func (me *LockingPathFileSystem) OpenDir(name string) (stream chan DirEntry, status Status) { func (me *LockingFileSystem) OpenDir(name string) (stream chan DirEntry, status Status) {
me.lock.Lock() me.lock.Lock()
defer me.lock.Unlock() defer me.lock.Unlock()
return me.Original.OpenDir(name) return me.Original.OpenDir(name)
} }
func (me *LockingPathFileSystem) Mount(conn *PathFileSystemConnector) Status { func (me *LockingFileSystem) Mount(conn *FileSystemConnector) Status {
me.lock.Lock() me.lock.Lock()
defer me.lock.Unlock() defer me.lock.Unlock()
return me.Original.Mount(conn) return me.Original.Mount(conn)
} }
func (me *LockingPathFileSystem) Unmount() { func (me *LockingFileSystem) 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 *LockingFileSystem) Access(name string, mode uint32) (code Status) {
me.lock.Lock() me.lock.Lock()
defer me.lock.Unlock() defer me.lock.Unlock()
return me.Original.Access(name, mode) return me.Original.Access(name, mode)
} }
func (me *LockingPathFileSystem) Create(name string, flags uint32, mode uint32) (file File, code Status) { func (me *LockingFileSystem) Create(name string, flags uint32, mode uint32) (file File, code Status) {
me.lock.Lock() me.lock.Lock()
defer me.lock.Unlock() defer me.lock.Unlock()
return me.Original.Create(name, flags, mode) return me.Original.Create(name, flags, mode)
} }
func (me *LockingPathFileSystem) Utimens(name string, AtimeNs uint64, CtimeNs uint64) (code Status) { func (me *LockingFileSystem) Utimens(name string, AtimeNs uint64, CtimeNs uint64) (code Status) {
me.lock.Lock() me.lock.Lock()
defer me.lock.Unlock() defer me.lock.Unlock()
return me.Original.Utimens(name, AtimeNs, CtimeNs) return me.Original.Utimens(name, AtimeNs, CtimeNs)
} }
func (me *LockingPathFileSystem) GetXAttr(name string, attr string) ([]byte, Status) { func (me *LockingFileSystem) GetXAttr(name string, attr string) ([]byte, Status) {
me.lock.Lock() me.lock.Lock()
defer me.lock.Unlock() defer me.lock.Unlock()
return me.Original.GetXAttr(name, attr) return me.Original.GetXAttr(name, attr)
} }
func (me *LockingPathFileSystem) SetXAttr(name string, attr string, data []byte, flags int) Status { func (me *LockingFileSystem) SetXAttr(name string, attr string, data []byte, flags int) Status {
me.lock.Lock() me.lock.Lock()
defer me.lock.Unlock() defer me.lock.Unlock()
return me.Original.SetXAttr(name, attr, data, flags) return me.Original.SetXAttr(name, attr, data, flags)
} }
func (me *LockingPathFileSystem) ListXAttr(name string) ([]string, Status) { func (me *LockingFileSystem) ListXAttr(name string) ([]string, Status) {
me.lock.Lock() me.lock.Lock()
defer me.lock.Unlock() defer me.lock.Unlock()
return me.Original.ListXAttr(name) return me.Original.ListXAttr(name)
} }
func (me *LockingPathFileSystem) RemoveXAttr(name string, attr string) Status { func (me *LockingFileSystem) RemoveXAttr(name string, attr string) Status {
me.lock.Lock() me.lock.Lock()
defer me.lock.Unlock() defer me.lock.Unlock()
return me.Original.RemoveXAttr(name, attr) return me.Original.RemoveXAttr(name, attr)
......
...@@ -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 DefaultFileSystem
} }
func NewLoopbackFileSystem(root string) (out *LoopbackFileSystem) { func NewLoopbackFileSystem(root string) (out *LoopbackFileSystem) {
...@@ -162,7 +162,7 @@ func (me *LoopbackFileSystem) RemoveXAttr(name string, attr string) Status { ...@@ -162,7 +162,7 @@ func (me *LoopbackFileSystem) RemoveXAttr(name string, attr string) Status {
return Status(Removexattr(me.GetPath(name), attr)) return Status(Removexattr(me.GetPath(name), attr))
} }
func (me *LoopbackFileSystem) FillOptions(options *PathFileSystemConnectorOptions) { func (me *LoopbackFileSystem) FillOptions(options *FileSystemConnectorOptions) {
// These options are to be compatible with libfuse defaults, // These options are to be compatible with libfuse defaults,
// making benchmarking easier. // making benchmarking easier.
options.NegativeTimeout = 1.0 options.NegativeTimeout = 1.0
......
...@@ -34,7 +34,7 @@ type testCase struct { ...@@ -34,7 +34,7 @@ type testCase struct {
origSubfile string origSubfile string
tester *testing.T tester *testing.T
state *MountState state *MountState
connector *PathFileSystemConnector connector *FileSystemConnector
} }
// Create and mount filesystem. // Create and mount filesystem.
...@@ -55,13 +55,13 @@ func (me *testCase) Setup(t *testing.T) { ...@@ -55,13 +55,13 @@ 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 FileSystem
pfs = NewLoopbackFileSystem(me.origDir) pfs = NewLoopbackFileSystem(me.origDir)
pfs = NewTimingPathFileSystem(pfs) pfs = NewTimingFileSystem(pfs)
pfs = NewLockingPathFileSystem(pfs) pfs = NewLockingFileSystem(pfs)
var rfs RawFileSystem var rfs RawFileSystem
me.connector = NewPathFileSystemConnector(pfs) me.connector = NewFileSystemConnector(pfs)
rfs = me.connector rfs = me.connector
rfs = NewTimingRawFileSystem(rfs) rfs = NewTimingRawFileSystem(rfs)
rfs = NewLockingRawFileSystem(rfs) rfs = NewLockingRawFileSystem(rfs)
......
...@@ -5,21 +5,21 @@ import ( ...@@ -5,21 +5,21 @@ import (
var _ = fmt.Println var _ = fmt.Println
type PathFileSystemDebug struct { type FileSystemDebug struct {
// TODO - use a generic callback system instead. // TODO - use a generic callback system instead.
Connector *PathFileSystemConnector Connector *FileSystemConnector
WrappingPathFileSystem WrappingFileSystem
} }
func (me *PathFileSystemDebug) Open(path string, flags uint32) (fuseFile File, status Status) { func (me *FileSystemDebug) Open(path string, flags uint32) (fuseFile File, 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 *FileSystemDebug) 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 FileSystem
// 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 FileSystem) *mountData {
return &mountData{fs: fs} return &mountData{fs: fs}
} }
...@@ -141,14 +141,14 @@ func MakeTimeoutOptions() TimeoutOptions { ...@@ -141,14 +141,14 @@ func MakeTimeoutOptions() TimeoutOptions {
} }
} }
type PathFileSystemConnectorOptions struct { type FileSystemConnectorOptions struct {
TimeoutOptions TimeoutOptions
} }
type PathFileSystemConnector struct { type FileSystemConnector struct {
DefaultRawFileSystem DefaultRawFileSystem
options PathFileSystemConnectorOptions options FileSystemConnectorOptions
Debug bool Debug bool
//////////////// ////////////////
...@@ -166,7 +166,7 @@ type PathFileSystemConnector struct { ...@@ -166,7 +166,7 @@ type PathFileSystemConnector struct {
nextFreeHandle uint64 nextFreeHandle uint64
} }
func (me *PathFileSystemConnector) DebugString() string { func (me *FileSystemConnector) DebugString() string {
me.lock.RLock() me.lock.RLock()
defer me.lock.RUnlock() defer me.lock.RUnlock()
...@@ -179,7 +179,7 @@ func (me *PathFileSystemConnector) DebugString() string { ...@@ -179,7 +179,7 @@ func (me *PathFileSystemConnector) DebugString() string {
len(me.openFiles), len(me.inodeMap)) len(me.openFiles), len(me.inodeMap))
} }
func (me *PathFileSystemConnector) unregisterFile(node *inode, handle uint64) interface{} { func (me *FileSystemConnector) unregisterFile(node *inode, handle uint64) interface{} {
me.fileLock.Lock() me.fileLock.Lock()
defer me.fileLock.Unlock() defer me.fileLock.Unlock()
f, ok := me.openFiles[handle] f, ok := me.openFiles[handle]
...@@ -191,7 +191,7 @@ func (me *PathFileSystemConnector) unregisterFile(node *inode, handle uint64) in ...@@ -191,7 +191,7 @@ func (me *PathFileSystemConnector) unregisterFile(node *inode, handle uint64) in
return f return f
} }
func (me *PathFileSystemConnector) registerFile(node *inode, f interface{}) uint64 { func (me *FileSystemConnector) registerFile(node *inode, f interface{}) uint64 {
me.fileLock.Lock() me.fileLock.Lock()
defer me.fileLock.Unlock() defer me.fileLock.Unlock()
...@@ -207,19 +207,19 @@ func (me *PathFileSystemConnector) registerFile(node *inode, f interface{}) uint ...@@ -207,19 +207,19 @@ func (me *PathFileSystemConnector) registerFile(node *inode, f interface{}) uint
return h return h
} }
func (me *PathFileSystemConnector) getDir(h uint64) RawDir { func (me *FileSystemConnector) getDir(h uint64) RawDir {
me.fileLock.RLock() me.fileLock.RLock()
defer me.fileLock.RUnlock() defer me.fileLock.RUnlock()
return me.openFiles[h].(RawDir) return me.openFiles[h].(RawDir)
} }
func (me *PathFileSystemConnector) getFile(h uint64) File { func (me *FileSystemConnector) getFile(h uint64) File {
me.fileLock.RLock() me.fileLock.RLock()
defer me.fileLock.RUnlock() defer me.fileLock.RUnlock()
return me.openFiles[h].(File) return me.openFiles[h].(File)
} }
func (me *PathFileSystemConnector) verify() { func (me *FileSystemConnector) verify() {
if !paranoia { if !paranoia {
return return
} }
...@@ -249,7 +249,7 @@ func (me *PathFileSystemConnector) verify() { ...@@ -249,7 +249,7 @@ func (me *PathFileSystemConnector) verify() {
} }
} }
func (me *PathFileSystemConnector) newInode() *inode { func (me *FileSystemConnector) newInode() *inode {
data := new(inode) data := new(inode)
data.NodeId = me.nextFreeInode data.NodeId = me.nextFreeInode
me.nextFreeInode++ me.nextFreeInode++
...@@ -259,7 +259,7 @@ func (me *PathFileSystemConnector) newInode() *inode { ...@@ -259,7 +259,7 @@ func (me *PathFileSystemConnector) newInode() *inode {
return data return data
} }
func (me *PathFileSystemConnector) lookupUpdate(parent *inode, name string, isDir bool) *inode { func (me *FileSystemConnector) lookupUpdate(parent *inode, name string, isDir bool) *inode {
defer me.verify() defer me.verify()
me.lock.Lock() me.lock.Lock()
...@@ -278,7 +278,7 @@ func (me *PathFileSystemConnector) lookupUpdate(parent *inode, name string, isDi ...@@ -278,7 +278,7 @@ func (me *PathFileSystemConnector) lookupUpdate(parent *inode, name string, isDi
return data return data
} }
func (me *PathFileSystemConnector) getInodeData(nodeid uint64) *inode { func (me *FileSystemConnector) getInodeData(nodeid uint64) *inode {
me.lock.RLock() me.lock.RLock()
defer me.lock.RUnlock() defer me.lock.RUnlock()
...@@ -289,7 +289,7 @@ func (me *PathFileSystemConnector) getInodeData(nodeid uint64) *inode { ...@@ -289,7 +289,7 @@ func (me *PathFileSystemConnector) getInodeData(nodeid uint64) *inode {
return val return val
} }
func (me *PathFileSystemConnector) forgetUpdate(nodeId uint64, forgetCount int) { func (me *FileSystemConnector) forgetUpdate(nodeId uint64, forgetCount int) {
defer me.verify() defer me.verify()
me.lock.Lock() me.lock.Lock()
defer me.lock.Unlock() defer me.lock.Unlock()
...@@ -301,7 +301,7 @@ func (me *PathFileSystemConnector) forgetUpdate(nodeId uint64, forgetCount int) ...@@ -301,7 +301,7 @@ func (me *PathFileSystemConnector) forgetUpdate(nodeId uint64, forgetCount int)
} }
} }
func (me *PathFileSystemConnector) considerDropInode(n *inode) { func (me *FileSystemConnector) considerDropInode(n *inode) {
if n.mount != nil { if n.mount != nil {
n.mount.mutex.RLock() n.mount.mutex.RLock()
defer n.mount.mutex.RUnlock() defer n.mount.mutex.RUnlock()
...@@ -315,7 +315,7 @@ func (me *PathFileSystemConnector) considerDropInode(n *inode) { ...@@ -315,7 +315,7 @@ func (me *PathFileSystemConnector) considerDropInode(n *inode) {
} }
} }
func (me *PathFileSystemConnector) renameUpdate(oldParent *inode, oldName string, newParent *inode, newName string) { func (me *FileSystemConnector) renameUpdate(oldParent *inode, oldName string, newParent *inode, newName string) {
defer me.verify() defer me.verify()
me.lock.Lock() me.lock.Lock()
defer me.lock.Unlock() defer me.lock.Unlock()
...@@ -334,7 +334,7 @@ func (me *PathFileSystemConnector) renameUpdate(oldParent *inode, oldName string ...@@ -334,7 +334,7 @@ func (me *PathFileSystemConnector) renameUpdate(oldParent *inode, oldName string
node.setParent(newParent) node.setParent(newParent)
} }
func (me *PathFileSystemConnector) unlinkUpdate(parent *inode, name string) { func (me *FileSystemConnector) unlinkUpdate(parent *inode, name string) {
defer me.verify() defer me.verify()
me.lock.Lock() me.lock.Lock()
defer me.lock.Unlock() defer me.lock.Unlock()
...@@ -344,7 +344,7 @@ func (me *PathFileSystemConnector) unlinkUpdate(parent *inode, name string) { ...@@ -344,7 +344,7 @@ func (me *PathFileSystemConnector) unlinkUpdate(parent *inode, name string) {
} }
// Walk the file system starting from the root. // Walk the file system starting from the root.
func (me *PathFileSystemConnector) findInode(fullPath string) *inode { func (me *FileSystemConnector) findInode(fullPath string) *inode {
fullPath = strings.TrimLeft(filepath.Clean(fullPath), "/") fullPath = strings.TrimLeft(filepath.Clean(fullPath), "/")
comps := strings.Split(fullPath, "/", -1) comps := strings.Split(fullPath, "/", -1)
...@@ -369,8 +369,8 @@ func (me *PathFileSystemConnector) findInode(fullPath string) *inode { ...@@ -369,8 +369,8 @@ func (me *PathFileSystemConnector) findInode(fullPath string) *inode {
// Below routines should not access inodePathMap(ByInode) directly, // Below routines should not access inodePathMap(ByInode) directly,
// and there need no locking. // and there need no locking.
func EmptyPathFileSystemConnector() (out *PathFileSystemConnector) { func EmptyFileSystemConnector() (out *FileSystemConnector) {
out = new(PathFileSystemConnector) out = new(FileSystemConnector)
out.inodeMap = make(map[uint64]*inode) out.inodeMap = make(map[uint64]*inode)
out.openFiles = make(map[uint64]interface{}) out.openFiles = make(map[uint64]interface{})
...@@ -387,8 +387,8 @@ func EmptyPathFileSystemConnector() (out *PathFileSystemConnector) { ...@@ -387,8 +387,8 @@ func EmptyPathFileSystemConnector() (out *PathFileSystemConnector) {
return out; return out;
} }
func NewPathFileSystemConnector(fs PathFileSystem) (out *PathFileSystemConnector) { func NewFileSystemConnector(fs FileSystem) (out *FileSystemConnector) {
out = EmptyPathFileSystemConnector() out = EmptyFileSystemConnector()
if code := out.Mount("/", fs); code != OK { if code := out.Mount("/", fs); code != OK {
panic("root mount failed.") panic("root mount failed.")
} }
...@@ -397,11 +397,11 @@ func NewPathFileSystemConnector(fs PathFileSystem) (out *PathFileSystemConnector ...@@ -397,11 +397,11 @@ func NewPathFileSystemConnector(fs PathFileSystem) (out *PathFileSystemConnector
return out return out
} }
func (me *PathFileSystemConnector) SetOptions(opts PathFileSystemConnectorOptions) { func (me *FileSystemConnector) SetOptions(opts FileSystemConnectorOptions) {
me.options = opts me.options = opts
} }
func (me *PathFileSystemConnector) Mount(mountPoint string, fs PathFileSystem) Status { func (me *FileSystemConnector) Mount(mountPoint string, fs FileSystem) Status {
var node *inode var node *inode
if mountPoint != "/" { if mountPoint != "/" {
...@@ -448,7 +448,7 @@ func (me *PathFileSystemConnector) Mount(mountPoint string, fs PathFileSystem) S ...@@ -448,7 +448,7 @@ func (me *PathFileSystemConnector) Mount(mountPoint string, fs PathFileSystem) S
return OK return OK
} }
func (me *PathFileSystemConnector) Unmount(path string) Status { func (me *FileSystemConnector) Unmount(path string) Status {
node := me.findInode(path) node := me.findInode(path)
if node == nil { if node == nil {
panic(path) panic(path)
...@@ -489,32 +489,32 @@ func (me *PathFileSystemConnector) Unmount(path string) Status { ...@@ -489,32 +489,32 @@ func (me *PathFileSystemConnector) Unmount(path string) Status {
return OK return OK
} }
func (me *PathFileSystemConnector) GetPath(nodeid uint64) (path string, mount *mountData, node *inode) { func (me *FileSystemConnector) GetPath(nodeid uint64) (path string, mount *mountData, node *inode) {
n := me.getInodeData(nodeid) n := me.getInodeData(nodeid)
p, m := n.GetPath() p, m := n.GetPath()
return p, m, n return p, m, n
} }
func (me *PathFileSystemConnector) Init(h *InHeader, input *InitIn) (*InitOut, Status) { func (me *FileSystemConnector) Init(h *InHeader, input *InitIn) (*InitOut, Status) {
// TODO ? // TODO ?
return new(InitOut), OK return new(InitOut), OK
} }
func (me *PathFileSystemConnector) Destroy(h *InHeader, input *InitIn) { func (me *FileSystemConnector) Destroy(h *InHeader, input *InitIn) {
// TODO - umount all. // TODO - umount all.
} }
func (me *PathFileSystemConnector) Lookup(header *InHeader, name string) (out *EntryOut, status Status) { func (me *FileSystemConnector) Lookup(header *InHeader, name string) (out *EntryOut, status Status) {
parent := me.getInodeData(header.NodeId) parent := me.getInodeData(header.NodeId)
return me.internalLookup(parent, name, 1) return me.internalLookup(parent, name, 1)
} }
func (me *PathFileSystemConnector) internalLookup(parent *inode, name string, lookupCount int) (out *EntryOut, status Status) { func (me *FileSystemConnector) internalLookup(parent *inode, name string, lookupCount int) (out *EntryOut, status Status) {
out, status, _ = me.internalLookupWithNode(parent, name, lookupCount) out, status, _ = me.internalLookupWithNode(parent, name, lookupCount)
return out, status return out, status
} }
func (me *PathFileSystemConnector) internalLookupWithNode(parent *inode, name string, lookupCount int) (out *EntryOut, status Status, node *inode) { func (me *FileSystemConnector) internalLookupWithNode(parent *inode, name string, lookupCount int) (out *EntryOut, status Status, node *inode) {
// TODO - fuse.c has special case code for name == "." and // TODO - fuse.c has special case code for name == "." and
// "..", those lookups happen if FUSE_EXPORT_SUPPORT is set in // "..", those lookups happen if FUSE_EXPORT_SUPPORT is set in
// Init. // Init.
...@@ -549,11 +549,11 @@ func (me *PathFileSystemConnector) internalLookupWithNode(parent *inode, name st ...@@ -549,11 +549,11 @@ func (me *PathFileSystemConnector) internalLookupWithNode(parent *inode, name st
return out, OK, data return out, OK, data
} }
func (me *PathFileSystemConnector) Forget(h *InHeader, input *ForgetIn) { func (me *FileSystemConnector) Forget(h *InHeader, input *ForgetIn) {
me.forgetUpdate(h.NodeId, int(input.Nlookup)) me.forgetUpdate(h.NodeId, int(input.Nlookup))
} }
func (me *PathFileSystemConnector) GetAttr(header *InHeader, input *GetAttrIn) (out *AttrOut, code Status) { func (me *FileSystemConnector) GetAttr(header *InHeader, input *GetAttrIn) (out *AttrOut, code Status) {
// TODO - do something intelligent with input.Fh. // TODO - do something intelligent with input.Fh.
fullPath, mount, _ := me.GetPath(header.NodeId) fullPath, mount, _ := me.GetPath(header.NodeId)
if mount == nil { if mount == nil {
...@@ -572,7 +572,7 @@ func (me *PathFileSystemConnector) GetAttr(header *InHeader, input *GetAttrIn) ( ...@@ -572,7 +572,7 @@ func (me *PathFileSystemConnector) GetAttr(header *InHeader, input *GetAttrIn) (
return out, OK return out, OK
} }
func (me *PathFileSystemConnector) OpenDir(header *InHeader, input *OpenIn) (flags uint32, handle uint64, status Status) { func (me *FileSystemConnector) OpenDir(header *InHeader, input *OpenIn) (flags uint32, handle uint64, status Status) {
fullPath, mount, node := me.GetPath(header.NodeId) fullPath, mount, node := me.GetPath(header.NodeId)
if mount == nil { if mount == nil {
return 0, 0, ENOENT return 0, 0, ENOENT
...@@ -591,7 +591,7 @@ func (me *PathFileSystemConnector) OpenDir(header *InHeader, input *OpenIn) (fla ...@@ -591,7 +591,7 @@ func (me *PathFileSystemConnector) OpenDir(header *InHeader, input *OpenIn) (fla
return 0, h, OK return 0, h, OK
} }
func (me *PathFileSystemConnector) ReadDir(header *InHeader, input *ReadIn) (*DirEntryList, Status) { func (me *FileSystemConnector) ReadDir(header *InHeader, input *ReadIn) (*DirEntryList, Status) {
d := me.getDir(input.Fh) d := me.getDir(input.Fh)
de, code := d.ReadDir(input) de, code := d.ReadDir(input)
if code != OK { if code != OK {
...@@ -600,7 +600,7 @@ func (me *PathFileSystemConnector) ReadDir(header *InHeader, input *ReadIn) (*Di ...@@ -600,7 +600,7 @@ func (me *PathFileSystemConnector) ReadDir(header *InHeader, input *ReadIn) (*Di
return de, OK return de, OK
} }
func (me *PathFileSystemConnector) Open(header *InHeader, input *OpenIn) (flags uint32, handle uint64, status Status) { func (me *FileSystemConnector) Open(header *InHeader, input *OpenIn) (flags uint32, handle uint64, status Status) {
fullPath, mount, node := me.GetPath(header.NodeId) fullPath, mount, node := me.GetPath(header.NodeId)
if mount == nil { if mount == nil {
return 0, 0, ENOENT return 0, 0, ENOENT
...@@ -616,7 +616,7 @@ func (me *PathFileSystemConnector) Open(header *InHeader, input *OpenIn) (flags ...@@ -616,7 +616,7 @@ func (me *PathFileSystemConnector) Open(header *InHeader, input *OpenIn) (flags
return 0, h, OK return 0, h, OK
} }
func (me *PathFileSystemConnector) SetAttr(header *InHeader, input *SetAttrIn) (out *AttrOut, code Status) { func (me *FileSystemConnector) SetAttr(header *InHeader, input *SetAttrIn) (out *AttrOut, code Status) {
var err Status = OK var err Status = OK
// TODO - support Fh. (FSetAttr/FGetAttr/FTruncate.) // TODO - support Fh. (FSetAttr/FGetAttr/FTruncate.)
...@@ -652,7 +652,7 @@ func (me *PathFileSystemConnector) SetAttr(header *InHeader, input *SetAttrIn) ( ...@@ -652,7 +652,7 @@ func (me *PathFileSystemConnector) SetAttr(header *InHeader, input *SetAttrIn) (
return me.GetAttr(header, new(GetAttrIn)) return me.GetAttr(header, new(GetAttrIn))
} }
func (me *PathFileSystemConnector) Readlink(header *InHeader) (out []byte, code Status) { func (me *FileSystemConnector) Readlink(header *InHeader) (out []byte, code Status) {
fullPath, mount, _ := me.GetPath(header.NodeId) fullPath, mount, _ := me.GetPath(header.NodeId)
if mount == nil { if mount == nil {
return nil, ENOENT return nil, ENOENT
...@@ -661,7 +661,7 @@ func (me *PathFileSystemConnector) Readlink(header *InHeader) (out []byte, code ...@@ -661,7 +661,7 @@ func (me *PathFileSystemConnector) Readlink(header *InHeader) (out []byte, code
return bytes.NewBufferString(val).Bytes(), err return bytes.NewBufferString(val).Bytes(), err
} }
func (me *PathFileSystemConnector) Mknod(header *InHeader, input *MknodIn, name string) (out *EntryOut, code Status) { func (me *FileSystemConnector) Mknod(header *InHeader, input *MknodIn, name string) (out *EntryOut, code Status) {
fullPath, mount, node := me.GetPath(header.NodeId) fullPath, mount, node := me.GetPath(header.NodeId)
if mount == nil { if mount == nil {
return nil, ENOENT return nil, ENOENT
...@@ -674,7 +674,7 @@ func (me *PathFileSystemConnector) Mknod(header *InHeader, input *MknodIn, name ...@@ -674,7 +674,7 @@ func (me *PathFileSystemConnector) Mknod(header *InHeader, input *MknodIn, name
return me.internalLookup(node, name, 1) return me.internalLookup(node, name, 1)
} }
func (me *PathFileSystemConnector) Mkdir(header *InHeader, input *MkdirIn, name string) (out *EntryOut, code Status) { func (me *FileSystemConnector) Mkdir(header *InHeader, input *MkdirIn, name string) (out *EntryOut, code Status) {
fullPath, mount, parent := me.GetPath(header.NodeId) fullPath, mount, parent := me.GetPath(header.NodeId)
if mount == nil { if mount == nil {
return nil, ENOENT return nil, ENOENT
...@@ -686,7 +686,7 @@ func (me *PathFileSystemConnector) Mkdir(header *InHeader, input *MkdirIn, name ...@@ -686,7 +686,7 @@ func (me *PathFileSystemConnector) Mkdir(header *InHeader, input *MkdirIn, name
return out, code return out, code
} }
func (me *PathFileSystemConnector) Unlink(header *InHeader, name string) (code Status) { func (me *FileSystemConnector) Unlink(header *InHeader, name string) (code Status) {
fullPath, mount, parent := me.GetPath(header.NodeId) fullPath, mount, parent := me.GetPath(header.NodeId)
if mount == nil { if mount == nil {
return ENOENT return ENOENT
...@@ -699,7 +699,7 @@ func (me *PathFileSystemConnector) Unlink(header *InHeader, name string) (code S ...@@ -699,7 +699,7 @@ func (me *PathFileSystemConnector) Unlink(header *InHeader, name string) (code S
return code return code
} }
func (me *PathFileSystemConnector) Rmdir(header *InHeader, name string) (code Status) { func (me *FileSystemConnector) Rmdir(header *InHeader, name string) (code Status) {
fullPath, mount, parent := me.GetPath(header.NodeId) fullPath, mount, parent := me.GetPath(header.NodeId)
if mount == nil { if mount == nil {
return ENOENT return ENOENT
...@@ -711,7 +711,7 @@ func (me *PathFileSystemConnector) Rmdir(header *InHeader, name string) (code St ...@@ -711,7 +711,7 @@ func (me *PathFileSystemConnector) Rmdir(header *InHeader, name string) (code St
return code return code
} }
func (me *PathFileSystemConnector) Symlink(header *InHeader, pointedTo string, linkName string) (out *EntryOut, code Status) { func (me *FileSystemConnector) Symlink(header *InHeader, pointedTo string, linkName string) (out *EntryOut, code Status) {
fullPath, mount, parent := me.GetPath(header.NodeId) fullPath, mount, parent := me.GetPath(header.NodeId)
if mount == nil { if mount == nil {
return nil, ENOENT return nil, ENOENT
...@@ -725,7 +725,7 @@ func (me *PathFileSystemConnector) Symlink(header *InHeader, pointedTo string, l ...@@ -725,7 +725,7 @@ func (me *PathFileSystemConnector) Symlink(header *InHeader, pointedTo string, l
return out, code return out, code
} }
func (me *PathFileSystemConnector) Rename(header *InHeader, input *RenameIn, oldName string, newName string) (code Status) { func (me *FileSystemConnector) Rename(header *InHeader, input *RenameIn, oldName string, newName string) (code Status) {
oldPath, oldMount, oldParent := me.GetPath(header.NodeId) oldPath, oldMount, oldParent := me.GetPath(header.NodeId)
newPath, mount, newParent := me.GetPath(input.Newdir) newPath, mount, newParent := me.GetPath(input.Newdir)
if mount == nil || oldMount == nil { if mount == nil || oldMount == nil {
...@@ -751,7 +751,7 @@ func (me *PathFileSystemConnector) Rename(header *InHeader, input *RenameIn, old ...@@ -751,7 +751,7 @@ func (me *PathFileSystemConnector) Rename(header *InHeader, input *RenameIn, old
return code return code
} }
func (me *PathFileSystemConnector) Link(header *InHeader, input *LinkIn, filename string) (out *EntryOut, code Status) { func (me *FileSystemConnector) Link(header *InHeader, input *LinkIn, filename string) (out *EntryOut, code Status) {
orig, mount, _ := me.GetPath(input.Oldnodeid) orig, mount, _ := me.GetPath(input.Oldnodeid)
newName, newMount, newParent := me.GetPath(header.NodeId) newName, newMount, newParent := me.GetPath(header.NodeId)
...@@ -771,7 +771,7 @@ func (me *PathFileSystemConnector) Link(header *InHeader, input *LinkIn, filenam ...@@ -771,7 +771,7 @@ func (me *PathFileSystemConnector) Link(header *InHeader, input *LinkIn, filenam
return me.internalLookup(newParent, filename, 1) return me.internalLookup(newParent, filename, 1)
} }
func (me *PathFileSystemConnector) Access(header *InHeader, input *AccessIn) (code Status) { func (me *FileSystemConnector) Access(header *InHeader, input *AccessIn) (code Status) {
p, mount, _ := me.GetPath(header.NodeId) p, mount, _ := me.GetPath(header.NodeId)
if mount == nil { if mount == nil {
return ENOENT return ENOENT
...@@ -779,7 +779,7 @@ func (me *PathFileSystemConnector) Access(header *InHeader, input *AccessIn) (co ...@@ -779,7 +779,7 @@ func (me *PathFileSystemConnector) Access(header *InHeader, input *AccessIn) (co
return mount.fs.Access(p, input.Mask) return mount.fs.Access(p, input.Mask)
} }
func (me *PathFileSystemConnector) Create(header *InHeader, input *CreateIn, name string) (flags uint32, h uint64, out *EntryOut, code Status) { func (me *FileSystemConnector) Create(header *InHeader, input *CreateIn, name string) (flags uint32, h uint64, out *EntryOut, code Status) {
directory, mount, parent := me.GetPath(header.NodeId) directory, mount, parent := me.GetPath(header.NodeId)
if mount == nil { if mount == nil {
return 0, 0, nil, ENOENT return 0, 0, nil, ENOENT
...@@ -795,26 +795,26 @@ func (me *PathFileSystemConnector) Create(header *InHeader, input *CreateIn, nam ...@@ -795,26 +795,26 @@ func (me *PathFileSystemConnector) Create(header *InHeader, input *CreateIn, nam
return 0, me.registerFile(inode, f), out, code return 0, me.registerFile(inode, f), out, code
} }
func (me *PathFileSystemConnector) Release(header *InHeader, input *ReleaseIn) { func (me *FileSystemConnector) Release(header *InHeader, input *ReleaseIn) {
node := me.getInodeData(header.NodeId) node := me.getInodeData(header.NodeId)
f := me.unregisterFile(node, input.Fh).(File) f := me.unregisterFile(node, input.Fh).(File)
f.Release() f.Release()
me.considerDropInode(node) me.considerDropInode(node)
} }
func (me *PathFileSystemConnector) ReleaseDir(header *InHeader, input *ReleaseIn) { func (me *FileSystemConnector) ReleaseDir(header *InHeader, input *ReleaseIn) {
node := me.getInodeData(header.NodeId) node := me.getInodeData(header.NodeId)
d := me.unregisterFile(node, input.Fh).(RawDir) d := me.unregisterFile(node, input.Fh).(RawDir)
d.Release() d.Release()
me.considerDropInode(node) me.considerDropInode(node)
} }
func (me *PathFileSystemConnector) FsyncDir(header *InHeader, input *FsyncIn) (code Status) { func (me *FileSystemConnector) FsyncDir(header *InHeader, input *FsyncIn) (code Status) {
// What the heck is FsyncDir supposed to do? // What the heck is FsyncDir supposed to do?
return OK return OK
} }
func (me *PathFileSystemConnector) GetXAttr(header *InHeader, attribute string) (data []byte, code Status) { func (me *FileSystemConnector) GetXAttr(header *InHeader, attribute string) (data []byte, code Status) {
path, mount, _ := me.GetPath(header.NodeId) path, mount, _ := me.GetPath(header.NodeId)
if mount == nil { if mount == nil {
return nil, ENOENT return nil, ENOENT
...@@ -824,7 +824,7 @@ func (me *PathFileSystemConnector) GetXAttr(header *InHeader, attribute string) ...@@ -824,7 +824,7 @@ func (me *PathFileSystemConnector) GetXAttr(header *InHeader, attribute string)
return data, code return data, code
} }
func (me *PathFileSystemConnector) RemoveXAttr(header *InHeader, attr string) Status { func (me *FileSystemConnector) RemoveXAttr(header *InHeader, attr string) Status {
path, mount, _ := me.GetPath(header.NodeId) path, mount, _ := me.GetPath(header.NodeId)
if mount == nil { if mount == nil {
return ENOENT return ENOENT
...@@ -833,7 +833,7 @@ func (me *PathFileSystemConnector) RemoveXAttr(header *InHeader, attr string) St ...@@ -833,7 +833,7 @@ func (me *PathFileSystemConnector) RemoveXAttr(header *InHeader, attr string) St
return mount.fs.RemoveXAttr(path, attr) return mount.fs.RemoveXAttr(path, attr)
} }
func (me *PathFileSystemConnector) SetXAttr(header *InHeader, input *SetXAttrIn, attr string, data []byte) Status { func (me *FileSystemConnector) SetXAttr(header *InHeader, input *SetXAttrIn, attr string, data []byte) Status {
path, mount, _ := me.GetPath(header.NodeId) path, mount, _ := me.GetPath(header.NodeId)
if mount == nil { if mount == nil {
return ENOENT return ENOENT
...@@ -842,7 +842,7 @@ func (me *PathFileSystemConnector) SetXAttr(header *InHeader, input *SetXAttrIn, ...@@ -842,7 +842,7 @@ func (me *PathFileSystemConnector) SetXAttr(header *InHeader, input *SetXAttrIn,
return mount.fs.SetXAttr(path, attr, data, int(input.Flags)) return mount.fs.SetXAttr(path, attr, data, int(input.Flags))
} }
func (me *PathFileSystemConnector) ListXAttr(header *InHeader) (data []byte, code Status) { func (me *FileSystemConnector) ListXAttr(header *InHeader) (data []byte, code Status) {
path, mount, _ := me.GetPath(header.NodeId) path, mount, _ := me.GetPath(header.NodeId)
if mount == nil { if mount == nil {
return nil, ENOENT return nil, ENOENT
...@@ -862,12 +862,12 @@ func (me *PathFileSystemConnector) ListXAttr(header *InHeader) (data []byte, cod ...@@ -862,12 +862,12 @@ func (me *PathFileSystemConnector) ListXAttr(header *InHeader) (data []byte, cod
return b.Bytes(), code return b.Bytes(), code
} }
func (me *PathFileSystemConnector) Write(input *WriteIn, data []byte) (written uint32, code Status) { func (me *FileSystemConnector) Write(input *WriteIn, data []byte) (written uint32, code Status) {
f := me.getFile(input.Fh).(File) f := me.getFile(input.Fh).(File)
return f.Write(input, data) return f.Write(input, data)
} }
func (me *PathFileSystemConnector) Read(input *ReadIn, bp *BufferPool) ([]byte, Status) { func (me *FileSystemConnector) Read(input *ReadIn, bp *BufferPool) ([]byte, Status) {
f := me.getFile(input.Fh) f := me.getFile(input.Fh)
return f.Read(input, bp) return f.Read(input, bp)
} }
...@@ -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 // TimingFileSystem is a wrapper to collect timings for a FileSystem
type TimingPathFileSystem struct { type TimingFileSystem struct {
WrappingPathFileSystem WrappingFileSystem
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 NewTimingFileSystem(fs FileSystem) *TimingFileSystem {
t := new(TimingPathFileSystem) t := new(TimingFileSystem)
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 *TimingFileSystem) 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 *TimingFileSystem) 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 *TimingFileSystem) 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 *TimingFileSystem) 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 *TimingFileSystem) 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 *TimingFileSystem) GetXAttr(name string, attr string) ([]byte, Status) {
defer me.startTimer("GetXAttr", name)() defer me.startTimer("GetXAttr", name)()
return me.Original.GetXAttr(name, attr) return me.Original.GetXAttr(name, attr)
} }
func (me *TimingPathFileSystem) SetXAttr(name string, attr string, data []byte, flags int) Status { func (me *TimingFileSystem) SetXAttr(name string, attr string, data []byte, flags int) Status {
defer me.startTimer("SetXAttr", name)() defer me.startTimer("SetXAttr", name)()
return me.Original.SetXAttr(name, attr, data, flags) return me.Original.SetXAttr(name, attr, data, flags)
} }
func (me *TimingPathFileSystem) ListXAttr(name string) ([]string, Status) { func (me *TimingFileSystem) ListXAttr(name string) ([]string, Status) {
defer me.startTimer("ListXAttr", name)() defer me.startTimer("ListXAttr", name)()
return me.Original.ListXAttr(name) return me.Original.ListXAttr(name)
} }
func (me *TimingPathFileSystem) RemoveXAttr(name string, attr string) Status { func (me *TimingFileSystem) RemoveXAttr(name string, attr string) Status {
defer me.startTimer("RemoveXAttr", name)() defer me.startTimer("RemoveXAttr", name)()
return me.Original.RemoveXAttr(name, attr) return me.Original.RemoveXAttr(name, attr)
} }
func (me *TimingPathFileSystem) Readlink(name string) (string, Status) { func (me *TimingFileSystem) Readlink(name string) (string, Status) {
defer me.startTimer("Readlink", name)() defer me.startTimer("Readlink", name)()
return me.Original.Readlink(name) return me.Original.Readlink(name)
} }
func (me *TimingPathFileSystem) Mknod(name string, mode uint32, dev uint32) Status { func (me *TimingFileSystem) Mknod(name string, mode uint32, dev uint32) Status {
defer me.startTimer("Mknod", name)() defer me.startTimer("Mknod", name)()
return me.Original.Mknod(name, mode, dev) return me.Original.Mknod(name, mode, dev)
} }
func (me *TimingPathFileSystem) Mkdir(name string, mode uint32) Status { func (me *TimingFileSystem) Mkdir(name string, mode uint32) Status {
defer me.startTimer("Mkdir", name)() defer me.startTimer("Mkdir", name)()
return me.Original.Mkdir(name, mode) return me.Original.Mkdir(name, mode)
} }
func (me *TimingPathFileSystem) Unlink(name string) (code Status) { func (me *TimingFileSystem) Unlink(name string) (code Status) {
defer me.startTimer("Unlink", name)() defer me.startTimer("Unlink", name)()
return me.Original.Unlink(name) return me.Original.Unlink(name)
} }
func (me *TimingPathFileSystem) Rmdir(name string) (code Status) { func (me *TimingFileSystem) Rmdir(name string) (code Status) {
defer me.startTimer("Rmdir", name)() defer me.startTimer("Rmdir", name)()
return me.Original.Rmdir(name) return me.Original.Rmdir(name)
} }
func (me *TimingPathFileSystem) Symlink(value string, linkName string) (code Status) { func (me *TimingFileSystem) Symlink(value string, linkName string) (code Status) {
defer me.startTimer("Symlink", linkName)() defer me.startTimer("Symlink", linkName)()
return me.Original.Symlink(value, linkName) return me.Original.Symlink(value, linkName)
} }
func (me *TimingPathFileSystem) Rename(oldName string, newName string) (code Status) { func (me *TimingFileSystem) Rename(oldName string, newName string) (code Status) {
defer me.startTimer("Rename", oldName)() defer me.startTimer("Rename", oldName)()
return me.Original.Rename(oldName, newName) return me.Original.Rename(oldName, newName)
} }
func (me *TimingPathFileSystem) Link(oldName string, newName string) (code Status) { func (me *TimingFileSystem) Link(oldName string, newName string) (code Status) {
defer me.startTimer("Link", newName)() defer me.startTimer("Link", newName)()
return me.Original.Link(oldName, newName) return me.Original.Link(oldName, newName)
} }
func (me *TimingPathFileSystem) Chmod(name string, mode uint32) (code Status) { func (me *TimingFileSystem) Chmod(name string, mode uint32) (code Status) {
defer me.startTimer("Chmod", name)() defer me.startTimer("Chmod", name)()
return me.Original.Chmod(name, mode) return me.Original.Chmod(name, mode)
} }
func (me *TimingPathFileSystem) Chown(name string, uid uint32, gid uint32) (code Status) { func (me *TimingFileSystem) Chown(name string, uid uint32, gid uint32) (code Status) {
defer me.startTimer("Chown", name)() defer me.startTimer("Chown", name)()
return me.Original.Chown(name, uid, gid) return me.Original.Chown(name, uid, gid)
} }
func (me *TimingPathFileSystem) Truncate(name string, offset uint64) (code Status) { func (me *TimingFileSystem) Truncate(name string, offset uint64) (code Status) {
defer me.startTimer("Truncate", name)() defer me.startTimer("Truncate", name)()
return me.Original.Truncate(name, offset) return me.Original.Truncate(name, offset)
} }
func (me *TimingPathFileSystem) Open(name string, flags uint32) (file File, code Status) { func (me *TimingFileSystem) Open(name string, flags uint32) (file File, code Status) {
defer me.startTimer("Open", name)() defer me.startTimer("Open", name)()
return me.Original.Open(name, flags) return me.Original.Open(name, flags)
} }
func (me *TimingPathFileSystem) OpenDir(name string) (stream chan DirEntry, status Status) { func (me *TimingFileSystem) OpenDir(name string) (stream chan DirEntry, status Status) {
defer me.startTimer("OpenDir", name)() defer me.startTimer("OpenDir", name)()
return me.Original.OpenDir(name) return me.Original.OpenDir(name)
} }
func (me *TimingPathFileSystem) Mount(conn *PathFileSystemConnector) Status { func (me *TimingFileSystem) Mount(conn *FileSystemConnector) 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 *TimingFileSystem) 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 *TimingFileSystem) Access(name string, mode uint32) (code Status) {
defer me.startTimer("Access", name)() defer me.startTimer("Access", name)()
return me.Original.Access(name, mode) return me.Original.Access(name, mode)
} }
func (me *TimingPathFileSystem) Create(name string, flags uint32, mode uint32) (file File, code Status) { func (me *TimingFileSystem) Create(name string, flags uint32, mode uint32) (file File, code Status) {
defer me.startTimer("Create", name)() defer me.startTimer("Create", name)()
return me.Original.Create(name, flags, mode) return me.Original.Create(name, flags, mode)
} }
func (me *TimingPathFileSystem) Utimens(name string, AtimeNs uint64, CtimeNs uint64) (code Status) { func (me *TimingFileSystem) Utimens(name string, AtimeNs uint64, CtimeNs uint64) (code Status) {
defer me.startTimer("Utimens", name)() defer me.startTimer("Utimens", name)()
return me.Original.Utimens(name, AtimeNs, CtimeNs) return me.Original.Utimens(name, AtimeNs, CtimeNs)
} }
...@@ -498,7 +498,7 @@ type NotifyInvalEntryOut struct { ...@@ -498,7 +498,7 @@ type NotifyInvalEntryOut struct {
// //
// Typically, each call happens in its own goroutine, so any global // Typically, each call happens in its own goroutine, so any global
// data should be made thread-safe. Unless you really know what you // data should be made thread-safe. Unless you really know what you
// are doing, you should not implement this, but PathFileSystem below; // are doing, you should not implement this, but FileSystem below;
// the details of getting interactions with open files, renames, and // the details of getting interactions with open files, renames, and
// threading right etc. are somewhat tricky and not very interesting. // threading right etc. are somewhat tricky and not very interesting.
type RawFileSystem interface { type RawFileSystem interface {
...@@ -561,7 +561,7 @@ type RawDir interface { ...@@ -561,7 +561,7 @@ type RawDir interface {
Release() Release()
} }
type PathFileSystem interface { type FileSystem 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
...@@ -586,7 +586,7 @@ type PathFileSystem interface { ...@@ -586,7 +586,7 @@ type PathFileSystem interface {
OpenDir(name string) (stream chan DirEntry, code Status) OpenDir(name string) (stream chan DirEntry, code Status)
// TODO - what is a good interface? // TODO - what is a good interface?
Mount(connector *PathFileSystemConnector) Status Mount(connector *FileSystemConnector) Status
Unmount() Unmount()
Access(name string, mode uint32) (code Status) Access(name string, mode uint32) (code Status)
...@@ -599,6 +599,6 @@ type PathFileSystem interface { ...@@ -599,6 +599,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 DefaultFileSystem struct{}
type DefaultFile struct{} type DefaultFile struct{}
type DefaultRawFileSystem struct{} type DefaultRawFileSystem struct{}
package fuse package fuse
type WrappingPathFileSystem struct { type WrappingFileSystem 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 FileSystem
} }
func (me *WrappingPathFileSystem) GetAttr(name string) (*Attr, Status) { func (me *WrappingFileSystem) 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 *WrappingFileSystem) 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 *WrappingFileSystem) 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 *WrappingFileSystem) 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 *WrappingFileSystem) 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 *WrappingFileSystem) 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 *WrappingFileSystem) 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 *WrappingFileSystem) 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 *WrappingFileSystem) 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 *WrappingFileSystem) 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 *WrappingFileSystem) 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 *WrappingFileSystem) 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 File, code Status) { func (me *WrappingFileSystem) Open(name string, flags uint32) (file File, 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 *WrappingFileSystem) 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 *WrappingFileSystem) Mount(conn *FileSystemConnector) Status {
return me.Original.Mount(conn) return me.Original.Mount(conn)
} }
func (me *WrappingPathFileSystem) Unmount() { func (me *WrappingFileSystem) Unmount() {
me.Original.Unmount() me.Original.Unmount()
} }
func (me *WrappingPathFileSystem) Access(name string, mode uint32) (code Status) { func (me *WrappingFileSystem) 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 File, code Status) { func (me *WrappingFileSystem) Create(name string, flags uint32, mode uint32) (file File, 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 *WrappingFileSystem) 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 *WrappingFileSystem) 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 *WrappingFileSystem) 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 *WrappingFileSystem) 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 *WrappingFileSystem) RemoveXAttr(name string, attr string) Status {
return me.Original.RemoveXAttr(name, attr) return me.Original.RemoveXAttr(name, attr)
} }
......
...@@ -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 DefaultFileSystem
} }
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 := NewFileSystemConnector(NewLockingFileSystem(xfs))
mountPoint := MakeTempDir() mountPoint := MakeTempDir()
state := NewMountState(connector) state := NewMountState(connector)
......
...@@ -18,13 +18,13 @@ import ( ...@@ -18,13 +18,13 @@ 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.DefaultFileSystem
lock sync.RWMutex lock sync.RWMutex
knownFileSystems map[string]*UnionFs knownFileSystems map[string]*UnionFs
root string root string
connector *fuse.PathFileSystemConnector connector *fuse.FileSystemConnector
options *AutoUnionFsOptions options *AutoUnionFsOptions
} }
...@@ -41,7 +41,7 @@ func NewAutoUnionFs(directory string, options AutoUnionFsOptions) *AutoUnionFs { ...@@ -41,7 +41,7 @@ func NewAutoUnionFs(directory string, options AutoUnionFsOptions) *AutoUnionFs {
return a return a
} }
func (me *AutoUnionFs) Mount(connector *fuse.PathFileSystemConnector) fuse.Status { func (me *AutoUnionFs) Mount(connector *fuse.FileSystemConnector) fuse.Status {
me.connector = connector me.connector = connector
time.AfterFunc(0.1e9, func() { me.updateKnownFses() }) time.AfterFunc(0.1e9, func() { me.updateKnownFses() })
return fuse.OK return fuse.OK
......
...@@ -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.WrappingFileSystem
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.FileSystem) *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.DefaultFileSystem
branches []*fuse.LoopbackFileSystem branches []*fuse.LoopbackFileSystem
// The same, but as interfaces. // The same, but as interfaces.
fileSystems []fuse.PathFileSystem fileSystems []fuse.FileSystem
// 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.FileSystem(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 FileSystem.
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.FileSystem) {
ch, s := pfs.OpenDir(directory) ch, s := pfs.OpenDir(directory)
statuses[j] = s statuses[j] = s
for s == fuse.OK { for s == fuse.OK {
......
...@@ -40,7 +40,7 @@ func setup(t *testing.T) (workdir string, state *fuse.MountState) { ...@@ -40,7 +40,7 @@ func setup(t *testing.T) (workdir string, state *fuse.MountState) {
roots = append(roots, wd+"/ro") roots = append(roots, wd+"/ro")
ufs := NewUnionFs(roots, testOpts) ufs := NewUnionFs(roots, testOpts)
connector := fuse.NewPathFileSystemConnector(ufs) connector := fuse.NewFileSystemConnector(ufs)
state = fuse.NewMountState(connector) state = fuse.NewMountState(connector)
state.Mount(wd + "/mount") state.Mount(wd + "/mount")
......
...@@ -68,16 +68,16 @@ func (me *zipCreateFile) Write(input *fuse.WriteIn, nameBytes []byte) (uint32, f ...@@ -68,16 +68,16 @@ func (me *zipCreateFile) Write(input *fuse.WriteIn, nameBytes []byte) (uint32, f
//////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////
// MultiZipFs is a path filesystem that mounts zipfiles. It needs a // MultiZipFs is a path filesystem that mounts zipfiles. It needs a
// reference to the PathFileSystemConnector to be able to execute // reference to the FileSystemConnector to be able to execute
// mounts. // mounts.
type MultiZipFs struct { type MultiZipFs struct {
Connector *fuse.PathFileSystemConnector Connector *fuse.FileSystemConnector
lock sync.RWMutex lock sync.RWMutex
zips map[string]*ZipArchiveFileSystem zips map[string]*ZipArchiveFileSystem
pendingZips map[string]bool pendingZips map[string]bool
zipFileNames map[string]string zipFileNames map[string]string
fuse.DefaultPathFileSystem fuse.DefaultFileSystem
} }
func NewMultiZipFs() *MultiZipFs { func NewMultiZipFs() *MultiZipFs {
...@@ -85,7 +85,7 @@ func NewMultiZipFs() *MultiZipFs { ...@@ -85,7 +85,7 @@ func NewMultiZipFs() *MultiZipFs {
m.zips = make(map[string]*ZipArchiveFileSystem) m.zips = make(map[string]*ZipArchiveFileSystem)
m.pendingZips = make(map[string]bool) m.pendingZips = make(map[string]bool)
m.zipFileNames = make(map[string]string) m.zipFileNames = make(map[string]string)
m.Connector = fuse.NewPathFileSystemConnector(m) m.Connector = fuse.NewFileSystemConnector(m)
return m return m
} }
......
...@@ -75,7 +75,7 @@ type ZipArchiveFileSystem struct { ...@@ -75,7 +75,7 @@ type ZipArchiveFileSystem struct {
tree *ZipDirTree tree *ZipDirTree
ZipFileName string ZipFileName string
fuse.DefaultPathFileSystem fuse.DefaultFileSystem
} }
func zipFilesToTree(files []*zip.File) *ZipDirTree { func zipFilesToTree(files []*zip.File) *ZipDirTree {
......
...@@ -11,7 +11,7 @@ func TestZipFs(t *testing.T) { ...@@ -11,7 +11,7 @@ func TestZipFs(t *testing.T) {
CheckSuccess(err) CheckSuccess(err)
zfs := NewZipArchiveFileSystem(wd + "/test.zip") zfs := NewZipArchiveFileSystem(wd + "/test.zip")
connector := fuse.NewPathFileSystemConnector(zfs) connector := fuse.NewFileSystemConnector(zfs)
mountPoint := fuse.MakeTempDir() mountPoint := fuse.MakeTempDir()
state := fuse.NewMountState(connector) state := fuse.NewMountState(connector)
......
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