GO-FUSE

用于 Go 的 FUSE 绑定。(FUSE bindings for Go)

Github星跟蹤圖

GO-FUSE

FUSE 内核模块的 Go 本地绑定。

你应该导入并使用 github.com/hanwen/go-fuse/fs 库。它严格遵循 wire 协议,但为构建基于 node 和路径的文件系统提供了方便的抽象。

旧的,已被废弃的API可以在 github.com/hanwen/go-fuse/fuse/pathfsgithub.com/hanwen/go-fuse/fuse/nodefs 找到。

与其他 FUSE 库的比较

在 2019 年完成的重写过程中,FUSE 库获得了一个新的、清理过的 API。在 这里 找到广泛的文档。

该库的进一步亮点是:

  • 全面、最新的协议支持(最高支持到 7.12.28)。
  • 性能与 libfuse 相当。

例子

  • example/hello/main.go 包含一个60行的 "hello world" 文件系统。
  • zipfs/zipfs.go 包含了一个小型的、简单的、只读的 zip 和 tar 文件的文件系统。对应的命令在 example/zipfs/中:
    mkdir /tmp/mountpoint
    example/zipfs/zipfs /tmp/mountpoint file.zip <span class="pl-k">&</span>
    ls /tmp/mountpoint
    fusermount -u /tmp/mountpoint
            
  • zipfs/multizipfs.go 展示了如何使用进程内挂载将多个 Go-FUSE 文件系统合并成一个更大的文件系统。
  • fuse/loopback.go 挂载了文件系统的另一部分。在功能上,它类似于一个符号链接。要运行的二进制文件在 example/loopback/。例如:
    mkdir /tmp/mountpoint
    example/loopback/loopback -debug /tmp/mountpoint /some/other/directory <span class="pl-k">&</span>
    ls /tmp/mountpoint
    fusermount -u /tmp/mountpoint
            

macOS 支持

  • go-fuse 在 OSX 上有一定的工作能力。已知的限制:
  • OSXFUSE 的所有限制,包括不支持 NOTIFY。
  • OSX 会连续发出 STATFS 调用(导致性能问题)。
  • OSX 对 FUSE 设备的并发读取有问题,导致性能问题。
  • 预计测试会通过,如果失败,请将其作为 bug 进行报告

鸣谢

Bugs

是的,可能(会存在)。请通过 https://github.com/hanwen/go-fuse/issues 报告他们。

声明

这不是谷歌的官方产品。

已知问题

Grep 源码的 TODO。主要议题:

  • 缺少对 CUSE、BMAP、IOCTL 的支持。

许可证

和 Go 一样,这个库也是在新的 BSD 许可下发布的。请参阅随附的 LICENSE 文件。


主要指標

概覽
名稱與所有者hanwen/go-fuse
主編程語言Go
編程語言Shell (語言數: 4)
平台Linux, Mac
許可證Other
所有者活动
創建於2010-12-27 18:49:26
推送於2025-06-16 03:15:57
最后一次提交2025-05-29 17:21:04
發布數24
最新版本名稱v2.8.0 (發布於 2025-06-11 21:22:22)
第一版名稱v20170619 (發布於 2017-06-19 10:23:44)
用户参与
星數2.2k
關注者數45
派生數365
提交數2.2k
已啟用問題?
問題數350
打開的問題數24
拉請求數74
打開的拉請求數2
關閉的拉請求數154
项目设置
已啟用Wiki?
已存檔?
是復刻?
已鎖定?
是鏡像?
是私有?

GO-FUSE

Build Status
GoDoc

Go native bindings for the FUSE kernel module.

You should import and use
github.com/hanwen/go-fuse/fs
library. It follows the wire protocol closely, but provides
convenient abstractions for building both node and path based file
systems

Older, deprecated APIs are available at
github.com/hanwen/go-fuse/fuse/pathfs
and
github.com/hanwen/go-fuse/fuse/nodefs.

Comparison with other FUSE libraries

The FUSE library gained a new, cleaned-up API during a rewrite
completed in 2019. Find extensive documentation
here.

Further highlights of this library is

  • Comprehensive and up to date protocol support (up to 7.12.28).

  • Performance that is competitive with libfuse.

