Commit 1f16ee66 authored by Han-Wen Nienhuys's avatar Han-Wen Nienhuys

fuse: Hide the RawFileSystem implementation of FileSystemConnector behind

the RawFS() method.
parent e50569a4
...@@ -43,7 +43,7 @@ func main() { ...@@ -43,7 +43,7 @@ func main() {
} }
pathFs := pathfs.NewPathNodeFs(finalFs, nil) pathFs := pathfs.NewPathNodeFs(finalFs, nil)
conn := fuse.NewFileSystemConnector(pathFs, opts) conn := fuse.NewFileSystemConnector(pathFs, opts)
state := fuse.NewMountState(conn) state := fuse.NewMountState(conn.RawFS())
state.SetDebug(*debug) state.SetDebug(*debug)
mountPoint := flag.Arg(0) mountPoint := flag.Arg(0)
......
...@@ -21,22 +21,17 @@ var paranoia = false ...@@ -21,22 +21,17 @@ var paranoia = false
// FilesystemConnector is a raw FUSE filesystem that manages // FilesystemConnector is a raw FUSE filesystem that manages
// in-process mounts and inodes. Its job is twofold: // in-process mounts and inodes. Its job is twofold:
// //
// * It translates between the raw kernel interface (padded structs of // It translates between the raw kernel interface (padded structs of
// int32 and int64) and the more abstract Go-ish NodeFileSystem // int32 and int64) and the more abstract Go-ish NodeFileSystem
// interface. // interface.
// //
// * It manages mounting and unmounting of NodeFileSystems into the // It manages mounting and unmounting of NodeFileSystems into the
// directory hierarchy // directory hierarchy.
//
// To achieve this, the connector only needs a pointer to the root
// node.
type FileSystemConnector struct { type FileSystemConnector struct {
// Used as the generation inodes. This must be 64-bit aligned, // Used as the generation inodes. This must be 64-bit aligned,
// for sync/atomic on i386 to work properly. // for sync/atomic on i386 to work properly.
generation uint64 generation uint64
DefaultRawFileSystem
debug bool debug bool
// Callbacks for talking back to the kernel. // Callbacks for talking back to the kernel.
...@@ -100,12 +95,11 @@ func (c *FileSystemConnector) verify() { ...@@ -100,12 +95,11 @@ func (c *FileSystemConnector) verify() {
root.verify(c.rootNode.mountPoint) root.verify(c.rootNode.mountPoint)
} }
// Generate EntryOut and increase the lookup count for an inode. func (c *rawBridge) childLookup(out *raw.EntryOut, fsi FsNode) {
func (c *FileSystemConnector) childLookup(out *raw.EntryOut, fsi FsNode) {
n := fsi.Inode() n := fsi.Inode()
fsi.GetAttr((*Attr)(&out.Attr), nil, nil) fsi.GetAttr((*Attr)(&out.Attr), nil, nil)
n.mount.fillEntry(out) n.mount.fillEntry(out)
out.Ino = c.lookupUpdate(n) out.Ino = c.fsConn().lookupUpdate(n)
out.NodeId = out.Ino out.NodeId = out.Ino
if out.Nlink == 0 { if out.Nlink == 0 {
// With Nlink == 0, newer kernels will refuse link // With Nlink == 0, newer kernels will refuse link
...@@ -114,7 +108,7 @@ func (c *FileSystemConnector) childLookup(out *raw.EntryOut, fsi FsNode) { ...@@ -114,7 +108,7 @@ func (c *FileSystemConnector) childLookup(out *raw.EntryOut, fsi FsNode) {
} }
} }
func (c *FileSystemConnector) toInode(nodeid uint64) *Inode { func (c *rawBridge) toInode(nodeid uint64) *Inode {
if nodeid == raw.FUSE_ROOT_ID { if nodeid == raw.FUSE_ROOT_ID {
return c.rootNode return c.rootNode
} }
......
This diff is collapsed.
...@@ -6,7 +6,7 @@ var _ = log.Println ...@@ -6,7 +6,7 @@ var _ = log.Println
func MountNodeFileSystem(mountpoint string, nodeFs NodeFileSystem, opts *FileSystemOptions) (*MountState, *FileSystemConnector, error) { func MountNodeFileSystem(mountpoint string, nodeFs NodeFileSystem, opts *FileSystemOptions) (*MountState, *FileSystemConnector, error) {
conn := NewFileSystemConnector(nodeFs, opts) conn := NewFileSystemConnector(nodeFs, opts)
mountState := NewMountState(conn) mountState := NewMountState(conn.RawFS())
err := mountState.Mount(mountpoint, nil) err := mountState.Mount(mountpoint, nil)
if err != nil { if err != nil {
return nil, nil, err return nil, nil, err
......
...@@ -30,7 +30,7 @@ func setupMemNodeTest(t *testing.T) (wd string, fs *MemNodeFs, clean func()) { ...@@ -30,7 +30,7 @@ func setupMemNodeTest(t *testing.T) (wd string, fs *MemNodeFs, clean func()) {
NegativeTimeout: 0.0, NegativeTimeout: 0.0,
}) })
connector.SetDebug(VerboseTest()) connector.SetDebug(VerboseTest())
state := NewMountState(connector) state := NewMountState(connector.RawFS())
state.Mount(mnt, nil) state.Mount(mnt, nil)
//me.state.SetDebug(false) //me.state.SetDebug(false)
......
...@@ -84,7 +84,7 @@ func NewTestCase(t *testing.T) *testCase { ...@@ -84,7 +84,7 @@ func NewTestCase(t *testing.T) *testCase {
AttrTimeout: testTtl, AttrTimeout: testTtl,
NegativeTimeout: 0.0, NegativeTimeout: 0.0,
}) })
rfs = fuse.NewLockingRawFileSystem(me.connector) rfs = fuse.NewLockingRawFileSystem(me.connector.RawFS())
me.connector.SetDebug(fuse.VerboseTest()) me.connector.SetDebug(fuse.VerboseTest())
me.state = fuse.NewMountState(rfs) me.state = fuse.NewMountState(rfs)
......
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