rust/library/std/src
Mara Bos ce1020fc55
Rollup merge of #81542 - RReverser:wasi-symlink, r=alexcrichton
Expose correct symlink API on WASI

As described in https://github.com/rust-lang/rust/issues/68574, the currently exposed API for symlinks is, in fact, a thin wrapper around the corresponding syscall, and not suitable for public usage.

The reason is that the 2nd param in the call is expected to be a handle of a "preopened directory" (a WASI concept for exposing dirs), and the only way to retrieve such handle right now is by tinkering with a private `__wasilibc_find_relpath` API, which is an implementation detail and definitely not something we want users to call directly.

Making matters worse, the semantics of this param aren't obvious from its name (`fd`), and easy to misinterpret, resulting in people trying to pass a handle of the target file itself (as in https://github.com/vitiral/path_abs/pull/50), which doesn't work as expected.

I did a [codesearch among open-source repos](https://sourcegraph.com/search?q=std%3A%3Aos%3A%3Awasi%3A%3Afs%3A%3Asymlink&patternType=literal), and the usage above is so far the only usage of this API at all, but we should fix it before more people start using it incorrectly.

While this is technically a breaking API change, I believe it's a justified one, as 1) it's OS-specific and 2) there was strictly no way to correctly use the previous form of the API, and if someone does use it, they're likely doing it wrong like in the example above.

The new API does not lead to the same confusion, as it mirrors `std::os::unix::fs::symlink` and `std::os::windows::fs::symlink_{file,dir}` variants by accepting source/target paths.

Fixes #68574.

r? ``@alexcrichton``
2021-02-05 12:26:00 +01:00
..
backtrace Add Frames iterator for Backtrace 2021-01-23 11:56:33 -06:00
collections Rollup merge of #81588 - xfix:delete-doc-alias, r=Mark-Simulacrum 2021-02-02 16:01:41 -05:00
env std: move "mod tests/benches" to separate files 2020-08-31 02:56:59 +00:00
error std: move "mod tests/benches" to separate files 2020-08-31 02:56:59 +00:00
f32 std: move "mod tests/benches" to separate files 2020-08-31 02:56:59 +00:00
f64 std: move "mod tests/benches" to separate files 2020-08-31 02:56:59 +00:00
ffi OsStr eq_ignore_ascii_case takes arg by value 2021-02-03 10:28:51 -05:00
fs std: Fix test got_symlink_permission on Windows 2020-11-16 21:09:26 +03:00
io specialize io::copy to use the memory of the writer if it is a BufWriter 2021-01-31 14:58:03 +01:00
lazy std: move "mod tests/benches" to separate files 2020-08-31 02:56:59 +00:00
memchr std: move "mod tests/benches" to separate files 2020-08-31 02:56:59 +00:00
net add #[inline] to all the public IpAddr functions 2021-02-03 10:53:25 -05:00
num rustc_expand: Mark inner #![test] attributes as soft-unstable 2020-11-20 19:35:03 +03:00
os Fix AArch64 types in std::os::raw 2021-02-02 05:49:31 +00:00
panic review: fix nits and move panic safety tests to the correct place 2020-09-25 23:10:24 +02:00
path Refactor parse_prefix on Windows 2020-11-07 16:15:48 +01:00
prelude Rollup merge of #80172 - camelid:prelude-docs-consistent-punct, r=steveklabnik 2021-01-21 20:04:39 +09:00
process std: move "mod tests/benches" to separate files 2020-08-31 02:56:59 +00:00
sync Stabilize poison API of Once, rename poisoned() 2021-02-04 15:20:14 +01:00
sys Rollup merge of #81542 - RReverser:wasi-symlink, r=alexcrichton 2021-02-05 12:26:00 +01:00
sys_common Optimize away some path lookups in the generic fs::copy implementation. 2021-01-06 08:36:31 -08:00
thread Recommend panic::resume_unwind instead of panicking. 2020-12-18 17:03:45 -05:00
time Duration::zero() -> Duration::ZERO 2020-10-21 20:44:03 -07:00
alloc.rs Fix safety comment 2021-01-07 09:13:21 +01:00
ascii.rs Convert many files to intra-doc links 2020-09-02 17:37:40 -04:00
backtrace.rs Add Frames iterator for Backtrace 2021-01-23 11:56:33 -06:00
env.rs Document security implications of std::env::temp_dir 2021-01-20 11:24:47 -08:00
error.rs Rollup merge of #75180 - KodrAus:feat/error-by-ref, r=m-ou-se 2021-01-24 22:09:45 +01:00
f32.rs Deprecate-in-future the constants superceded by RFC 2700 2021-01-20 20:08:11 -05:00
f64.rs Deprecate-in-future the constants superceded by RFC 2700 2021-01-20 20:08:11 -05:00
fs.rs Add doc aliases for "delete" 2021-01-31 11:07:37 +01:00
keyword_docs.rs Update code to account for extern ABI requirement 2021-01-13 07:49:45 -05:00
lazy.rs Add (internal-only) SyncOnceCell::get_or_init_pin. 2020-12-08 22:57:50 +01:00
lib.rs Stabilize the Wake trait 2021-02-03 16:54:29 +01:00
macros.rs Implement new panic!() behaviour for Rust 2021. 2021-01-25 13:48:11 +01:00
memchr.rs std: move "mod tests/benches" to separate files 2020-08-31 02:56:59 +00:00
num.rs std: move "mod tests/benches" to separate files 2020-08-31 02:56:59 +00:00
panic.rs Auto merge of #80851 - m-ou-se:panic-2021, r=petrochenkov 2021-02-01 10:25:31 +00:00
panicking.rs fix another comment, and make __rust_start_panic code a bit more semantically clear 2020-12-25 23:37:27 +01:00
path.rs Inline methods of Path and OsString 2021-01-22 18:46:00 +01:00
primitive_docs.rs Auto merge of #80590 - camelid:bool-never-docs, r=nagisa 2021-01-03 12:21:12 +00:00
process.rs Auto merge of #78439 - lzutao:rm-clouldabi, r=Mark-Simulacrum 2020-11-23 19:01:19 +00:00
rt.rs Prevent __rust_begin_short_backtrace frames from being tail-call optimised away 2020-08-07 19:31:25 +01:00
time.rs Drop support for cloudabi targets 2020-11-22 17:11:41 -05:00