Skip to content

Commit

Permalink
Make WASI's hard_link behavior match other platforms.
Browse files Browse the repository at this point in the history
Following rust-lang#78026, `std::fs::hard_link` on most platforms does not follow
symlinks. Change the WASI implementation to also not follow symlinks.
  • Loading branch information
sunfishcode committed Feb 11, 2021
1 parent e708cbd commit 0060c91
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion library/std/src/sys/wasi/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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())?,
Expand Down

0 comments on commit 0060c91

Please sign in to comment.