diff --git a/kernel/src/init/initial_kthread.rs b/kernel/src/init/initial_kthread.rs index 25fb21911..a1f2dedd0 100644 --- a/kernel/src/init/initial_kthread.rs +++ b/kernel/src/init/initial_kthread.rs @@ -141,7 +141,7 @@ fn run_init_process( trap_frame: &mut TrapFrame, ) -> Result<(), SystemError> { compiler_fence(Ordering::SeqCst); - ProcessManager::current_pcb().set_nsproxy(NsProxy::new()); // 初始化init进程的namespace + ProcessManager::current_pcb().set_nsproxy(NsProxy::default()); // 初始化init进程的namespace let path = proc_init_info.proc_name.to_str().unwrap(); Syscall::do_execve( diff --git a/kernel/src/libs/ida/src/lib.rs b/kernel/src/libs/ida/src/lib.rs deleted file mode 100644 index ac25d557c..000000000 --- a/kernel/src/libs/ida/src/lib.rs +++ /dev/null @@ -1,55 +0,0 @@ -#![no_std] -#![feature(core_intrinsics)] -#![allow(clippy::needless_return)] - -use core::intrinsics::unlikely; -use core::sync::atomic::{AtomicBool, AtomicUsize, Ordering}; - -/// id分配器 -/// -/// TODO: 当前只是为了简单实现功能,将来这里应使用类似linux的ida的方式去实现 -#[derive(Debug)] -pub struct IdAllocator { - current_id: AtomicUsize, - max_id: usize, - dead: AtomicBool, -} - -impl IdAllocator { - /// 创建一个新的id分配器 - pub const fn new(initial_id: usize, max_id: usize) -> Self { - Self { - current_id: AtomicUsize::new(initial_id), - max_id, - dead: AtomicBool::new(false), - } - } - - /// 分配一个新的id - /// - /// ## 返回 - /// - /// 如果分配成功,返回Some(id),否则返回None - pub fn alloc(&self) -> Option { - if unlikely(self.dead.load(Ordering::SeqCst)) { - return None; - } - - let ret = self.current_id.fetch_add(1, Ordering::SeqCst); - // 如果id溢出,panic - if ret == self.max_id { - self.dead.store(true, Ordering::SeqCst); - return None; - } - - return Some(ret); - } - - pub fn free(&self, _id: usize) { - // todo: free - } - - pub fn get_max_id(&self) -> usize { - self.max_id - } -} diff --git a/kernel/src/namespaces/mnt_namespace.rs b/kernel/src/namespaces/mnt_namespace.rs index e5312d82c..01f2dc226 100644 --- a/kernel/src/namespaces/mnt_namespace.rs +++ b/kernel/src/namespaces/mnt_namespace.rs @@ -11,10 +11,8 @@ use alloc::sync::Arc; use system_error::SystemError; use super::namespace::Namespace; -use super::namespace::NsOperations; use super::ucount::Ucount::MntNamespaces; -use super::{namespace::NsCommon, ucount::UCounts, user_namespace::UserNamespace}; -use crate::container_of; +use super::{ucount::UCounts, user_namespace::UserNamespace}; use crate::filesystem::vfs::mount::MountFSInode; use crate::filesystem::vfs::IndexNode; use crate::filesystem::vfs::InodeId; @@ -26,10 +24,8 @@ use crate::process::fork::CloneFlags; use crate::process::ProcessManager; use crate::syscall::Syscall; #[allow(dead_code)] -#[derive(Debug)] +#[derive(Debug, Clone)] pub struct MntNamespace { - /// namespace 共有的部分 - ns_common: Arc, /// 关联的用户名字空间 user_ns: Arc, /// 资源计数器 @@ -37,11 +33,11 @@ pub struct MntNamespace { /// 根文件系统 root: Option>, /// 红黑树用于挂载所有挂载点 - mounts: RBTree, + mounts: Arc>, /// 等待队列 - poll: WaitQueue, + poll: Arc, /// 挂载序列号 - seq: AtomicU64, + seq: Arc, /// 挂载点的数量 nr_mounts: u32, /// 待处理的挂载点 @@ -50,7 +46,16 @@ pub struct MntNamespace { impl Default for MntNamespace { fn default() -> Self { - Self::new() + Self { + user_ns: Arc::new(UserNamespace::default()), + ucounts: Arc::new(UCounts::default()), + root: None, + mounts: Arc::new(RBTree::new()), + poll: Arc::new(WaitQueue::default()), + seq: Arc::new(AtomicU64::new(0)), + nr_mounts: 0, + pending_mounts: 0, + } } } @@ -69,18 +74,15 @@ pub struct FsStruct { } impl Default for FsStruct { fn default() -> Self { - Self::new() - } -} - -impl FsStruct { - pub fn new() -> Self { Self { umask: 0o22, root: ROOT_INODE(), pwd: ROOT_INODE(), } } +} + +impl FsStruct { pub fn set_root(&mut self, inode: Arc) { self.root = inode; } @@ -90,72 +92,41 @@ impl FsStruct { } impl Namespace for MntNamespace { - fn ns_common_to_ns(ns_common: Arc) -> Arc { - let ns_common_ptr = Arc::as_ptr(&ns_common); - container_of!(ns_common_ptr, MntNamespace, ns_common) + fn name(&self) -> String { + "mnt".to_string() } -} - -impl MntNsOperations { - pub fn new(name: String) -> Self { - Self { - name, - clone_flags: CloneFlags::CLONE_NEWNS, - } + fn get(&self, pid: crate::process::Pid) -> Option> { + ProcessManager::find(pid) + .map(|pcb| pcb.get_nsproxy().read().mnt_namespace.clone() as Arc) } -} -impl NsOperations for MntNsOperations { - fn get(&self, pid: crate::process::Pid) -> Option> { - let pcb = ProcessManager::find(pid); - pcb.map(|pcb| pcb.get_nsproxy().read().mnt_namespace.ns_common.clone()) + fn clone_flags(&self) -> CloneFlags { + CloneFlags::CLONE_NEWNS } - // 不存在这个方法 - fn get_parent(&self, _ns_common: Arc) -> Result, SystemError> { - unreachable!() - } - fn install( - &self, - nsset: &mut super::NsSet, - ns_common: Arc, - ) -> Result<(), SystemError> { + + fn put(&self) {} + + fn install(&self, nsset: &mut super::NsSet) -> Result<(), SystemError> { let nsproxy = &mut nsset.nsproxy; - let mnt_ns = MntNamespace::ns_common_to_ns(ns_common); - if mnt_ns.is_anon_ns() { + if self.is_anon_ns() { return Err(SystemError::EINVAL); } - nsproxy.mnt_namespace = mnt_ns; + nsproxy.mnt_namespace = Arc::new(self.clone()); nsset.fs.lock().set_pwd(ROOT_INODE()); nsset.fs.lock().set_root(ROOT_INODE()); Ok(()) } - fn owner(&self, ns_common: Arc) -> Arc { - let mnt_ns = MntNamespace::ns_common_to_ns(ns_common); - mnt_ns.user_ns.clone() + + fn owner(&self) -> Arc { + self.user_ns.clone() } - fn put(&self, ns_common: Arc) { - let pid_ns = MntNamespace::ns_common_to_ns(ns_common); + // 不存在这个方法 + fn get_parent(&self) -> Result, SystemError> { + unreachable!() } } impl MntNamespace { - pub fn new() -> Self { - let ns_common = Arc::new(NsCommon::new(Box::new(MntNsOperations::new( - "mnt".to_string(), - )))); - - Self { - ns_common, - user_ns: Arc::new(UserNamespace::new()), - ucounts: Arc::new(UCounts::new()), - root: None, - mounts: RBTree::new(), - poll: WaitQueue::default(), - seq: AtomicU64::new(0), - nr_mounts: 0, - pending_mounts: 0, - } - } /// anon 用来判断是否是匿名的.匿名函数的问题还需要考虑 pub fn create_mnt_namespace( &self, @@ -167,20 +138,16 @@ impl MntNamespace { return Err(SystemError::ENOSPC); } let ucounts = ucounts.unwrap(); - let ns_common = Arc::new(NsCommon::new(Box::new(MntNsOperations::new( - "mnt".to_string(), - )))); - let seq = AtomicU64::new(0); + let seq = Arc::new(AtomicU64::new(0)); if !anon { seq.fetch_add(1, core::sync::atomic::Ordering::SeqCst); } Ok(Self { - ns_common, user_ns, ucounts, root: None, - mounts: RBTree::new(), - poll: WaitQueue::default(), + mounts: Arc::new(RBTree::new()), + poll: Arc::new(WaitQueue::default()), seq, nr_mounts: 0, pending_mounts: 0, diff --git a/kernel/src/namespaces/mod.rs b/kernel/src/namespaces/mod.rs index a9043a125..817d0bb05 100644 --- a/kernel/src/namespaces/mod.rs +++ b/kernel/src/namespaces/mod.rs @@ -30,17 +30,14 @@ pub struct NsProxy { } impl Default for NsProxy { fn default() -> Self { - Self::new() + Self { + pid_namespace: Arc::new(PidNamespace::default()), + mnt_namespace: Arc::new(MntNamespace::default()), + } } } impl NsProxy { - pub fn new() -> Self { - Self { - pid_namespace: Arc::new(PidNamespace::new()), - mnt_namespace: Arc::new(MntNamespace::new()), - } - } pub fn set_pid_namespace(&mut self, new_pid_ns: Arc) { self.pid_namespace = new_pid_ns; } @@ -55,10 +52,10 @@ pub fn create_new_namespaces( pcb: &Arc, user_ns: Arc, ) -> Result { - let mut nsproxy = NsProxy::new(); + let mut nsproxy = NsProxy::default(); // pid_namespace let new_pid_ns = if (clone_flags & CloneFlags::CLONE_NEWPID.bits()) != 0 { - Arc::new(PidNamespace::new().create_pid_namespace( + Arc::new(PidNamespace::default().create_pid_namespace( pcb.get_nsproxy().read().pid_namespace.clone(), user_ns.clone(), )?) @@ -69,7 +66,7 @@ pub fn create_new_namespaces( // mnt_namespace let new_mnt_ns = if clone_flags & CloneFlags::CLONE_NEWNS.bits() != 0 { - Arc::new(MntNamespace::new().create_mnt_namespace(user_ns.clone(), false)?) + Arc::new(MntNamespace::default().create_mnt_namespace(user_ns.clone(), false)?) } else { pcb.get_nsproxy().read().mnt_namespace.clone() }; @@ -77,16 +74,3 @@ pub fn create_new_namespaces( Ok(nsproxy) } - -#[macro_export] -macro_rules! container_of { - ($ptr:expr, $struct:path, $field:ident) => { - unsafe { - let dummy = core::mem::MaybeUninit::<$struct>::uninit(); - let dummy_ptr = dummy.as_ptr(); - let field_ptr = &(*dummy_ptr).$field as *const _ as usize; - let offset = field_ptr - dummy_ptr as usize; - Arc::from_raw(($ptr as *const u8).wrapping_sub(offset) as *mut $struct) - } - }; -} diff --git a/kernel/src/namespaces/namespace.rs b/kernel/src/namespaces/namespace.rs index 06b0e6aca..f673a61c4 100644 --- a/kernel/src/namespaces/namespace.rs +++ b/kernel/src/namespaces/namespace.rs @@ -1,4 +1,5 @@ #![allow(dead_code, unused_variables, unused_imports)] +use alloc::string::String; use core::fmt::Debug; use crate::filesystem::procfs::ProcFSInode; @@ -12,30 +13,17 @@ use system_error::SystemError; // 目前无credit功能,采用全局静态的user_namespace lazy_static! { - pub static ref USER_NS: Arc = Arc::new(UserNamespace::new()); + pub static ref USER_NS: Arc = Arc::new(UserNamespace::default()); } use super::{create_new_namespaces, NsProxy, NsSet}; -pub trait NsOperations: Send + Sync + Debug { - fn get(&self, pid: Pid) -> Option>; - fn put(&self, ns_common: Arc); - fn install(&self, nsset: &mut NsSet, ns_common: Arc) -> Result<(), SystemError>; - fn owner(&self, ns_common: Arc) -> Arc; - fn get_parent(&self, ns_common: Arc) -> Result, SystemError>; -} -#[derive(Debug)] -pub struct NsCommon { - ops: Box, - stashed: Arc, -} - -impl NsCommon { - pub fn new(ops: Box) -> Self { - let inode = ROOT_INODE().find("proc").unwrap_or_else(|_| ROOT_INODE()); - Self { - ops, - stashed: inode, - } - } +pub trait Namespace: Send + Sync + Debug { + fn name(&self) -> String; + fn clone_flags(&self) -> CloneFlags; + fn get(&self, pid: Pid) -> Option>; + fn put(&self); + fn install(&self, nsset: &mut NsSet) -> Result<(), SystemError>; + fn owner(&self) -> Arc; + fn get_parent(&self) -> Result, SystemError>; } pub enum NsType { @@ -49,10 +37,6 @@ pub enum NsType { Time, } -pub trait Namespace { - fn ns_common_to_ns(ns_common: Arc) -> Arc; -} - pub fn check_unshare_flags(unshare_flags: u64) -> Result { let valid_flags = CloneFlags::CLONE_THREAD | CloneFlags::CLONE_FS diff --git a/kernel/src/namespaces/pid_namespace.rs b/kernel/src/namespaces/pid_namespace.rs index 7f1eb05b2..0ffbcdcb8 100644 --- a/kernel/src/namespaces/pid_namespace.rs +++ b/kernel/src/namespaces/pid_namespace.rs @@ -4,10 +4,8 @@ use alloc::vec::Vec; use super::namespace::Namespace; use super::ucount::Ucount::PidNamespaces; use super::NsSet; -use super::{namespace::NsCommon, ucount::UCounts, user_namespace::UserNamespace}; -use crate::container_of; +use super::{ucount::UCounts, user_namespace::UserNamespace}; use crate::filesystem::vfs::{IndexNode, ROOT_INODE}; -use crate::namespaces::namespace::NsOperations; use crate::process::fork::CloneFlags; use crate::process::ProcessManager; use crate::syscall::Syscall; @@ -25,10 +23,9 @@ const MAX_PID_NS_LEVEL: usize = 32; const PIDNS_ADDING: u32 = 1 << 31; const PID_MAX: usize = 4096; static PID_IDA: ida::IdAllocator = ida::IdAllocator::new(1, usize::MAX).unwrap(); -#[derive(Debug)] -#[repr(C)] +#[derive(Debug, Clone)] pub struct PidNamespace { - id_alloctor: RwLock, + id_alloctor: Arc>, /// 已经分配的进程数 pid_allocated: u32, /// 当前的pid_namespace所在的层数 @@ -41,13 +38,19 @@ pub struct PidNamespace { user_ns: Arc, /// 回收孤儿进程的init进程 child_reaper: Arc>, - /// namespace共有部分 - pub ns_common: Arc, } impl Default for PidNamespace { fn default() -> Self { - Self::new() + Self { + id_alloctor: Arc::new(RwLock::new(IdAllocator::new(1, PID_MAX).unwrap())), + pid_allocated: 1, + level: 0, + child_reaper: Arc::new(RwLock::new(Pid::from(1))), + parent: None, + ucounts: Arc::new(UCounts::default()), + user_ns: Arc::new(UserNamespace::default()), + } } } @@ -60,27 +63,23 @@ pub struct PidStrcut { impl Default for PidStrcut { fn default() -> Self { - Self::new() - } -} -#[derive(Debug, Clone)] -pub struct UPid { - pub nr: Pid, // 在该pid_namespace 中的pid - pub ns: Arc, -} - -impl PidStrcut { - pub fn new() -> Self { Self { level: 0, numbers: vec![UPid { nr: Pid::new(0), - ns: Arc::new(PidNamespace::new()), + ns: Arc::new(PidNamespace::default()), }], stashed: ROOT_INODE(), } } +} +#[derive(Debug, Clone)] +pub struct UPid { + pub nr: Pid, // 在该pid_namespace 中的pid + pub ns: Arc, +} +impl PidStrcut { pub fn put_pid(pid: PidStrcut) { let ns = pid.numbers[pid.level].ns.clone(); let id = pid.numbers[pid.level].nr.data(); @@ -151,53 +150,50 @@ impl PidNsOperations { } } } + impl Namespace for PidNamespace { - fn ns_common_to_ns(ns_common: Arc) -> Arc { - container_of!(Arc::as_ptr(&ns_common), PidNamespace, ns_common) + fn name(&self) -> String { + "pid".to_string() } -} - -impl NsOperations for PidNsOperations { - fn put(&self, ns_common: Arc) { - let _pid_ns = PidNamespace::ns_common_to_ns(ns_common); + fn put(&self) { // pid_ns 超出作用域自动drop 同时递归drop } - fn owner(&self, ns_common: Arc) -> Arc { - let pid_ns = PidNamespace::ns_common_to_ns(ns_common); - pid_ns.user_ns.clone() + fn owner(&self) -> Arc { + self.user_ns.clone() } - fn get_parent(&self, ns_common: Arc) -> Result, SystemError> { + fn get_parent(&self) -> Result, SystemError> { let current = ProcessManager::current_pid(); let pcb = ProcessManager::find(current).unwrap(); let active = pcb.pid_strcut().read().ns_of_pid(); - let mut pid_ns = &PidNamespace::ns_common_to_ns(ns_common).parent; + let mut pid_ns = &self.parent; while let Some(ns) = pid_ns { if Arc::ptr_eq(&active, ns) { - return Ok(ns.ns_common.clone()); + return Ok(ns.clone()); } pid_ns = &ns.parent; } Err(SystemError::EPERM) } - fn get(&self, pid: Pid) -> Option> { - let pcb = ProcessManager::find(pid); - pcb.map(|pcb| pcb.get_nsproxy().read().pid_namespace.ns_common.clone()) + fn get(&self, pid: Pid) -> Option> { + ProcessManager::find(pid) + .map(|pcb| pcb.get_nsproxy().read().pid_namespace.clone() as Arc) } - fn install(&self, nsset: &mut NsSet, ns_common: Arc) -> Result<(), SystemError> { + + fn install(&self, nsset: &mut NsSet) -> Result<(), SystemError> { let nsproxy = &mut nsset.nsproxy; let current = ProcessManager::current_pid(); let pcb = ProcessManager::find(current).unwrap(); let active = pcb.pid_strcut().read().ns_of_pid(); - let mut pid_ns = PidNamespace::ns_common_to_ns(ns_common); - if pid_ns.level < active.level { + if self.level < active.level { return Err(SystemError::EINVAL); } - while pid_ns.level > active.level { - if let Some(ns) = &pid_ns.parent { + let mut pid_ns: Arc = Arc::new(self.clone()); + while self.level > active.level { + if let Some(ns) = &self.parent { pid_ns = ns.clone(); } else { break; @@ -209,23 +205,11 @@ impl NsOperations for PidNsOperations { nsproxy.pid_namespace = pid_ns.clone(); Ok(()) } + fn clone_flags(&self) -> CloneFlags { + CloneFlags::CLONE_NEWPID + } } impl PidNamespace { - pub fn new() -> Self { - Self { - id_alloctor: RwLock::new(IdAllocator::new(1, PID_MAX).unwrap()), - pid_allocated: 1, - level: 0, - child_reaper: Arc::new(RwLock::new(Pid::from(1))), - parent: None, - ucounts: Arc::new(UCounts::new()), - user_ns: Arc::new(UserNamespace::new()), - ns_common: Arc::new(NsCommon::new(Box::new(PidNsOperations::new( - "pid".to_string(), - )))), - } - } - pub fn create_pid_namespace( &self, parent: Arc, @@ -242,18 +226,14 @@ impl PidNamespace { } let ucounts = ucounts.unwrap(); - let ns_common = Arc::new(NsCommon::new(Box::new(PidNsOperations::new( - "pid".to_string(), - )))); let child_reaper = parent.child_reaper.clone(); Ok(Self { - id_alloctor: RwLock::new(IdAllocator::new(1, PID_MAX).unwrap()), + id_alloctor: Arc::new(RwLock::new(IdAllocator::new(1, PID_MAX).unwrap())), pid_allocated: PIDNS_ADDING, level, ucounts, parent: Some(parent), user_ns, - ns_common, child_reaper, }) } diff --git a/kernel/src/namespaces/ucount.rs b/kernel/src/namespaces/ucount.rs index 358c8cef0..164edc959 100644 --- a/kernel/src/namespaces/ucount.rs +++ b/kernel/src/namespaces/ucount.rs @@ -48,13 +48,8 @@ pub struct UCounts { impl Default for UCounts { fn default() -> Self { - Self::new() - } -} -impl UCounts { - pub fn new() -> Self { Self { - ns: Arc::new(UserNamespace::new()), + ns: Arc::new(UserNamespace::default()), uid: 0, count: AtomicU32::new(1), ucount: (0..Ucount::Counts as usize) @@ -65,7 +60,8 @@ impl UCounts { .collect(), } } - +} +impl UCounts { fn alloc_ucounts(&self, ns: Arc, uid: usize) -> Arc { let mut counts = COUNT_MANAGER.counts.lock(); let key = UKey { diff --git a/kernel/src/namespaces/user_namespace.rs b/kernel/src/namespaces/user_namespace.rs index 2314ccfcb..7146d5f45 100644 --- a/kernel/src/namespaces/user_namespace.rs +++ b/kernel/src/namespaces/user_namespace.rs @@ -9,13 +9,12 @@ use alloc::string::ToString; use alloc::vec::Vec; use system_error::SystemError; -use crate::namespaces::namespace::NsCommon; use crate::namespaces::ucount::UCounts; use crate::process::fork::CloneFlags; use crate::process::Pid; use alloc::sync::Arc; -use super::namespace::NsOperations; +use super::namespace::Namespace; use super::ucount::Ucount::Counts; const UID_GID_MAP_MAX_BASE_EXTENTS: usize = 5; @@ -46,50 +45,57 @@ pub struct UserNamespace { level: u32, owner: usize, group: usize, - ns_common: Arc, flags: u32, pid: Arc>, pub ucounts: Option>, - pub ucount_max: Vec, //vec![u32; UCOUNT_COUNTS as usize], - pub rlimit_max: Vec, // vec![u32; UCOUNT_RLIMIT_COUNTS as usize], + pub ucount_max: Vec, + pub rlimit_max: Vec, } impl Default for UserNamespace { fn default() -> Self { - Self::new() - } -} -#[derive(Debug)] -struct UserNsOperations { - name: String, - clone_flags: CloneFlags, -} -impl UserNsOperations { - pub fn new(name: String) -> Self { Self { - name, - clone_flags: CloneFlags::CLONE_NEWUSER, + uid_map: UidGidMap::new(), + gid_map: UidGidMap::new(), + progid_map: UidGidMap::new(), + owner: 0, + level: 0, + group: 0, + flags: 1, + parent: None, + pid: Arc::new(RwLock::new(Pid::new(1))), + ucount_max: vec![UCOUNT_MAX; Counts as usize], + ucounts: None, + rlimit_max: vec![65535, 10, 32000, 64 * 1024], } } } -impl NsOperations for UserNsOperations { - fn get(&self, pid: Pid) -> Option> { +impl Namespace for UserNamespace { + fn name(&self) -> String { + "user".to_string() + } + + fn clone_flags(&self) -> CloneFlags { + CloneFlags::CLONE_NEWUSER + } + + fn get(&self, pid: Pid) -> Option> { unimplemented!() } - fn get_parent(&self, ns_common: Arc) -> Result, SystemError> { + + fn put(&self) { unimplemented!() } - fn install( - &self, - nsset: &mut super::NsSet, - ns_common: Arc, - ) -> Result<(), SystemError> { + + fn install(&self, nsset: &mut super::NsSet) -> Result<(), SystemError> { unimplemented!() } - fn owner(&self, ns_common: Arc) -> Arc { + + fn owner(&self) -> Arc { unimplemented!() } - fn put(&self, ns_common: Arc) { + + fn get_parent(&self) -> Result, SystemError> { unimplemented!() } } @@ -111,25 +117,3 @@ impl UidGidExtent { } } } - -impl UserNamespace { - pub fn new() -> Self { - Self { - uid_map: UidGidMap::new(), - gid_map: UidGidMap::new(), - progid_map: UidGidMap::new(), - owner: 0, - level: 0, - group: 0, - flags: 1, - parent: None, - ns_common: Arc::new(NsCommon::new(Box::new(UserNsOperations::new( - "User".to_string(), - )))), - pid: Arc::new(RwLock::new(Pid::new(1))), - ucount_max: vec![UCOUNT_MAX; Counts as usize], - ucounts: None, - rlimit_max: vec![65535, 10, 32000, 64 * 1024], - } - } -} diff --git a/kernel/src/process/mod.rs b/kernel/src/process/mod.rs index 1c5ce4bb4..6da8f3a31 100644 --- a/kernel/src/process/mod.rs +++ b/kernel/src/process/mod.rs @@ -730,7 +730,7 @@ impl ProcessControlBlock { let pcb = Self { pid, tgid: pid, - thread_pid: Arc::new(RwLock::new(PidStrcut::new())), + thread_pid: Arc::new(RwLock::new(PidStrcut::default())), basic: basic_info, preempt_count, flags, @@ -747,10 +747,10 @@ impl ProcessControlBlock { children: RwLock::new(Vec::new()), wait_queue: WaitQueue::default(), thread: RwLock::new(ThreadInfo::new()), - fs: Arc::new(SpinLock::new(FsStruct::new())), + fs: Arc::new(SpinLock::new(FsStruct::default())), alarm_timer: SpinLock::new(None), robust_list: RwLock::new(None), - nsproxy: Arc::new(RwLock::new(NsProxy::new())), + nsproxy: Arc::new(RwLock::new(NsProxy::default())), cred: SpinLock::new(cred), }; diff --git a/user/dadk/config/test_namespace.dadk b/user/dadk/config/test_namespace.dadk index 29f1afc62..a24e8f780 100644 --- a/user/dadk/config/test_namespace.dadk +++ b/user/dadk/config/test_namespace.dadk @@ -15,7 +15,7 @@ "build_command": "make install" }, "install": { - "in_dragonos_path": "/bin" + "in_dragonos_path": "/" }, "clean": { "clean_command": "make clean"