【问题标题】:go-fuse Open filego-fuse 打开文件
【发布时间】:2018-02-23 20:07:12
【问题描述】:

使用go-fuse 创建了一个 FUSE 文件系统:nodefs。一切正常,除了文件没有打开。

基本上文件节点是这样的:

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
}

【问题讨论】:

    标签: go fuse


    【解决方案1】:

    在此回答:https://github.com/hanwen/go-fuse/issues/186

    需要实现 GetAttr 并报告 Size。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-12-29
      • 1970-01-01
      • 2011-05-17
      • 2020-10-21
      • 1970-01-01
      • 1970-01-01
      • 2016-06-24
      相关资源
      最近更新 更多