1 use super::{LockedSysFSInode, SYS_FS_INODE};
2 use crate::{filesystem::vfs::IndexNode, syscall::SystemError};
3 use alloc::sync::Arc;
4 
5 /// @brief: 注册fs,在sys/fs下是生成文件夹
6 /// @parameter fs_name: 类文件夹名
7 /// @return: 操作成功,返回inode,操作失败,返回错误码
8 #[inline]
9 #[allow(dead_code)]
fs_register(fs_name: &str) -> Result<Arc<dyn IndexNode>, SystemError>10 pub fn fs_register(fs_name: &str) -> Result<Arc<dyn IndexNode>, SystemError> {
11     let binding: Arc<dyn IndexNode> = SYS_FS_INODE();
12     binding
13         .as_any_ref()
14         .downcast_ref::<LockedSysFSInode>()
15         .ok_or(SystemError::E2BIG)
16         .unwrap()
17         .add_dir(fs_name)
18 }
19 
20 /// @brief: 注销fs,在sys/fs删除文件夹
21 /// @parameter fs_name: 总线文件夹名
22 /// @return: 操作成功,返回(),操作失败,返回错误码
23 #[inline]
24 #[allow(dead_code)]
fs_unregister(fs_name: &str) -> Result<(), SystemError>25 pub fn fs_unregister(fs_name: &str) -> Result<(), SystemError> {
26     let binding: Arc<dyn IndexNode> = SYS_FS_INODE();
27     binding
28         .as_any_ref()
29         .downcast_ref::<LockedSysFSInode>()
30         .ok_or(SystemError::E2BIG)
31         .unwrap()
32         .remove(fs_name)
33 }
34