Commit 9c09165d authored by Han-Wen Nienhuys's avatar Han-Wen Nienhuys

Rename Mount/Unmount to OnMount/OnUnmount.

Add PathNodeFs.Mount/Unmount methods.
parent f9ab0286
...@@ -17,8 +17,8 @@ import ( ...@@ -17,8 +17,8 @@ import (
// to represent fits in memory: you can construct FsNode at mount // to represent fits in memory: you can construct FsNode at mount
// time, and the filesystem will be ready. // time, and the filesystem will be ready.
type NodeFileSystem interface { type NodeFileSystem interface {
Unmount() OnUnmount()
Mount(conn *FileSystemConnector) OnMount(conn *FileSystemConnector)
StatFs() *StatfsOut StatFs() *StatfsOut
Root() FsNode Root() FsNode
} }
...@@ -104,8 +104,8 @@ type FileSystem interface { ...@@ -104,8 +104,8 @@ type FileSystem interface {
SetXAttr(name string, attr string, data []byte, flags int, context *Context) Status SetXAttr(name string, attr string, data []byte, flags int, context *Context) Status
// Called after mount. // Called after mount.
Mount(nodeFs *PathNodeFs, connector *FileSystemConnector) OnMount(nodeFs *PathNodeFs)
Unmount() OnUnmount()
// File handling. If opening for writing, the file's mtime // File handling. If opening for writing, the file's mtime
// should be updated too. // should be updated too.
......
...@@ -81,10 +81,10 @@ func (me *DefaultFileSystem) OpenDir(name string, context *Context) (stream chan ...@@ -81,10 +81,10 @@ func (me *DefaultFileSystem) OpenDir(name string, context *Context) (stream chan
return nil, ENOSYS return nil, ENOSYS
} }
func (me *DefaultFileSystem) Mount(nodeFs *PathNodeFs, conn *FileSystemConnector) { func (me *DefaultFileSystem) OnMount(nodeFs *PathNodeFs) {
} }
func (me *DefaultFileSystem) Unmount() { func (me *DefaultFileSystem) OnUnmount() {
} }
func (me *DefaultFileSystem) Access(name string, mode uint32, context *Context) (code Status) { func (me *DefaultFileSystem) Access(name string, mode uint32, context *Context) (code Status) {
......
...@@ -8,10 +8,11 @@ type DefaultNodeFileSystem struct { ...@@ -8,10 +8,11 @@ type DefaultNodeFileSystem struct {
root DefaultFsNode root DefaultFsNode
} }
func (me *DefaultNodeFileSystem) Unmount() { func (me *DefaultNodeFileSystem) OnUnmount() {
} }
func (me *DefaultNodeFileSystem) Mount(conn *FileSystemConnector) { func (me *DefaultNodeFileSystem) OnMount(conn *FileSystemConnector) {
} }
func (me *DefaultNodeFileSystem) StatFs() *StatfsOut { func (me *DefaultNodeFileSystem) StatFs() *StatfsOut {
......
...@@ -225,7 +225,7 @@ func (me *FileSystemConnector) findInode(fullPath string) *Inode { ...@@ -225,7 +225,7 @@ func (me *FileSystemConnector) findInode(fullPath string) *Inode {
func (me *FileSystemConnector) MountRoot(nodeFs NodeFileSystem, opts *FileSystemOptions) { func (me *FileSystemConnector) MountRoot(nodeFs NodeFileSystem, opts *FileSystemOptions) {
me.rootNode.mountFs(nodeFs, opts) me.rootNode.mountFs(nodeFs, opts)
nodeFs.Mount(me) nodeFs.OnMount(me)
me.verify() me.verify()
} }
...@@ -270,8 +270,8 @@ func (me *FileSystemConnector) Mount(parent *Inode, name string, nodeFs NodeFile ...@@ -270,8 +270,8 @@ func (me *FileSystemConnector) Mount(parent *Inode, name string, nodeFs NodeFile
log.Println("Mount: ", nodeFs, "on subdir", name, log.Println("Mount: ", nodeFs, "on subdir", name,
"parent", parent.nodeId) "parent", parent.nodeId)
} }
nodeFs.Mount(me)
me.verify() me.verify()
nodeFs.OnMount(me)
return OK return OK
} }
...@@ -309,7 +309,7 @@ func (me *FileSystemConnector) Unmount(node *Inode) Status { ...@@ -309,7 +309,7 @@ func (me *FileSystemConnector) Unmount(node *Inode) Status {
parentNode.mounts[name] = nil, false parentNode.mounts[name] = nil, false
parentNode.children[name] = nil, false parentNode.children[name] = nil, false
mount.fs.Unmount() mount.fs.OnUnmount()
me.fsInit.EntryNotify(parentNode.nodeId, name) me.fsInit.EntryNotify(parentNode.nodeId, name)
......
...@@ -95,14 +95,14 @@ func (me *LockingFileSystem) OpenDir(name string, context *Context) (stream chan ...@@ -95,14 +95,14 @@ func (me *LockingFileSystem) OpenDir(name string, context *Context) (stream chan
return me.FileSystem.OpenDir(name, context) return me.FileSystem.OpenDir(name, context)
} }
func (me *LockingFileSystem) Mount(nodeFs *PathNodeFs, conn *FileSystemConnector) { func (me *LockingFileSystem) OnMount(nodeFs *PathNodeFs) {
defer me.locked()() defer me.locked()()
me.FileSystem.Mount(nodeFs, conn) me.FileSystem.OnMount(nodeFs)
} }
func (me *LockingFileSystem) Unmount() { func (me *LockingFileSystem) OnUnmount() {
defer me.locked()() defer me.locked()()
me.FileSystem.Unmount() me.FileSystem.OnUnmount()
} }
func (me *LockingFileSystem) Access(name string, mode uint32, context *Context) (code Status) { func (me *LockingFileSystem) Access(name string, mode uint32, context *Context) (code Status) {
......
...@@ -114,14 +114,14 @@ func (me *LoggingFileSystem) OpenDir(name string, context *Context) (stream chan ...@@ -114,14 +114,14 @@ func (me *LoggingFileSystem) OpenDir(name string, context *Context) (stream chan
return me.FileSystem.OpenDir(name, context) return me.FileSystem.OpenDir(name, context)
} }
func (me *LoggingFileSystem) Mount(nodeFs *PathNodeFs, conn *FileSystemConnector) { func (me *LoggingFileSystem) OnMount(nodeFs *PathNodeFs) {
me.Print("Mount", "") me.Print("OnMount", "")
me.FileSystem.Mount(nodeFs, conn) me.FileSystem.OnMount(nodeFs)
} }
func (me *LoggingFileSystem) Unmount() { func (me *LoggingFileSystem) OnUnmount() {
me.Print("Unmount", "") me.Print("OnUnmount", "")
me.FileSystem.Unmount() me.FileSystem.OnUnmount()
} }
func (me *LoggingFileSystem) Access(name string, mode uint32, context *Context) (code Status) { func (me *LoggingFileSystem) Access(name string, mode uint32, context *Context) (code Status) {
......
...@@ -12,13 +12,23 @@ var _ = log.Println ...@@ -12,13 +12,23 @@ var _ = log.Println
type PathNodeFs struct { type PathNodeFs struct {
fs FileSystem fs FileSystem
root *pathInode root *pathInode
connector *FileSystemConnector
} }
func (me *PathNodeFs) Unmount() { func (me *PathNodeFs) Mount(parent *Inode, name string, nodeFs NodeFileSystem, opts *FileSystemOptions) Status {
return me.connector.Mount(parent, name, nodeFs, opts)
} }
func (me *PathNodeFs) Mount(conn *FileSystemConnector) { func (me *PathNodeFs) Unmount(node *Inode) Status {
me.fs.Mount(me, conn) return me.connector.Unmount(node)
}
func (me *PathNodeFs) OnUnmount() {
}
func (me *PathNodeFs) OnMount(conn *FileSystemConnector) {
me.connector = conn
me.fs.OnMount(me)
} }
func (me *PathNodeFs) StatFs() *StatfsOut { func (me *PathNodeFs) StatFs() *StatfsOut {
......
...@@ -69,12 +69,12 @@ func (me *ReadonlyFileSystem) OpenDir(name string, context *Context) (stream cha ...@@ -69,12 +69,12 @@ func (me *ReadonlyFileSystem) OpenDir(name string, context *Context) (stream cha
return me.FileSystem.OpenDir(name, context) return me.FileSystem.OpenDir(name, context)
} }
func (me *ReadonlyFileSystem) Mount(nodeFs *PathNodeFs, conn *FileSystemConnector) { func (me *ReadonlyFileSystem) OnMount(nodeFs *PathNodeFs) {
me.FileSystem.Mount(nodeFs, conn) me.FileSystem.OnMount(nodeFs)
} }
func (me *ReadonlyFileSystem) Unmount() { func (me *ReadonlyFileSystem) OnUnmount() {
me.FileSystem.Unmount() me.FileSystem.OnUnmount()
} }
func (me *ReadonlyFileSystem) Access(name string, mode uint32, context *Context) (code Status) { func (me *ReadonlyFileSystem) Access(name string, mode uint32, context *Context) (code Status) {
......
...@@ -196,15 +196,15 @@ func (me *SwitchFileSystem) OpenDir(name string, context *Context) (stream chan ...@@ -196,15 +196,15 @@ func (me *SwitchFileSystem) OpenDir(name string, context *Context) (stream chan
return fs.FileSystem.OpenDir(name, context) return fs.FileSystem.OpenDir(name, context)
} }
func (me *SwitchFileSystem) Mount(nodeFs *PathNodeFs, conn *FileSystemConnector) { func (me *SwitchFileSystem) OnMount(nodeFs *PathNodeFs) {
for _, fs := range me.fileSystems { for _, fs := range me.fileSystems {
fs.FileSystem.Mount(nodeFs, conn) fs.FileSystem.OnMount(nodeFs)
} }
} }
func (me *SwitchFileSystem) Unmount() { func (me *SwitchFileSystem) OnUnmount() {
for _, fs := range me.fileSystems { for _, fs := range me.fileSystems {
fs.FileSystem.Unmount() fs.FileSystem.OnUnmount()
} }
} }
......
...@@ -135,14 +135,14 @@ func (me *TimingFileSystem) OpenDir(name string, context *Context) (stream chan ...@@ -135,14 +135,14 @@ func (me *TimingFileSystem) OpenDir(name string, context *Context) (stream chan
return me.FileSystem.OpenDir(name, context) return me.FileSystem.OpenDir(name, context)
} }
func (me *TimingFileSystem) Mount(nodeFs *PathNodeFs, conn *FileSystemConnector) { func (me *TimingFileSystem) OnMount(nodeFs *PathNodeFs) {
defer me.startTimer("Mount", "")() defer me.startTimer("OnMount", "")()
me.FileSystem.Mount(nodeFs, conn) me.FileSystem.OnMount(nodeFs)
} }
func (me *TimingFileSystem) Unmount() { func (me *TimingFileSystem) OnUnmount() {
defer me.startTimer("Unmount", "")() defer me.startTimer("OnUnmount", "")()
me.FileSystem.Unmount() me.FileSystem.OnUnmount()
} }
func (me *TimingFileSystem) Access(name string, mode uint32, context *Context) (code Status) { func (me *TimingFileSystem) Access(name string, mode uint32, context *Context) (code Status) {
......
...@@ -31,7 +31,6 @@ type AutoUnionFs struct { ...@@ -31,7 +31,6 @@ type AutoUnionFs struct {
nameRootMap map[string]string nameRootMap map[string]string
root string root string
connector *fuse.FileSystemConnector
nodeFs *fuse.PathNodeFs nodeFs *fuse.PathNodeFs
options *AutoUnionFsOptions options *AutoUnionFsOptions
} }
...@@ -70,9 +69,8 @@ func (me *AutoUnionFs) Name() string { ...@@ -70,9 +69,8 @@ func (me *AutoUnionFs) Name() string {
return fmt.Sprintf("AutoUnionFs(%s)", me.root) return fmt.Sprintf("AutoUnionFs(%s)", me.root)
} }
func (me *AutoUnionFs) Mount(nodeFs *fuse.PathNodeFs, connector *fuse.FileSystemConnector) { func (me *AutoUnionFs) OnMount(nodeFs *fuse.PathNodeFs) {
me.nodeFs = nodeFs me.nodeFs = nodeFs
me.connector = connector
if me.options.UpdateOnMount { if me.options.UpdateOnMount {
time.AfterFunc(0.1e9, func() { me.updateKnownFses() }) time.AfterFunc(0.1e9, func() { me.updateKnownFses() })
} }
...@@ -113,7 +111,7 @@ func (me *AutoUnionFs) createFs(name string, roots []string) fuse.Status { ...@@ -113,7 +111,7 @@ func (me *AutoUnionFs) createFs(name string, roots []string) fuse.Status {
log.Printf("Adding workspace %v for roots %v", name, ufs.Name()) log.Printf("Adding workspace %v for roots %v", name, ufs.Name())
nfs := fuse.NewPathNodeFs(ufs) nfs := fuse.NewPathNodeFs(ufs)
code := me.connector.Mount(me.nodeFs.Root().Inode(), name, nfs, &me.options.FileSystemOptions) code := me.nodeFs.Mount(me.nodeFs.Root().Inode(), name, nfs, &me.options.FileSystemOptions)
if code.Ok() { if code.Ok() {
me.knownFileSystems[name] = knownFs{ me.knownFileSystems[name] = knownFs{
ufs, ufs,
...@@ -133,7 +131,7 @@ func (me *AutoUnionFs) rmFs(name string) (code fuse.Status) { ...@@ -133,7 +131,7 @@ func (me *AutoUnionFs) rmFs(name string) (code fuse.Status) {
return fuse.ENOENT return fuse.ENOENT
} }
code = me.connector.Unmount(known.PathNodeFs.Root().Inode()) code = me.nodeFs.Unmount(known.PathNodeFs.Root().Inode())
if code.Ok() { if code.Ok() {
me.knownFileSystems[name] = knownFs{}, false me.knownFileSystems[name] = knownFs{}, false
me.nameRootMap[name] = "", false me.nameRootMap[name] = "", false
......
...@@ -103,7 +103,7 @@ func NewUnionFs(fileSystems []fuse.FileSystem, options UnionFsOptions) *UnionFs ...@@ -103,7 +103,7 @@ func NewUnionFs(fileSystems []fuse.FileSystem, options UnionFsOptions) *UnionFs
return g return g
} }
func (me *UnionFs) Mount(nodeFs *fuse.PathNodeFs, connector *fuse.FileSystemConnector) { func (me *UnionFs) OnMount(nodeFs *fuse.PathNodeFs) {
me.nodeFs = nodeFs me.nodeFs = nodeFs
} }
......
...@@ -31,7 +31,7 @@ func NewMemTreeFs() *MemTreeFs { ...@@ -31,7 +31,7 @@ func NewMemTreeFs() *MemTreeFs {
return d return d
} }
func (me *MemTreeFs) Mount(conn *fuse.FileSystemConnector) { func (me *MemTreeFs) OnMount(conn *fuse.FileSystemConnector) {
for k, v := range me.files { for k, v := range me.files {
me.addFile(k, v) me.addFile(k, v)
} }
......
...@@ -30,7 +30,6 @@ const ( ...@@ -30,7 +30,6 @@ const (
// reference to the FileSystemConnector to be able to execute // reference to the FileSystemConnector to be able to execute
// mounts. // mounts.
type MultiZipFs struct { type MultiZipFs struct {
Connector *fuse.FileSystemConnector
lock sync.RWMutex lock sync.RWMutex
zips map[string]*MemTreeFs zips map[string]*MemTreeFs
dirZipFileMap map[string]string dirZipFileMap map[string]string
...@@ -50,9 +49,8 @@ func (me *MultiZipFs) Name() string { ...@@ -50,9 +49,8 @@ func (me *MultiZipFs) Name() string {
return "MultiZipFs" return "MultiZipFs"
} }
func (me *MultiZipFs) Mount(nodeFs *fuse.PathNodeFs, connector *fuse.FileSystemConnector) { func (me *MultiZipFs) OnMount(nodeFs *fuse.PathNodeFs) {
me.nodeFs = nodeFs me.nodeFs = nodeFs
me.Connector = connector
} }
func (me *MultiZipFs) OpenDir(name string, context *fuse.Context) (stream chan fuse.DirEntry, code fuse.Status) { func (me *MultiZipFs) OpenDir(name string, context *fuse.Context) (stream chan fuse.DirEntry, code fuse.Status) {
...@@ -123,7 +121,7 @@ func (me *MultiZipFs) Unlink(name string, context *fuse.Context) (code fuse.Stat ...@@ -123,7 +121,7 @@ func (me *MultiZipFs) Unlink(name string, context *fuse.Context) (code fuse.Stat
zfs, ok := me.zips[basename] zfs, ok := me.zips[basename]
if ok { if ok {
code = me.Connector.Unmount(zfs.Root().Inode()) code = me.nodeFs.Unmount(zfs.Root().Inode())
if !code.Ok() { if !code.Ok() {
return code return code
} }
...@@ -173,7 +171,7 @@ func (me *MultiZipFs) Symlink(value string, linkName string, context *fuse.Conte ...@@ -173,7 +171,7 @@ func (me *MultiZipFs) Symlink(value string, linkName string, context *fuse.Conte
return fuse.EINVAL return fuse.EINVAL
} }
code = me.Connector.Mount(me.nodeFs.Root().Inode(), base, fs, nil) code = me.nodeFs.Mount(me.nodeFs.Root().Inode(), base, fs, nil)
if !code.Ok() { if !code.Ok() {
return code return code
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment