Update mountfs

This commit is contained in:
LI Qing 2021-11-15 12:50:45 +08:00 committed by Zongmin.Gu
parent 821ea843ae
commit b61188889d
2 changed files with 10 additions and 6 deletions

2
deps/sefs vendored

@ -1 +1 @@
Subproject commit 5fd86adbfa0b173d10d5afebd871a237bf25f688 Subproject commit 6eaf1d2f50327631cf62a965f30d56ce40934c76

@ -75,7 +75,7 @@ pub fn open_root_fs_according_to(
} }
pub fn mount_nonroot_fs_according_to( pub fn mount_nonroot_fs_according_to(
root: &MNode, root: &Arc<dyn INode>,
mount_configs: &Vec<ConfigMount>, mount_configs: &Vec<ConfigMount>,
user_key: &Option<sgx_key_128bit_t>, user_key: &Option<sgx_key_128bit_t>,
) -> Result<()> { ) -> Result<()> {
@ -123,11 +123,15 @@ pub fn mount_nonroot_fs_according_to(
Ok(()) Ok(())
} }
pub fn mount_fs_at(fs: Arc<dyn FileSystem>, parent_inode: &MNode, abs_path: &Path) -> Result<()> { pub fn mount_fs_at(
let mut mount_dir = parent_inode.find(false, ".")?; fs: Arc<dyn FileSystem>,
parent_inode: &Arc<dyn INode>,
abs_path: &Path,
) -> Result<()> {
let mut mount_dir = parent_inode.find(".")?;
// The first component of abs_path is the RootDir, skip it. // The first component of abs_path is the RootDir, skip it.
for dirname in abs_path.iter().skip(1) { for dirname in abs_path.iter().skip(1) {
mount_dir = match mount_dir.find(false, dirname.to_str().unwrap()) { mount_dir = match mount_dir.find(dirname.to_str().unwrap()) {
Ok(existing_dir) => { Ok(existing_dir) => {
if existing_dir.metadata()?.type_ != FileType::Dir { if existing_dir.metadata()?.type_ != FileType::Dir {
return_errno!(EIO, "not a directory"); return_errno!(EIO, "not a directory");
@ -137,7 +141,7 @@ pub fn mount_fs_at(fs: Arc<dyn FileSystem>, parent_inode: &MNode, abs_path: &Pat
Err(_) => return_errno!(ENOENT, "Mount point does not exist"), Err(_) => return_errno!(ENOENT, "Mount point does not exist"),
}; };
} }
mount_dir.mount(fs); mount_dir.downcast_ref::<MNode>().unwrap().mount(fs);
Ok(()) Ok(())
} }