introduce Narfuse for fun #89
Draft
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I banged this together until it worked. And it works! The code is quite garbage right now, but it was fun, and I learned a few things.
go-fuse wants to build the filesystem structure when mounted. Then later, when individual files get accessed, there is a callback to read the content. There are multiple ways to handle this, but I wanted to avoid keeping the whole NAR in memory, so I added the Offset to the nar.Header. This allows the first pass to read the NAR file for the headers and build the filesystem layout. Then later, when individual files get read, re-open the NAR file, seek at Offset and read up to Size.
Once I did this, I found that the nar/ls.Node structure also has an offset. Maybe better to use that, but right now we're missing a method that converse the NAR to a nar/ls structure. That's something I might do in another iteration.