mirror of
https://github.com/DragonOS-Community/DragonOS.git
synced 2025-06-09 02:46:47 +00:00
* 添加sysfs * 注册sysfs * 添加sysfs相关 * 添加rust-anlyzer辅助配置 * 将设备与sysfs相关联 * 添加单独的文件管理sysfs下的文件夹
34 lines
1.1 KiB
Rust
34 lines
1.1 KiB
Rust
use super::{LockedSysFSInode, SYS_FS_INODE};
|
||
use crate::{filesystem::vfs::IndexNode, syscall::SystemError};
|
||
use alloc::sync::Arc;
|
||
|
||
/// @brief: 注册fs,在sys/fs下是生成文件夹
|
||
/// @parameter fs_name: 类文件夹名
|
||
/// @return: 操作成功,返回inode,操作失败,返回错误码
|
||
#[inline]
|
||
#[allow(dead_code)]
|
||
pub fn fs_register(fs_name: &str) -> Result<Arc<dyn IndexNode>, SystemError> {
|
||
let binding: Arc<dyn IndexNode> = SYS_FS_INODE();
|
||
binding
|
||
.as_any_ref()
|
||
.downcast_ref::<LockedSysFSInode>()
|
||
.ok_or(SystemError::E2BIG)
|
||
.unwrap()
|
||
.add_dir(fs_name)
|
||
}
|
||
|
||
/// @brief: 注销fs,在sys/fs删除文件夹
|
||
/// @parameter fs_name: 总线文件夹名
|
||
/// @return: 操作成功,返回(),操作失败,返回错误码
|
||
#[inline]
|
||
#[allow(dead_code)]
|
||
pub fn fs_unregister(fs_name: &str) -> Result<(), SystemError> {
|
||
let binding: Arc<dyn IndexNode> = SYS_FS_INODE();
|
||
binding
|
||
.as_any_ref()
|
||
.downcast_ref::<LockedSysFSInode>()
|
||
.ok_or(SystemError::E2BIG)
|
||
.unwrap()
|
||
.remove(fs_name)
|
||
}
|