Refine Devpts with new metadata api

This commit is contained in:
LI Qing
2024-05-24 10:33:38 +08:00
committed by Tate, Hongliang Tian
parent 494c88e993
commit ce2e0cee92
3 changed files with 9 additions and 10 deletions

View File

@ -41,18 +41,17 @@ const MAX_PTY_NUM: usize = 4096;
///
/// Actually, the "/dev/ptmx" is a symlink to the real device at "/dev/pts/ptmx".
pub struct DevPts {
root: Arc<RootInode>,
sb: SuperBlock,
root: Arc<RootInode>,
index_alloc: Mutex<IdAlloc>,
this: Weak<Self>,
}
impl DevPts {
pub fn new() -> Arc<Self> {
let sb = SuperBlock::new(DEVPTS_MAGIC, BLOCK_SIZE, NAME_MAX);
Arc::new_cyclic(|weak_self| Self {
root: RootInode::new(weak_self.clone(), &sb),
sb,
sb: SuperBlock::new(DEVPTS_MAGIC, BLOCK_SIZE, NAME_MAX),
root: RootInode::new(weak_self.clone()),
index_alloc: Mutex::new(IdAlloc::with_capacity(MAX_PTY_NUM)),
this: weak_self.clone(),
})
@ -112,14 +111,14 @@ struct RootInode {
}
impl RootInode {
pub fn new(fs: Weak<DevPts>, sb: &SuperBlock) -> Arc<Self> {
pub fn new(fs: Weak<DevPts>) -> Arc<Self> {
Arc::new(Self {
ptmx: Ptmx::new(sb, fs.clone()),
ptmx: Ptmx::new(fs.clone()),
slaves: RwLock::new(SlotVec::new()),
metadata: RwLock::new(Metadata::new_dir(
ROOT_INO,
InodeMode::from_bits_truncate(0o755),
sb,
BLOCK_SIZE,
)),
fs,
})