Skip to content

Commit 7b9ef2f

Browse files
authored
Rollup merge of rust-lang#81984 - sunfishcode:wasi-link, r=alexcrichton
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```
2 parents c3de8ab + 1abcdfe commit 7b9ef2f

File tree

1 file changed

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

1 file changed

+2
-6
lines changed

Diff for: library/std/src/sys/wasi/fs.rs

+2-6
Original file line numberDiff line numberDiff line change
@@ -557,12 +557,8 @@ 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-
original.link(
561-
wasi::LOOKUPFLAGS_SYMLINK_FOLLOW,
562-
osstr2str(original_file.as_ref())?,
563-
&link,
564-
osstr2str(link_file.as_ref())?,
565-
)
560+
// Pass 0 as the flags argument, meaning don't follow symlinks.
561+
original.link(0, osstr2str(original_file.as_ref())?, &link, osstr2str(link_file.as_ref())?)
566562
}
567563

568564
pub fn stat(p: &Path) -> io::Result<FileAttr> {

0 commit comments

Comments
 (0)