logoalt Hacker News

dsp_person10/11/20242 repliesview on HN

The libfuse github has some good examples for C/C++ in [0] of increasing complexity:

- passthrough.c mirrors existing filesystem, "Its performance is terrible."

- passthrough_fh.c "performance is not quite as bad."

- passthrough_ll.c implemented with low level api and "the least bad among the three"

- passthrough_hp.cc high performance version written in C++

Some interesting fuse projects in my notes: [1] splitting large files into segments; [2] show ZFS incremental snapshots as files; [3] transparent filesystem compression; [4] and [5] options for mounting archives as filesytems.

- [0] https://github.com/libfuse/libfuse/tree/master/example

- [1] https://github.com/seiferma/splitviewfuse

- [2] https://github.com/UNFmontreal/zfs_fuse_snapshot

- [3] https://github.com/FS-make-simple/fusecompress

- [4] https://github.com/google/fuse-archive

- [5] https://github.com/mxmlnkn/ratarmount


Replies

craftkiller10/12/2024

While [2] might be a good code example, this functionality is already built into ZFS. At the mountpoint of every dataset is a hidden ".zfs" folder that doesn't show up, even on a `ls -A`. You just have to believe its there and cd into it. Under that is a "snapshot" folder, and inside that is a folder for each snapshot of that dataset. Those folders contain the files in the snapshot.

So for example, /etc/hosts from my snapshot zrepl_20241011_010143_000 would be at /.zfs/snapshot/zrepl_20241011_010143_000/etc/hosts

If you don't like the magic hidden nature of it, you can even configure it to behave like a normal folder with `zfs set snapdir=visible <dataset>`

show 1 reply
j4510/12/2024

I was just thinking about Fuse the other day for a project to get around case sensitivity in linux for a use case.

Appreciate these links. I'm a little rusty on it, if anyone has any Fuse tutorials or guides they found helpful, happy to receive.

show 2 replies