Skip to content

Commit 37c9e80

Browse files
committed
Add some notes comparing cap-std to similar crates.
1 parent 24df088 commit 37c9e80

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

README.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,4 +186,29 @@ more information on the technique, see the [`arf-strings` package]. To try it,
186186
opt in by enabling the `fs_utf8` feature and using `std::fs_utf8` in place of
187187
`std::fs`.
188188

189+
## Similar crates
190+
191+
`cap-std` provides similar functionality to the [`openat`] crate, with a similar
192+
`Dir` type with associated functions corresponding to `*at` functions.
193+
`cap-std`'s `Dir` type performs sandboxing, including for multiple-component
194+
paths.
195+
196+
`cap-std` has some similar functionality to [`pathrs`] in that it also
197+
explicitly verifies that `/proc` has actual `/proc` mounted on it and nothing
198+
mounted on top, and it can also use `openat2`. However, `cap-std` uses
199+
`RESOLVE_BENEATH`-style resolution where absolute paths are considered errors,
200+
while `pathrs` uses `RESOLVE_IN_ROOT` where absolute paths are interpreted as
201+
references to the base file descriptor. And overall, `cap-std` seeks to provide
202+
a portable `std`-like API which supports Windows in addition to Unix-like
203+
platforms, while `pathrs` provides a lower-level API that exposes more of the
204+
underlying `openat2` options and only supports Linux.
205+
206+
[`obnth`] is a new crate which appears to be very similar to `cap_std::fs`.
207+
It's not mature yet, and it doesn't support Windows. It does support
208+
`openat2`-like features such as `RESOLVE_NO_XDEV`, `RESOLVE_NO_SYMLINKS`,
209+
and `RESOLVE_IN_ROOT`, including emulation when `openat2` isn't available.
210+
189211
[`arf-strings` package]: https://github.com/bytecodealliance/arf-strings/
212+
[`openat`]: https://crates.io/crates/openat
213+
[`pathrs`]: https://crates.io/crates/pathrs
214+
[`obnth`]: https://crates.io/crates/obnth

0 commit comments

Comments
 (0)