about summary refs log tree commit diff
diff options
context:
space:
mode:
authorDylan DPC <dylan.dpc@gmail.com>2021-02-23 02:51:49 +0100
committerGitHub <noreply@github.com>2021-02-23 02:51:49 +0100
commit7b9ef2fde4233a30b15bc7b92004a4cc0bb22dc5 (patch)
tree522a56ddfde30e0532919fa6706250ff3f1a3a4a
parentc3de8ab9082be2c838132f2547d681633c2bb6fc (diff)
parent1abcdfe4493b781cea654840b497674907038faf (diff)
downloadrust-7b9ef2fde4233a30b15bc7b92004a4cc0bb22dc5.tar.gz
rust-7b9ef2fde4233a30b15bc7b92004a4cc0bb22dc5.zip
Rollup merge of #81984 - sunfishcode:wasi-link, r=alexcrichton
Make WASI's `hard_link` behavior match other platforms.

Following #78026, `std::fs::hard_link` on most platforms does not follow
symlinks. Change the WASI implementation to also not follow symlinks.

r? ```@alexcrichton```
-rw-r--r--library/std/src/sys/wasi/fs.rs8
1 files changed, 2 insertions, 6 deletions
diff --git a/library/std/src/sys/wasi/fs.rs b/library/std/src/sys/wasi/fs.rs
index 4134ef67671..83debdfc860 100644
--- a/library/std/src/sys/wasi/fs.rs
+++ b/library/std/src/sys/wasi/fs.rs
@@ -557,12 +557,8 @@ pub fn symlink(original: &Path, link: &Path) -> io::Result<()> {
 pub fn link(original: &Path, link: &Path) -> io::Result<()> {
     let (original, original_file) = open_parent(original)?;
     let (link, link_file) = open_parent(link)?;
-    original.link(
-        wasi::LOOKUPFLAGS_SYMLINK_FOLLOW,
-        osstr2str(original_file.as_ref())?,
-        &link,
-        osstr2str(link_file.as_ref())?,
-    )
+    // Pass 0 as the flags argument, meaning don't follow symlinks.
+    original.link(0, osstr2str(original_file.as_ref())?, &link, osstr2str(link_file.as_ref())?)
 }
 
 pub fn stat(p: &Path) -> io::Result<FileAttr> {