From f38a810d26da9f91284f579a3b30209ad7f640b2 Mon Sep 17 00:00:00 2001 From: "M.Amin Rayej" Date: Tue, 14 May 2024 17:29:06 +0330 Subject: [PATCH 1/3] redirect child node --- lib/virtual-fs/src/mem_fs/filesystem.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/virtual-fs/src/mem_fs/filesystem.rs b/lib/virtual-fs/src/mem_fs/filesystem.rs index c1d72bc493b..17ce1bf31df 100644 --- a/lib/virtual-fs/src/mem_fs/filesystem.rs +++ b/lib/virtual-fs/src/mem_fs/filesystem.rs @@ -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) From bc326010aaac64a53b43962f58fd429766128bfa Mon Sep 17 00:00:00 2001 From: "M.Amin Rayej" Date: Tue, 14 May 2024 17:30:22 +0330 Subject: [PATCH 2/3] add wasi-fyi test --- tests/wasi-fyi/fs_remove_dir_all.rs | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 tests/wasi-fyi/fs_remove_dir_all.rs diff --git a/tests/wasi-fyi/fs_remove_dir_all.rs b/tests/wasi-fyi/fs_remove_dir_all.rs new file mode 100644 index 00000000000..51c8e9d732b --- /dev/null +++ b/tests/wasi-fyi/fs_remove_dir_all.rs @@ -0,0 +1,6 @@ +use std::fs; + +fn main() { + assert!(fs::create_dir_all("/fyi/foo/bar").is_ok()); + assert!(fs::remove_dir_all("/fyi/foo").is_ok()); +} \ No newline at end of file From 7d26efc1ee75566e2496b4bd2b94d9511195cc6a Mon Sep 17 00:00:00 2001 From: "M.Amin Rayej" Date: Tue, 14 May 2024 17:56:47 +0330 Subject: [PATCH 3/3] use stronger assertions in the test --- tests/wasi-fyi/fs_remove_dir_all.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/tests/wasi-fyi/fs_remove_dir_all.rs b/tests/wasi-fyi/fs_remove_dir_all.rs index 51c8e9d732b..fcfba4cc94e 100644 --- a/tests/wasi-fyi/fs_remove_dir_all.rs +++ b/tests/wasi-fyi/fs_remove_dir_all.rs @@ -2,5 +2,14 @@ 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!["bar", "baz"] + ); assert!(fs::remove_dir_all("/fyi/foo").is_ok()); -} \ No newline at end of file + assert!(fs::read_dir("/fyi/foo").is_err()); +}