ratarmount icon indicating copy to clipboard operation
ratarmount copied to clipboard

[feature request] Mounting via syscall overrides / LD_PRELOAD or static linking with `--wrap=` syscall hooks

Open vadimkantorov opened this issue 5 months ago • 2 comments

If any of these would be possible, then it would be possible to have this virtual FS functionality pluggable to other existing software (and on systems without FUSE/root capabilities)

I'm implementing myself something similar in https://github.com/vadimkantorov/packfs - but I'm using libarchive under the hood which does not currently support seeks...

What would be eventually good is to be adding some seeking functionality to libarchive... (starting with ZIP and TAR archives)

vadimkantorov avatar Sep 17 '25 04:09 vadimkantorov

Interesting. Many of ratarmount's features can be used as a library without FUSE via ratarmountcore, but it is a slightly higher hurdle. The issue with FUSE permissions comes up frequently. A solution to that would be nice, but it seems impossible when still requiring a POSIX filesystem. Yes, one could offer some S3, or NFS, or 9P interface, but then you would need mount permissions for the NFS, S3, or 9P client. If you are fine using S3 directly in your program, then why not use ratarmountcore directly?

Static linking seems out of scope because it is Python, I think, or am I misunderstanding? I have not used syscall hooks yet. I am unsure about LD_PRELOAD. If LD_PRELOAD hijacks libfuse functions, then it might be feasible, but I am not sure how it behaves when combined with dlopen. It could be added by simply replacing the mfusepy Python module with some custom implementation. Creating an mfusepy.py file in the current directory might also confuse ratarmount sufficiently to use that as a shim.

Adding seeking support to libarchive seems like the most usable solution, yes. But, it is also the hardest and would require coordination and probably large refactors in a foreign project. I also only have limited knowledge about programming in C. It should be possible to use rapidgzip / indexed_bzip2 as a dependency by static or shared linking to avoid reimplementing those parts in C. I see that you already collected some related issues there: https://github.com/libarchive/libarchive/issues/2638#issuecomment-2966162058 It feels easier to try it in librapidarchive and keep the decompression layer separate from the archiving layer. That separation is a bit more problematic with ZIP though, but it should be doable.

mxmlnkn avatar Sep 19 '25 11:09 mxmlnkn

LD_PRELOAD is an alternative mechanism to FUSE (with its own downsides, but the upside is that it does not require root privileges / creating new user namespaces etc). But yeah, if ratarmount is based on Python, it can be quite complex to follow this path (would require embedding all of Python into a shared library and exposing certain Python funcions as C functions)...

vadimkantorov avatar Sep 19 '25 16:09 vadimkantorov