Dir::hard_link: dont support symlink following

if we're asked to follow symlinks, give ERRNO_INVAL instead.
This commit is contained in:
Pat Hickey
2021-01-25 17:07:43 -08:00
parent a993090e30
commit fded424e68
3 changed files with 4 additions and 3 deletions

View File

@@ -200,7 +200,6 @@ impl WasiDir for Dir {
fn hard_link(
&self,
src_path: &str,
symlink_follow: bool, // XXX not in cap-std yet
target_dir: &dyn WasiDir,
target_path: &str,
) -> Result<(), Error> {

View File

@@ -32,7 +32,6 @@ pub trait WasiDir {
fn hard_link(
&self,
path: &str,
symlink_follow: bool,
target_dir: &dyn WasiDir,
target_path: &str,
) -> Result<(), Error>;

View File

@@ -749,10 +749,13 @@ impl<'a> wasi_snapshot_preview1::WasiSnapshotPreview1 for WasiCtx {
.get_dir(u32::from(target_fd))?
.get_cap(DirCaps::LINK_TARGET)?;
let symlink_follow = src_flags.contains(types::Lookupflags::SYMLINK_FOLLOW);
if symlink_follow {
return Err(Error::invalid_argument()
.context("symlink following on path_link is not supported"));
}
src_dir.hard_link(
src_path.as_str()?.deref(),
symlink_follow,
target_dir.deref(),
target_path.as_str()?.deref(),
)