From 0060c91cfc9b8c0a73e7a23e16cddf8ac09440fb Mon Sep 17 00:00:00 2001 From: Dan Gohman Date: Wed, 10 Feb 2021 17:52:36 -0800 Subject: [PATCH] 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. --- library/std/src/sys/wasi/fs.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/library/std/src/sys/wasi/fs.rs b/library/std/src/sys/wasi/fs.rs index 4134ef676719c..6050620729f83 100644 --- a/library/std/src/sys/wasi/fs.rs +++ b/library/std/src/sys/wasi/fs.rs @@ -557,8 +557,9 @@ 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)?; + // Pass 0 as the flags argument, meaning don't follow symlinks. original.link( - wasi::LOOKUPFLAGS_SYMLINK_FOLLOW, + 0, osstr2str(original_file.as_ref())?, &link, osstr2str(link_file.as_ref())?,