Skip to content

Commit 0060c91

Browse files
committed
Make WASI's hard_link behavior match other platforms.
Following rust-lang#78026, `std::fs::hard_link` on most platforms does not follow symlinks. Change the WASI implementation to also not follow symlinks.
1 parent e708cbd commit 0060c91

File tree

1 file changed

+2
-1
lines changed
  • library/std/src/sys/wasi

1 file changed

+2
-1
lines changed

library/std/src/sys/wasi/fs.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -557,8 +557,9 @@ pub fn symlink(original: &Path, link: &Path) -> io::Result<()> {
557557
pub fn link(original: &Path, link: &Path) -> io::Result<()> {
558558
let (original, original_file) = open_parent(original)?;
559559
let (link, link_file) = open_parent(link)?;
560+
// Pass 0 as the flags argument, meaning don't follow symlinks.
560561
original.link(
561-
wasi::LOOKUPFLAGS_SYMLINK_FOLLOW,
562+
0,
562563
osstr2str(original_file.as_ref())?,
563564
&link,
564565
osstr2str(link_file.as_ref())?,

0 commit comments

Comments
 (0)