Export fs.FS as FUSE fs

220 views
Skip to first unread message

Tamás Gulácsi

unread,
Jun 23, 2023, 2:08:32 AM6/23/23
to golang-nuts
Hi,

Does anyone know an existing solution for exporting an fs.FS as a FUSE filesystem?

As fs.FS is standard now, this would open several new possibilities,
as a lot of interesting fs.FS implementations exist (zip, tar, DB, embedded, union ....),
and this one little glue code could export them all!

Thanks in advance,
Tamás

Tamás Gulácsi

unread,
Jun 24, 2023, 10:09:22 AM6/24/23
to golang-nuts
Ok, I've put some hours into it, and implemented it: https://pkg.go.dev/github.com/tgulacsi/g...@v0.25.0/fsfuse
It uses github.com/jacobsa/fuse to export a mountable io/fs.FS.

I've only tested with os.DirFS, with that, it works as expected.

I'd love to get some feedback - if anynone interested, I can export it to some more direct/slimmer repo.

Tanás Gulácsi

Roland Müller

unread,
Jun 29, 2023, 3:00:18 AM6/29/23
to golang-nuts
Hello,
I am struggling to understand the purpose of extension.
FS is an interface to access file systems from go code. Is your new extension acting as a handler and allows to expose any Go FS to be mounted and acessed at operating system level?

https://en.m.wikipedia.org/wiki/Filesystem_in_Userspace#/media/File%3AFUSE_structure.svg

Br/Üdvözlettel
Roland
> --
> You received this message because you are subscribed to the Google Groups "golang-nuts" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/f8edf7e1-a864-4ab0-b7e6-773246485da1n%40googlegroups.com.
>

Peter Galbavy

unread,
Jun 29, 2023, 3:11:03 AM6/29/23
to golang-nuts
I can see a use - exporting an embedded FS (read only) from a binary, especially for testing stuff.

Tamás Gulácsi

unread,
Jun 29, 2023, 5:28:33 AM6/29/23
to golang-nuts
FS is an abstraction, a common interface for file systems.
It allows me to provide access to an archive (zip, tar) or database or network (S3, HTTP ...) backed file system.
Thus exporting FS as a FUSE filesystem allows all those FS implementations to be accessed as a real file system,
eliminating the double implementation (say, if you implement a HTTP backed FS, you can use it as a FUSE fs, don't have to reimplement it with a fuse lib).

You're right, exporting a file system backed FS as FUSE is moot.
But exporting the embed.FS or database backed FS as FUSE allows ordinary programs, user, scripts to access those files.

FS being read-only is a bless and a curse at the same time: simplifies implementation, but deflates the usefulness.
Reply all
Reply to author
Forward
0 new messages