Examples

  • example/hello/main.go contains a 60-line "hello world" filesystem

  • zipfs/zipfs.go contains a small and simple read-only filesystem for
    zip and tar files. The corresponding command is in example/zipfs/
    For example,

    mkdir /tmp/mountpoint
    example/zipfs/zipfs /tmp/mountpoint file.zip &
    ls /tmp/mountpoint
    fusermount -u /tmp/mountpoint
    
  • zipfs/multizipfs.go shows how to use in-process mounts to
    combine multiple Go-FUSE filesystems into a larger filesystem.

  • fuse/loopback.go mounts another piece of the filesystem.
    Functionally, it is similar to a symlink. A binary to run is in
    example/loopback/ . For example

    mkdir /tmp/mountpoint
    example/loopback/loopback -debug /tmp/mountpoint /some/other/directory &
    ls /tmp/mountpoint
    fusermount -u /tmp/mountpoint
    

macOS Support

go-fuse works somewhat on OSX. Known limitations:

  • All of the limitations of OSXFUSE, including lack of support for
    NOTIFY.

  • OSX issues STATFS calls continuously (leading to performance
    concerns).

  • OSX has trouble with concurrent reads from the FUSE device, leading
    to performance concerns.

  • Tests are expected to pass; report any failure as a bug!

Credits

Bugs

Yes, probably. Report them through
https://github.com/hanwen/go-fuse/issues

Disclaimer

This is not an official Google product.

Known Problems

Grep source code for TODO. Major topics:

  • Missing support for CUSE, BMAP, IOCTL

License

Like Go, this library is distributed under the new BSD license. See
accompanying LICENSE file.


Appendix I. Go-FUSE log format

To increase signal/noise ratio Go-FUSE uses abbreviations in its debug log
output. Here is how to read it:

  • iX means inode X;
  • gX means generation X;
  • tA and tE means timeout for attributes and directory entry correspondingly;
  • [<off> +<size>) means data range from <off> inclusive till <off>+<size> exclusive;
  • Xb means X bytes.

Every line is prefixed with either rx <unique> or tx <unique> to denote
whether it was for kernel request, which Go-FUSE received, or reply, which
Go-FUSE sent back to kernel.

Example debug log output:

rx 2: LOOKUP i1 [".wcfs"] 6b
tx 2:     OK, {i3 g2 tE=1s tA=1s {M040755 SZ=0 L=0 1000:1000 B0*0 i0:3 A 0.000000 M 0.000000 C 0.000000}}
rx 3: LOOKUP i3 ["zurl"] 5b
tx 3:     OK, {i4 g3 tE=1s tA=1s {M0100644 SZ=33 L=1 1000:1000 B0*0 i0:4 A 0.000000 M 0.000000 C 0.000000}}
rx 4: OPEN i4 {O_RDONLY,0x8000}
tx 4:     38=function not implemented, {Fh 0 }
rx 5: READ i4 {Fh 0 [0 +4096)  L 0 RDONLY,0x8000}
tx 5:     OK,  33b data "file:///"...
rx 6: GETATTR i4 {Fh 0}
tx 6:     OK, {tA=1s {M0100644 SZ=33 L=1 1000:1000 B0*0 i0:4 A 0.000000 M 0.000000 C 0.000000}}
rx 7: FLUSH i4 {Fh 0}
tx 7:     OK
rx 8: LOOKUP i1 ["head"] 5b
tx 8:     OK, {i5 g4 tE=1s tA=1s {M040755 SZ=0 L=0 1000:1000 B0*0 i0:5 A 0.000000 M 0.000000 C 0.000000}}
rx 9: LOOKUP i5 ["bigfile"] 8b
tx 9:     OK, {i6 g5 tE=1s tA=1s {M040755 SZ=0 L=0 1000:1000 B0*0 i0:6 A 0.000000 M 0.000000 C 0.000000}}
rx 10: FLUSH i4 {Fh 0}
tx 10:     OK
rx 11: GETATTR i1 {Fh 0}
tx 11:     OK, {tA=1s {M040755 SZ=0 L=1 1000:1000 B0*0 i0:1 A 0.000000 M 0.000000 C 0.000000}}