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```
This commit is contained in:
Dylan DPC 2021-02-23 02:51:49 +01:00 committed by GitHub
commit 7b9ef2fde4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 6 deletions

View File

@ -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> {