mirror of
https://github.com/asterinas/asterinas.git
synced 2025-06-27 19:33:23 +00:00
Add sysfs implementation
This commit is contained in:
committed by
Tate, Hongliang Tian
parent
3a5f270ee9
commit
79b0866259
27
kernel/src/fs/sysfs/mod.rs
Normal file
27
kernel/src/fs/sysfs/mod.rs
Normal file
@ -0,0 +1,27 @@
|
||||
// SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
mod fs;
|
||||
mod inode;
|
||||
#[cfg(ktest)]
|
||||
mod test;
|
||||
|
||||
use alloc::sync::Arc;
|
||||
|
||||
use spin::Once;
|
||||
|
||||
pub use self::{fs::SysFs, inode::SysFsInode};
|
||||
|
||||
static SYSFS_SINGLETON: Once<Arc<SysFs>> = Once::new();
|
||||
|
||||
/// Returns a reference to the global SysFs instance. Panics if not initialized.
|
||||
pub fn singleton() -> &'static Arc<SysFs> {
|
||||
SYSFS_SINGLETON.get().expect("SysFs not initialized")
|
||||
}
|
||||
|
||||
/// Initializes the SysFs singleton.
|
||||
/// Ensures that the singleton is created by calling it.
|
||||
/// Should be called during kernel filesystem initialization, *after* systree::init().
|
||||
pub fn init() {
|
||||
// Ensure systree is initialized first. This should be handled by the kernel's init order.
|
||||
SYSFS_SINGLETON.call_once(|| SysFs::new());
|
||||
}
|
Reference in New Issue
Block a user