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.
What's the problem this PR addresses?
While adding tests to JailFS I came across a behaviour I didn't expect - calling
readFile("foo.txt")
would joinfoo.txt
to the JailFS target path, but callingresolve("foo.txt")
would return/foo.txt
. This seems conflating two different things: the jail, and obtaining a "partial view" of the filesystem.How did you fix it?
I'm looking whether it'd make sense to split those two concerns in two separate FS classes:
JailFS
would strictly forbid accessing paths outside of the specified directory (and would check absolute paths unmodified), whileSubFS
would pretend that anything outside of the provided directory doesn't exist (/
would thus internally point to the SubFS target path).It's a little experimental, and a breaking change for the fslib, so I have to think a little whether this all make sense. Originally I implemented something similar to SubFS to supplement MountFS, and only then noticed that JailFS was kind of the same, except that not really, and perhaps it shouldn't be the same at all.
Checklist