Commit 11af8051 authored by Han-Wen Nienhuys's avatar Han-Wen Nienhuys

fuse/nodefs: hide MemNodeFs type, document NewMemNodeFs().

parent 480c7997
...@@ -2,7 +2,6 @@ package nodefs ...@@ -2,7 +2,6 @@ package nodefs
import ( import (
"fmt" "fmt"
"log"
"os" "os"
"sync" "sync"
"syscall" "syscall"
...@@ -11,9 +10,17 @@ import ( ...@@ -11,9 +10,17 @@ import (
"github.com/hanwen/go-fuse/fuse" "github.com/hanwen/go-fuse/fuse"
) )
var _ = log.Println // NewMemNodeFs creates an in-memory node-based filesystem. Files are
// written into a backing store under the given prefix.
func NewMemNodeFs(prefix string) FileSystem {
fs := &memNodeFs{
backingStorePrefix: prefix,
}
fs.root = fs.newNode()
return fs
}
type MemNodeFs struct { type memNodeFs struct {
backingStorePrefix string backingStorePrefix string
root *memNode root *memNode
...@@ -21,24 +28,24 @@ type MemNodeFs struct { ...@@ -21,24 +28,24 @@ type MemNodeFs struct {
nextFree int nextFree int
} }
func (fs *MemNodeFs) String() string { func (fs *memNodeFs) String() string {
return fmt.Sprintf("MemNodeFs(%s)", fs.backingStorePrefix) return fmt.Sprintf("MemNodeFs(%s)", fs.backingStorePrefix)
} }
func (fs *MemNodeFs) Root() Node { func (fs *memNodeFs) Root() Node {
return fs.root return fs.root
} }
func (fs *MemNodeFs) SetDebug(bool) { func (fs *memNodeFs) SetDebug(bool) {
} }
func (fs *MemNodeFs) OnMount(*FileSystemConnector) { func (fs *memNodeFs) OnMount(*FileSystemConnector) {
} }
func (fs *MemNodeFs) OnUnmount() { func (fs *memNodeFs) OnUnmount() {
} }
func (fs *MemNodeFs) newNode() *memNode { func (fs *memNodeFs) newNode() *memNode {
fs.mutex.Lock() fs.mutex.Lock()
n := &memNode{ n := &memNode{
Node: NewDefaultNode(), Node: NewDefaultNode(),
...@@ -53,22 +60,14 @@ func (fs *MemNodeFs) newNode() *memNode { ...@@ -53,22 +60,14 @@ func (fs *MemNodeFs) newNode() *memNode {
return n return n
} }
func NewMemNodeFs(prefix string) *MemNodeFs { func (fs *memNodeFs) Filename(n *Inode) string {
me := &MemNodeFs{
backingStorePrefix: prefix,
}
me.root = me.newNode()
return me
}
func (fs *MemNodeFs) Filename(n *Inode) string {
mn := n.Node().(*memNode) mn := n.Node().(*memNode)
return mn.filename() return mn.filename()
} }
type memNode struct { type memNode struct {
Node Node
fs *MemNodeFs fs *memNodeFs
id int id int
link string link string
......
...@@ -14,7 +14,7 @@ var _ = log.Println ...@@ -14,7 +14,7 @@ var _ = log.Println
const testTtl = 100 * time.Millisecond const testTtl = 100 * time.Millisecond
func setupMemNodeTest(t *testing.T) (wd string, fs *MemNodeFs, clean func()) { func setupMemNodeTest(t *testing.T) (wd string, fs FileSystem, clean func()) {
tmp, err := ioutil.TempDir("", "go-fuse-memnode_test") tmp, err := ioutil.TempDir("", "go-fuse-memnode_test")
if err != nil { if err != nil {
t.Fatalf("TempDir failed: %v", err) t.Fatalf("TempDir failed: %v", err)
......
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