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 (
// to represent fits in memory: you can construct FsNode at mount
// time, and the filesystem will be ready.
type NodeFileSystem interface {
Unmount()
Mount(conn *FileSystemConnector)
OnUnmount()
OnMount(conn *FileSystemConnector)
StatFs() *StatfsOut
Root() FsNode
}
......@@ -104,8 +104,8 @@ type FileSystem interface {
SetXAttr(name string, attr string, data []byte, flags int, context *Context) Status
// Called after mount.
Mount(nodeFs *PathNodeFs, connector *FileSystemConnector)
Unmount()
OnMount(nodeFs *PathNodeFs)
OnUnmount()
// File handling. If opening for writing, the file's mtime
// should be updated too.
......
......@@ -81,10 +81,10 @@ func (me *DefaultFileSystem) OpenDir(name string, context *Context) (stream chan
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) {
......
......@@ -8,10 +8,11 @@ type DefaultNodeFileSystem struct {
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 {
......
......@@ -225,7 +225,7 @@ func (me *FileSystemConnector) findInode(fullPath string) *Inode {
func (me *FileSystemConnector) MountRoot(nodeFs NodeFileSystem, opts *FileSystemOptions) {
me.rootNode.mountFs(nodeFs, opts)
nodeFs.Mount(me)
nodeFs.OnMount(me)
me.verify()
}
......@@ -270,8 +270,8 @@ func (me *FileSystemConnector) Mount(parent *Inode, name string, nodeFs NodeFile
log.Println("Mount: ", nodeFs, "on subdir", name,
"parent", parent.nodeId)
}
nodeFs.Mount(me)
me.verify()
nodeFs.OnMount(me)
return OK
}
......@@ -309,7 +309,7 @@ func (me *FileSystemConnector) Unmount(node *Inode) Status {
parentNode.mounts[name] = nil, false
parentNode.children[name] = nil, false
mount.fs.Unmount()
mount.fs.OnUnmount()
me.fsInit.EntryNotify(parentNode.nodeId, name)
......
......@@ -95,14 +95,14 @@ func (me *LockingFileSystem) OpenDir(name string, context *Context) (stream chan
return me.FileSystem.OpenDir(name, context)
}
func (me *LockingFileSystem) Mount(nodeFs *PathNodeFs, conn *FileSystemConnector) {
func (me *LockingFileSystem) OnMount(nodeFs *PathNodeFs) {
defer me.locked()()
me.FileSystem.Mount(nodeFs, conn)
me.FileSystem.OnMount(nodeFs)
}
func (me *LockingFileSystem) Unmount() {
func (me *LockingFileSystem) OnUnmount() {
defer me.locked()()
me.FileSystem.Unmount()
me.FileSystem.OnUnmount()
}
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
return me.FileSystem.OpenDir(name, context)
}
func (me *LoggingFileSystem) Mount(nodeFs *PathNodeFs, conn *FileSystemConnector) {
me.Print("Mount", "")
me.FileSystem.Mount(nodeFs, conn)
func (me *LoggingFileSystem) OnMount(nodeFs *PathNodeFs) {
me.Print("OnMount", "")
me.FileSystem.OnMount(nodeFs)
}
func (me *LoggingFileSystem) Unmount() {
me.Print("Unmount", "")
me.FileSystem.Unmount()
func (me *LoggingFileSystem) OnUnmount() {
me.Print("OnUnmount", "")
me.FileSystem.OnUnmount()
}
func (me *LoggingFileSystem) Access(name string, mode uint32, context *Context) (code Status) {
......
......@@ -12,13 +12,23 @@ var _ = log.Println
type PathNodeFs struct {
fs FileSystem
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) {
me.fs.Mount(me, conn)
func (me *PathNodeFs) Unmount(node *Inode) Status {
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 {
......
......@@ -69,12 +69,12 @@ func (me *ReadonlyFileSystem) OpenDir(name string, context *Context) (stream cha
return me.FileSystem.OpenDir(name, context)
}
func (me *ReadonlyFileSystem) Mount(nodeFs *PathNodeFs, conn *FileSystemConnector) {
me.FileSystem.Mount(nodeFs, conn)
func (me *ReadonlyFileSystem) OnMount(nodeFs *PathNodeFs) {
me.FileSystem.OnMount(nodeFs)
}
func (me *ReadonlyFileSystem) Unmount() {
me.FileSystem.Unmount()
func (me *ReadonlyFileSystem) OnUnmount() {
me.FileSystem.OnUnmount()
}
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
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 {
fs.FileSystem.Mount(nodeFs, conn)
fs.FileSystem.OnMount(nodeFs)
}
}
func (me *SwitchFileSystem) Unmount() {
func (me *SwitchFileSystem) OnUnmount() {
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
return me.FileSystem.OpenDir(name, context)
}
func (me *TimingFileSystem) Mount(nodeFs *PathNodeFs, conn *FileSystemConnector) {
defer me.startTimer("Mount", "")()
me.FileSystem.Mount(nodeFs, conn)
func (me *TimingFileSystem) OnMount(nodeFs *PathNodeFs) {
defer me.startTimer("OnMount", "")()
me.FileSystem.OnMount(nodeFs)
}
func (me *TimingFileSystem) Unmount() {
defer me.startTimer("Unmount", "")()
me.FileSystem.Unmount()
func (me *TimingFileSystem) OnUnmount() {
defer me.startTimer("OnUnmount", "")()
me.FileSystem.OnUnmount()
}
func (me *TimingFileSystem) Access(name string, mode uint32, context *Context) (code Status) {
......
......@@ -31,7 +31,6 @@ type AutoUnionFs struct {
nameRootMap map[string]string
root string
connector *fuse.FileSystemConnector
nodeFs *fuse.PathNodeFs
options *AutoUnionFsOptions
}
......@@ -70,9 +69,8 @@ func (me *AutoUnionFs) Name() string {
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.connector = connector
if me.options.UpdateOnMount {
time.AfterFunc(0.1e9, func() { me.updateKnownFses() })
}
......@@ -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())
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() {
me.knownFileSystems[name] = knownFs{
ufs,
......@@ -133,7 +131,7 @@ func (me *AutoUnionFs) rmFs(name string) (code fuse.Status) {
return fuse.ENOENT
}
code = me.connector.Unmount(known.PathNodeFs.Root().Inode())
code = me.nodeFs.Unmount(known.PathNodeFs.Root().Inode())
if code.Ok() {
me.knownFileSystems[name] = knownFs{}, false
me.nameRootMap[name] = "", false
......
......@@ -103,7 +103,7 @@ func NewUnionFs(fileSystems []fuse.FileSystem, options UnionFsOptions) *UnionFs
return g
}
func (me *UnionFs) Mount(nodeFs *fuse.PathNodeFs, connector *fuse.FileSystemConnector) {
func (me *UnionFs) OnMount(nodeFs *fuse.PathNodeFs) {
me.nodeFs = nodeFs
}
......
......@@ -31,7 +31,7 @@ func NewMemTreeFs() *MemTreeFs {
return d
}
func (me *MemTreeFs) Mount(conn *fuse.FileSystemConnector) {
func (me *MemTreeFs) OnMount(conn *fuse.FileSystemConnector) {
for k, v := range me.files {
me.addFile(k, v)
}
......
......@@ -30,7 +30,6 @@ const (
// reference to the FileSystemConnector to be able to execute
// mounts.
type MultiZipFs struct {
Connector *fuse.FileSystemConnector
lock sync.RWMutex
zips map[string]*MemTreeFs
dirZipFileMap map[string]string
......@@ -50,9 +49,8 @@ func (me *MultiZipFs) Name() string {
return "MultiZipFs"
}
func (me *MultiZipFs) Mount(nodeFs *fuse.PathNodeFs, connector *fuse.FileSystemConnector) {
func (me *MultiZipFs) OnMount(nodeFs *fuse.PathNodeFs) {
me.nodeFs = nodeFs
me.Connector = connector
}
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
zfs, ok := me.zips[basename]
if ok {
code = me.Connector.Unmount(zfs.Root().Inode())
code = me.nodeFs.Unmount(zfs.Root().Inode())
if !code.Ok() {
return code
}
......@@ -173,7 +171,7 @@ func (me *MultiZipFs) Symlink(value string, linkName string, context *fuse.Conte
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() {
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