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

Mount NodeFileSystem rather than (Path)FileSystem.

parent 66f65406
......@@ -33,7 +33,7 @@ func setupCacheTest() (string, *FileSystemConnector, func()) {
fs := &cacheFs{
LoopbackFileSystem: NewLoopbackFileSystem(dir + "/orig"),
}
state, conn, err := MountFileSystem(dir+"/mnt", fs, nil)
state, conn, err := MountPathFileSystem(dir+"/mnt", fs, nil)
CheckSuccess(err)
state.Debug = true
conn.Debug = true
......@@ -116,7 +116,7 @@ func TestNonseekable(t *testing.T) {
dir := MakeTempDir()
defer os.RemoveAll(dir)
state, _, err := MountFileSystem(dir, fs, nil)
state, _, err := MountPathFileSystem(dir, fs, nil)
CheckSuccess(err)
state.Debug = true
defer state.Unmount()
......
......@@ -35,7 +35,7 @@ type FileSystemConnector struct {
rootNode *Inode
}
func NewFileSystemConnector(fs FileSystem, opts *FileSystemOptions) (me *FileSystemConnector) {
func NewFileSystemConnector(nodeFs NodeFileSystem, opts *FileSystemOptions) (me *FileSystemConnector) {
me = new(FileSystemConnector)
if opts == nil {
opts = NewFileSystemOptions()
......@@ -44,7 +44,7 @@ func NewFileSystemConnector(fs FileSystem, opts *FileSystemOptions) (me *FileSys
me.rootNode = me.newInode(true)
me.rootNode.nodeId = FUSE_ROOT_ID
me.verify()
me.mountRoot(fs, opts)
me.mountRoot(nodeFs, opts)
return me
}
......@@ -229,9 +229,9 @@ func (me *FileSystemConnector) findInode(fullPath string) *Inode {
// mount management in FileSystemConnector, so AutoUnionFs and
// MultiZipFs don't have to do it separately, with the risk of
// inconsistencies.
func (me *FileSystemConnector) Mount(mountPoint string, fs FileSystem, opts *FileSystemOptions) Status {
func (me *FileSystemConnector) Mount(mountPoint string, nodeFs NodeFileSystem, opts *FileSystemOptions) Status {
if mountPoint == "/" || mountPoint == "" {
me.mountRoot(fs, opts)
me.mountRoot(nodeFs, opts)
return OK
}
......@@ -257,7 +257,6 @@ func (me *FileSystemConnector) Mount(mountPoint string, fs FileSystem, opts *Fil
opts = me.rootNode.mountPoint.options
}
nodeFs := NewPathNodeFs(fs)
node.mountFs(nodeFs, opts)
parent.addChild(base, node)
......@@ -266,18 +265,17 @@ func (me *FileSystemConnector) Mount(mountPoint string, fs FileSystem, opts *Fil
}
parent.mounts[base] = node.mountPoint
if me.Debug {
log.Println("Mount: ", fs, "on dir", mountPoint,
log.Println("Mount: ", nodeFs, "on dir", mountPoint,
"parent", parent)
}
fs.Mount(me)
nodeFs.Mount(me)
me.verify()
return OK
}
func (me *FileSystemConnector) mountRoot(fs FileSystem, opts *FileSystemOptions) {
ifs := NewPathNodeFs(fs)
me.rootNode.mountFs(ifs, opts)
ifs.Mount(me)
func (me *FileSystemConnector) mountRoot(nodeFs NodeFileSystem, opts *FileSystemOptions) {
me.rootNode.mountFs(nodeFs, opts)
nodeFs.Mount(me)
me.verify()
}
......
......@@ -122,7 +122,7 @@ func NewFile() *MutableDataFile {
func setupFAttrTest(fs FileSystem) (dir string, clean func()) {
dir = MakeTempDir()
state, _, err := MountFileSystem(dir, fs, nil)
state, _, err := MountPathFileSystem(dir, fs, nil)
CheckSuccess(err)
state.Debug = true
......
......@@ -8,8 +8,8 @@ import (
var _ = log.Println
func MountFileSystem(mountpoint string, fs FileSystem, opts *FileSystemOptions) (*MountState, *FileSystemConnector, os.Error) {
conn := NewFileSystemConnector(fs, opts)
func MountNodeFileSystem(mountpoint string, nodeFs NodeFileSystem, opts *FileSystemOptions) (*MountState, *FileSystemConnector, os.Error) {
conn := NewFileSystemConnector(nodeFs, opts)
mountState := NewMountState(conn)
fmt.Printf("Go-FUSE Version %v.\nMounting...\n", Version())
err := mountState.Mount(mountpoint, nil)
......@@ -19,3 +19,8 @@ func MountFileSystem(mountpoint string, fs FileSystem, opts *FileSystemOptions)
fmt.Println("Mounted!")
return mountState, conn, nil
}
func MountPathFileSystem(mountpoint string, pathFs FileSystem, opts *FileSystemOptions) (*MountState, *FileSystemConnector, os.Error) {
nfs := NewPathNodeFs(pathFs)
return MountNodeFileSystem(mountpoint, nfs, opts)
}
......@@ -68,7 +68,8 @@ func NewTestCase(t *testing.T) *testCase {
pfs = NewLockingFileSystem(pfs)
var rfs RawFileSystem
me.connector = NewFileSystemConnector(pfs,
nfs := NewPathNodeFs(pfs)
me.connector = NewFileSystemConnector(nfs,
&FileSystemOptions{
EntryTimeout: testTtl,
AttrTimeout: testTtl,
......@@ -670,7 +671,7 @@ func TestOriginalIsSymlink(t *testing.T) {
CheckSuccess(err)
fs := NewLoopbackFileSystem(link)
state, _, err := MountFileSystem(mnt, fs, nil)
state, _, err := MountPathFileSystem(mnt, fs, nil)
CheckSuccess(err)
defer state.Unmount()
......
......@@ -15,15 +15,15 @@ func TestMountOnExisting(t *testing.T) {
err := os.Mkdir(ts.mnt+"/mnt", 0777)
CheckSuccess(err)
fs := &DefaultFileSystem{}
code := ts.connector.Mount("/mnt", fs, nil)
nfs := &DefaultNodeFileSystem{}
code := ts.connector.Mount("/mnt", nfs, nil)
if code != EBUSY {
t.Fatal("expect EBUSY:", code)
}
err = os.Remove(ts.mnt + "/mnt")
CheckSuccess(err)
code = ts.connector.Mount("/mnt", fs, nil)
code = ts.connector.Mount("/mnt", nfs, nil)
if !code.Ok() {
t.Fatal("expect OK:", code)
}
......@@ -43,7 +43,7 @@ func TestMountRename(t *testing.T) {
ts := NewTestCase(t)
defer ts.Cleanup()
fs := NewLoopbackFileSystem(ts.orig)
fs := NewPathNodeFs(NewLoopbackFileSystem(ts.orig))
code := ts.connector.Mount("/mnt", fs, nil)
if !code.Ok() {
t.Fatal("mount should succeed")
......@@ -58,7 +58,7 @@ func TestMountReaddir(t *testing.T) {
ts := NewTestCase(t)
defer ts.Cleanup()
fs := NewLoopbackFileSystem(ts.orig)
fs := NewPathNodeFs(NewLoopbackFileSystem(ts.orig))
code := ts.connector.Mount("/mnt", fs, nil)
if !code.Ok() {
t.Fatal("mount should succeed")
......@@ -78,7 +78,7 @@ func TestRecursiveMount(t *testing.T) {
err := ioutil.WriteFile(ts.orig+"/hello.txt", []byte("blabla"), 0644)
CheckSuccess(err)
fs := NewLoopbackFileSystem(ts.orig)
fs := NewPathNodeFs(NewLoopbackFileSystem(ts.orig))
code := ts.connector.Mount("/mnt", fs, nil)
if !code.Ok() {
t.Fatal("mount should succeed")
......@@ -115,7 +115,7 @@ func TestDeletedUnmount(t *testing.T) {
defer ts.Cleanup()
submnt := filepath.Join(ts.mnt, "mnt")
pfs2 := NewLoopbackFileSystem(ts.orig)
pfs2 := NewPathNodeFs(NewLoopbackFileSystem(ts.orig))
code := ts.connector.Mount("/mnt", pfs2, nil)
if !code.Ok() {
t.Fatal("Mount error", code)
......
......@@ -50,7 +50,7 @@ func NewNotifyTest() *NotifyTest {
}
var err os.Error
me.state, me.connector, err = MountFileSystem(me.dir, me.fs, opts)
me.state, me.connector, err = MountPathFileSystem(me.dir, me.fs, opts)
CheckSuccess(err)
me.state.Debug = true
go me.state.Loop(false)
......
......@@ -28,7 +28,7 @@ func setupOwnerTest(opts *FileSystemOptions) (workdir string, cleanup func()) {
wd := MakeTempDir()
fs := &ownerFs{}
state, _, err := MountFileSystem(wd, fs, opts)
state, _, err := MountPathFileSystem(wd, fs, opts)
CheckSuccess(err)
go state.Loop(false)
return wd, func() {
......
......@@ -12,7 +12,7 @@ func TestPathDebug(t *testing.T) {
debugFs.FileSystem = &DefaultFileSystem{}
debugFs.Add("test-entry", func() []byte { return []byte("test-content") })
connector := NewFileSystemConnector(debugFs, nil)
connector := NewFileSystemConnector(NewPathNodeFs(debugFs), nil)
mountPoint := MakeTempDir()
defer os.RemoveAll(mountPoint)
......
......@@ -94,7 +94,7 @@ func TestXAttrRead(t *testing.T) {
mountPoint := MakeTempDir()
defer os.RemoveAll(mountPoint)
state, _, err := MountFileSystem(mountPoint, xfs, nil)
state, _, err := MountPathFileSystem(mountPoint, xfs, nil)
CheckSuccess(err)
state.Debug = true
defer state.Unmount()
......
......@@ -106,7 +106,8 @@ func (me *AutoUnionFs) createFs(name string, roots []string) fuse.Status {
}
log.Printf("Adding workspace %v for roots %v", name, ufs.Name())
code := me.connector.Mount("/"+name, ufs, &me.options.FileSystemOptions)
nfs := fuse.NewPathNodeFs(ufs)
code := me.connector.Mount("/"+name, nfs, &me.options.FileSystemOptions)
if code.Ok() {
me.knownFileSystems[name] = ufs
me.nameRootMap[name] = roots[0]
......
......@@ -42,7 +42,7 @@ func setup(t *testing.T) (workdir string, cleanup func()) {
WriteFile(wd+"/ro/file2", "file2")
fs := NewAutoUnionFs(wd+"/store", testAOpts)
state, conn, err := fuse.MountFileSystem(wd+"/mount", fs, &testAOpts.FileSystemOptions)
state, conn, err := fuse.MountPathFileSystem(wd+"/mount", fs, &testAOpts.FileSystemOptions)
CheckSuccess(err)
state.Debug = true
conn.Debug = true
......
......@@ -54,7 +54,7 @@ func setupUfs(t *testing.T) (workdir string, cleanup func()) {
NegativeTimeout: .5 * entryTtl,
}
state, conn, err := fuse.MountFileSystem(wd+"/mount", ufs, opts)
state, conn, err := fuse.MountPathFileSystem(wd+"/mount", ufs, opts)
CheckSuccess(err)
conn.Debug = true
state.Debug = true
......@@ -821,7 +821,7 @@ func TestDisappearing(t *testing.T) {
NegativeTimeout: entryTtl,
}
state, _, err := fuse.MountFileSystem(wd+"/mount", ufs, opts)
state, _, err := fuse.MountPathFileSystem(wd+"/mount", ufs, opts)
CheckSuccess(err)
defer state.Unmount()
state.Debug = true
......
......@@ -171,7 +171,7 @@ func (me *MultiZipFs) Symlink(value string, linkName string, context *fuse.Conte
return fuse.EINVAL
}
code = me.Connector.Mount("/"+base, fs, nil)
code = me.Connector.Mount("/"+base, fuse.NewPathNodeFs(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