Path symlink follow (#1284)
* Fix the tests for correctly following symlinks. * Correctly follow symlinks in path_link.
This commit is contained in:
committed by
GitHub
parent
bcddce5fe0
commit
c50c24e699
@@ -71,15 +71,24 @@ pub(crate) fn path_create_directory(base: &File, path: &str) -> WasiResult<()> {
|
||||
unsafe { mkdirat(base.as_raw_fd(), path, Mode::from_bits_truncate(0o777)) }.map_err(Into::into)
|
||||
}
|
||||
|
||||
pub(crate) fn path_link(resolved_old: PathGet, resolved_new: PathGet) -> WasiResult<()> {
|
||||
pub(crate) fn path_link(
|
||||
resolved_old: PathGet,
|
||||
resolved_new: PathGet,
|
||||
follow_symlinks: bool,
|
||||
) -> WasiResult<()> {
|
||||
use yanix::file::{linkat, AtFlag};
|
||||
let flags = if follow_symlinks {
|
||||
AtFlag::SYMLINK_FOLLOW
|
||||
} else {
|
||||
AtFlag::empty()
|
||||
};
|
||||
unsafe {
|
||||
linkat(
|
||||
resolved_old.dirfd().as_raw_fd(),
|
||||
resolved_old.path(),
|
||||
resolved_new.dirfd().as_raw_fd(),
|
||||
resolved_new.path(),
|
||||
AtFlag::SYMLINK_FOLLOW,
|
||||
flags,
|
||||
)
|
||||
}
|
||||
.map_err(Into::into)
|
||||
|
||||
Reference in New Issue
Block a user