Skip to content

Commit

Permalink
redirect to child node in a different fs (#4689)
Browse files Browse the repository at this point in the history
  • Loading branch information
maminrayej authored May 14, 2024
2 parents 63fb0a1 + 7d26efc commit b19a1e1
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/virtual-fs/src/mem_fs/filesystem.rs
Original file line number Diff line number Diff line change
Expand Up @@ -739,7 +739,11 @@ impl FileSystemInner {
Some(Err(FsError::DirectoryNotEmpty))
}
}

Node::ArcDirectory(ArcDirectoryNode { name, fs, path, .. })
if name.as_os_str() == name_of_directory =>
{
Some(Ok((0, InodeResolution::Redirect(fs.clone(), path.clone()))))
}
_ => None,
})
.ok_or(FsError::InvalidInput)
Expand Down
15 changes: 15 additions & 0 deletions tests/wasi-fyi/fs_remove_dir_all.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
use std::fs;

fn main() {
assert!(fs::create_dir_all("/fyi/foo/bar").is_ok());
assert!(fs::create_dir_all("/fyi/foo/baz").is_ok());
assert_eq!(
fs::read_dir("/fyi/foo")
.unwrap()
.map(|e| e.unwrap().file_name())
.collect::<Vec<_>>(),
vec!["bar", "baz"]
);
assert!(fs::remove_dir_all("/fyi/foo").is_ok());
assert!(fs::read_dir("/fyi/foo").is_err());
}

0 comments on commit b19a1e1

Please sign in to comment.