0
使用go-fuse:nodefs创建FUSE文件系统。除文件以外的所有工作都没有打开。go-fuse打开文件
基本上文件节点是这样的:
type SomeFileNode struct {
nodefs.Node
content string
}
func (this *SomeFileNode) Open(flags uint32, context *fuse.Context) (nodefs.File, fuse.Status) {
return nodefs.NewDataFile([]byte(this.content)), fuse.OK
}
我希望cat
该文件,但没有被打印到标准输出。
我错过了什么?
全部摄制代码:
func main() {
mountPoint := "/some/mountpoint"
fs := &SomeFs{Root: &SomeRootNode{nodefs.NewDefaultNode()}}
server, _, err := nodefs.MountRoot(mountPoint, fs.Root, nil)
if err != nil {
log.Fatalln("Mount fail")
os.Exit(1)
}
server.Serve()
}
type SomeFs struct {
Root *SomeRootNode
}
type SomeRootNode struct {
nodefs.Node
}
type SomeFileNode struct {
nodefs.Node
content string
}
func (this *SomeRootNode) OnMount(c *nodefs.FileSystemConnector) {
this.Inode().NewChild("leaf", false, &SomeFileNode{Node: nodefs.NewDefaultNode(), content: "hello"})
}
func (this *SomeFileNode) Open(flags uint32, context *fuse.Context) (nodefs.File, fuse.Status) {
return nodefs.NewDataFile([]byte(this.content)), fuse.OK
}