mirror of
https://github.com/asterinas/asterinas.git
synced 2025-06-20 13:06:33 +00:00
Refine Devpts with new metadata api
This commit is contained in:
committed by
Tate, Hongliang Tian
parent
494c88e993
commit
ce2e0cee92
@ -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,
|
||||
})
|
||||
|
@ -24,13 +24,13 @@ pub struct Ptmx {
|
||||
struct Inner(Weak<DevPts>);
|
||||
|
||||
impl Ptmx {
|
||||
pub fn new(sb: &SuperBlock, fs: Weak<DevPts>) -> Arc<Self> {
|
||||
pub fn new(fs: Weak<DevPts>) -> Arc<Self> {
|
||||
let inner = Inner(fs);
|
||||
Arc::new(Self {
|
||||
metadata: RwLock::new(Metadata::new_device(
|
||||
PTMX_INO,
|
||||
InodeMode::from_bits_truncate(0o666),
|
||||
sb,
|
||||
super::BLOCK_SIZE,
|
||||
&inner,
|
||||
)),
|
||||
inner,
|
||||
|
@ -24,7 +24,7 @@ impl PtySlaveInode {
|
||||
metadata: RwLock::new(Metadata::new_device(
|
||||
device.index() as usize + FIRST_SLAVE_INO,
|
||||
InodeMode::from_bits_truncate(0o620),
|
||||
&fs.upgrade().unwrap().sb(),
|
||||
super::BLOCK_SIZE,
|
||||
device.as_ref(),
|
||||
)),
|
||||
device,
|
||||
|
Reference in New Issue
Block a user