Skip to content

Commit

Permalink
Rollup merge of rust-lang#81984 - sunfishcode:wasi-link, r=alexcrichton
Browse files Browse the repository at this point in the history
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.

r? ``@alexcrichton``
  • Loading branch information
Dylan-DPC committed Feb 23, 2021
2 parents 299ea9d + 1abcdfe commit f30f76b
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions library/std/src/sys/wasi/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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> {
Expand Down

0 comments on commit f30f76b

Please sign in to comment.