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