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
} }
......
This diff is collapsed.
...@@ -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)
} }
This diff is collapsed.
...@@ -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{}
This diff is collapsed.
...@@ -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