11496ba7bSLoGin use core::ffi::c_void; 2ab5c8ca4Slogin 3971462beSGnoCiYeH use alloc::{ 4971462beSGnoCiYeH string::{String, ToString}, 5971462beSGnoCiYeH sync::Arc, 6971462beSGnoCiYeH vec::Vec, 7971462beSGnoCiYeH }; 81496ba7bSLoGin 9971462beSGnoCiYeH use super::{ 10971462beSGnoCiYeH abi::WaitOption, 11971462beSGnoCiYeH fork::{CloneFlags, KernelCloneArgs}, 12*0d9b7d92SLoGin resource::{RLimit64, RLimitID, RUsage, RUsageWho}, 13971462beSGnoCiYeH KernelStack, Pid, ProcessManager, ProcessState, 14971462beSGnoCiYeH }; 15ab5c8ca4Slogin use crate::{ 16*0d9b7d92SLoGin arch::{interrupt::TrapFrame, sched::sched, CurrentIrqArch, MMArch}, 171496ba7bSLoGin exception::InterruptArch, 18*0d9b7d92SLoGin filesystem::{ 19*0d9b7d92SLoGin procfs::procfs_register_pid, 20*0d9b7d92SLoGin vfs::{file::FileDescriptorVec, MAX_PATHLEN}, 21*0d9b7d92SLoGin }, 22971462beSGnoCiYeH include::bindings::bindings::verify_area, 23*0d9b7d92SLoGin mm::{ucontext::UserStack, MemoryManagementArch, VirtAddr}, 241496ba7bSLoGin process::ProcessControlBlock, 25971462beSGnoCiYeH sched::completion::Completion, 261496ba7bSLoGin syscall::{ 271496ba7bSLoGin user_access::{ 281496ba7bSLoGin check_and_clone_cstr, check_and_clone_cstr_array, UserBufferReader, UserBufferWriter, 291496ba7bSLoGin }, 301496ba7bSLoGin Syscall, SystemError, 311496ba7bSLoGin }, 32ab5c8ca4Slogin }; 33ab5c8ca4Slogin 34ab5c8ca4Slogin impl Syscall { 351496ba7bSLoGin pub fn fork(frame: &mut TrapFrame) -> Result<usize, SystemError> { 361496ba7bSLoGin let r = ProcessManager::fork(frame, CloneFlags::empty()).map(|pid| pid.into()); 371496ba7bSLoGin return r; 38ab5c8ca4Slogin } 39ab5c8ca4Slogin 401496ba7bSLoGin pub fn vfork(frame: &mut TrapFrame) -> Result<usize, SystemError> { 411496ba7bSLoGin ProcessManager::fork( 421496ba7bSLoGin frame, 431496ba7bSLoGin CloneFlags::CLONE_VM | CloneFlags::CLONE_FS | CloneFlags::CLONE_SIGNAL, 441496ba7bSLoGin ) 451496ba7bSLoGin .map(|pid| pid.into()) 46ab5c8ca4Slogin } 47ab5c8ca4Slogin 48ab5c8ca4Slogin pub fn execve( 491496ba7bSLoGin path: *const u8, 501496ba7bSLoGin argv: *const *const u8, 511496ba7bSLoGin envp: *const *const u8, 521496ba7bSLoGin frame: &mut TrapFrame, 531496ba7bSLoGin ) -> Result<(), SystemError> { 541496ba7bSLoGin // kdebug!( 551496ba7bSLoGin // "execve path: {:?}, argv: {:?}, envp: {:?}\n", 561496ba7bSLoGin // path, 571496ba7bSLoGin // argv, 581496ba7bSLoGin // envp 591496ba7bSLoGin // ); 60971462beSGnoCiYeH // kdebug!( 61971462beSGnoCiYeH // "before execve: strong count: {}", 62971462beSGnoCiYeH // Arc::strong_count(&ProcessManager::current_pcb()) 63971462beSGnoCiYeH // ); 64971462beSGnoCiYeH 651496ba7bSLoGin if path.is_null() { 661496ba7bSLoGin return Err(SystemError::EINVAL); 671496ba7bSLoGin } 681496ba7bSLoGin 691496ba7bSLoGin let x = || { 701496ba7bSLoGin let path: String = check_and_clone_cstr(path, Some(MAX_PATHLEN))?; 711496ba7bSLoGin let argv: Vec<String> = check_and_clone_cstr_array(argv)?; 721496ba7bSLoGin let envp: Vec<String> = check_and_clone_cstr_array(envp)?; 731496ba7bSLoGin Ok((path, argv, envp)) 741496ba7bSLoGin }; 751496ba7bSLoGin let r: Result<(String, Vec<String>, Vec<String>), SystemError> = x(); 761496ba7bSLoGin if let Err(e) = r { 771496ba7bSLoGin panic!("Failed to execve: {:?}", e); 781496ba7bSLoGin } 791496ba7bSLoGin let (path, argv, envp) = r.unwrap(); 801496ba7bSLoGin ProcessManager::current_pcb() 811496ba7bSLoGin .basic_mut() 821496ba7bSLoGin .set_name(ProcessControlBlock::generate_name(&path, &argv)); 831496ba7bSLoGin 84876cb89eSGnoCiYeH Self::do_execve(path, argv, envp, frame)?; 85876cb89eSGnoCiYeH 86876cb89eSGnoCiYeH // 关闭设置了O_CLOEXEC的文件描述符 87876cb89eSGnoCiYeH let fd_table = ProcessManager::current_pcb().fd_table(); 88876cb89eSGnoCiYeH fd_table.write().close_on_exec(); 89971462beSGnoCiYeH // kdebug!( 90971462beSGnoCiYeH // "after execve: strong count: {}", 91971462beSGnoCiYeH // Arc::strong_count(&ProcessManager::current_pcb()) 92971462beSGnoCiYeH // ); 93876cb89eSGnoCiYeH 94876cb89eSGnoCiYeH return Ok(()); 95ab5c8ca4Slogin } 96ab5c8ca4Slogin 97ab5c8ca4Slogin pub fn wait4( 981496ba7bSLoGin pid: i64, 991496ba7bSLoGin wstatus: *mut i32, 1001496ba7bSLoGin options: i32, 101ab5c8ca4Slogin rusage: *mut c_void, 102ab5c8ca4Slogin ) -> Result<usize, SystemError> { 103b7b843beSGnoCiYeH let ret = WaitOption::from_bits(options as u32); 104b7b843beSGnoCiYeH let options = match ret { 105b7b843beSGnoCiYeH Some(options) => options, 106b7b843beSGnoCiYeH None => { 107b7b843beSGnoCiYeH return Err(SystemError::EINVAL); 108b7b843beSGnoCiYeH } 109b7b843beSGnoCiYeH }; 110b7b843beSGnoCiYeH 1111496ba7bSLoGin let mut _rusage_buf = 1121496ba7bSLoGin UserBufferReader::new::<c_void>(rusage, core::mem::size_of::<c_void>(), true)?; 1131496ba7bSLoGin 1141496ba7bSLoGin let mut wstatus_buf = 1151496ba7bSLoGin UserBufferWriter::new::<i32>(wstatus, core::mem::size_of::<i32>(), true)?; 1161496ba7bSLoGin 1171496ba7bSLoGin let cur_pcb = ProcessManager::current_pcb(); 1181496ba7bSLoGin let rd_childen = cur_pcb.children.read(); 1191496ba7bSLoGin 1201496ba7bSLoGin if pid > 0 { 1211496ba7bSLoGin let pid = Pid(pid as usize); 122971462beSGnoCiYeH let child_pcb = ProcessManager::find(pid).ok_or(SystemError::ECHILD)?; 1231496ba7bSLoGin drop(rd_childen); 1241496ba7bSLoGin 125b7b843beSGnoCiYeH loop { 126971462beSGnoCiYeH let state = child_pcb.sched_info().state(); 1271496ba7bSLoGin // 获取退出码 128971462beSGnoCiYeH match state { 129b7b843beSGnoCiYeH ProcessState::Runnable => { 130b7b843beSGnoCiYeH if options.contains(WaitOption::WNOHANG) 131b7b843beSGnoCiYeH || options.contains(WaitOption::WNOWAIT) 132b7b843beSGnoCiYeH { 1331496ba7bSLoGin if !wstatus.is_null() { 134b7b843beSGnoCiYeH wstatus_buf.copy_one_to_user(&WaitOption::WCONTINUED.bits(), 0)?; 135b7b843beSGnoCiYeH } 136b7b843beSGnoCiYeH return Ok(0); 137b7b843beSGnoCiYeH } 138b7b843beSGnoCiYeH } 1393c82aa56SChiichen ProcessState::Blocked(_) | ProcessState::Stopped => { 140b7b843beSGnoCiYeH // 指定WUNTRACED则等待暂停的进程,不指定则返回0 141b7b843beSGnoCiYeH if !options.contains(WaitOption::WUNTRACED) 142b7b843beSGnoCiYeH || options.contains(WaitOption::WNOWAIT) 143b7b843beSGnoCiYeH { 144b7b843beSGnoCiYeH if !wstatus.is_null() { 145b7b843beSGnoCiYeH wstatus_buf.copy_one_to_user(&WaitOption::WSTOPPED.bits(), 0)?; 146b7b843beSGnoCiYeH } 147b7b843beSGnoCiYeH return Ok(0); 148b7b843beSGnoCiYeH } 149b7b843beSGnoCiYeH } 150b7b843beSGnoCiYeH ProcessState::Exited(status) => { 151971462beSGnoCiYeH // kdebug!("wait4: child exited, pid: {:?}, status: {status}\n", pid); 152b7b843beSGnoCiYeH if !wstatus.is_null() { 153b7b843beSGnoCiYeH wstatus_buf.copy_one_to_user( 154971462beSGnoCiYeH &(status as u32 | WaitOption::WEXITED.bits()), 155b7b843beSGnoCiYeH 0, 156b7b843beSGnoCiYeH )?; 1571496ba7bSLoGin } 158971462beSGnoCiYeH drop(child_pcb); 159971462beSGnoCiYeH // kdebug!("wait4: to release {pid:?}"); 160971462beSGnoCiYeH unsafe { ProcessManager::release(pid) }; 1611496ba7bSLoGin return Ok(pid.into()); 1621496ba7bSLoGin } 163b7b843beSGnoCiYeH }; 164b7b843beSGnoCiYeH 1651496ba7bSLoGin // 等待指定进程 1661496ba7bSLoGin child_pcb.wait_queue.sleep(); 167b7b843beSGnoCiYeH } 1681496ba7bSLoGin } else if pid < -1 { 1691496ba7bSLoGin // TODO 判断是否pgid == -pid(等待指定组任意进程) 1701496ba7bSLoGin // 暂时不支持 1711496ba7bSLoGin return Err(SystemError::EINVAL); 1721496ba7bSLoGin } else if pid == 0 { 1731496ba7bSLoGin // TODO 判断是否pgid == current_pgid(等待当前组任意进程) 1741496ba7bSLoGin // 暂时不支持 1751496ba7bSLoGin return Err(SystemError::EINVAL); 1761496ba7bSLoGin } else { 1771496ba7bSLoGin // 等待任意子进程(这两) 1781496ba7bSLoGin let irq_guard = unsafe { CurrentIrqArch::save_and_disable_irq() }; 179971462beSGnoCiYeH for pid in rd_childen.iter() { 180971462beSGnoCiYeH let pcb = ProcessManager::find(*pid).ok_or(SystemError::ECHILD)?; 1811496ba7bSLoGin if pcb.sched_info().state().is_exited() { 1821496ba7bSLoGin if !wstatus.is_null() { 1831496ba7bSLoGin wstatus_buf.copy_one_to_user(&0, 0)?; 1841496ba7bSLoGin } 1851496ba7bSLoGin return Ok(pid.clone().into()); 1861496ba7bSLoGin } else { 1871496ba7bSLoGin unsafe { pcb.wait_queue.sleep_without_schedule() }; 1881496ba7bSLoGin } 1891496ba7bSLoGin } 1901496ba7bSLoGin drop(irq_guard); 1911496ba7bSLoGin sched(); 1921496ba7bSLoGin } 1931496ba7bSLoGin 1941496ba7bSLoGin return Ok(0); 195ab5c8ca4Slogin } 196ab5c8ca4Slogin 197ab5c8ca4Slogin /// # 退出进程 198ab5c8ca4Slogin /// 199ab5c8ca4Slogin /// ## 参数 200ab5c8ca4Slogin /// 201ab5c8ca4Slogin /// - status: 退出状态 202ab5c8ca4Slogin pub fn exit(status: usize) -> ! { 2031496ba7bSLoGin ProcessManager::exit(status); 204ab5c8ca4Slogin } 205ab5c8ca4Slogin 2061496ba7bSLoGin /// @brief 获取当前进程的pid 2071496ba7bSLoGin pub fn getpid() -> Result<Pid, SystemError> { 2081496ba7bSLoGin let current_pcb = ProcessManager::current_pcb(); 209393f6915SLoGin return Ok(current_pcb.tgid()); 2101496ba7bSLoGin } 2111496ba7bSLoGin 2121496ba7bSLoGin /// @brief 获取指定进程的pgid 2131496ba7bSLoGin /// 2141496ba7bSLoGin /// @param pid 指定一个进程号 2151496ba7bSLoGin /// 2161496ba7bSLoGin /// @return 成功,指定进程的进程组id 2171496ba7bSLoGin /// @return 错误,不存在该进程 2181496ba7bSLoGin pub fn getpgid(mut pid: Pid) -> Result<Pid, SystemError> { 2191496ba7bSLoGin if pid == Pid(0) { 2201496ba7bSLoGin let current_pcb = ProcessManager::current_pcb(); 2211496ba7bSLoGin pid = current_pcb.pid(); 2221496ba7bSLoGin } 2231496ba7bSLoGin let target_proc = ProcessManager::find(pid).ok_or(SystemError::ESRCH)?; 2241496ba7bSLoGin return Ok(target_proc.basic().pgid()); 2251496ba7bSLoGin } 2261496ba7bSLoGin /// @brief 获取当前进程的父进程id 2271496ba7bSLoGin 2281496ba7bSLoGin /// 若为initproc则ppid设置为0 2291496ba7bSLoGin pub fn getppid() -> Result<Pid, SystemError> { 2301496ba7bSLoGin let current_pcb = ProcessManager::current_pcb(); 2311496ba7bSLoGin return Ok(current_pcb.basic().ppid()); 232ab5c8ca4Slogin } 233971462beSGnoCiYeH 234971462beSGnoCiYeH pub fn clone( 235971462beSGnoCiYeH current_trapframe: &mut TrapFrame, 236971462beSGnoCiYeH clone_args: KernelCloneArgs, 237971462beSGnoCiYeH ) -> Result<usize, SystemError> { 238971462beSGnoCiYeH let flags = clone_args.flags; 239971462beSGnoCiYeH 240971462beSGnoCiYeH let vfork = Arc::new(Completion::new()); 241971462beSGnoCiYeH 242971462beSGnoCiYeH if flags.contains(CloneFlags::CLONE_PIDFD) 243971462beSGnoCiYeH && flags.contains(CloneFlags::CLONE_PARENT_SETTID) 244971462beSGnoCiYeH { 245971462beSGnoCiYeH return Err(SystemError::EINVAL); 246971462beSGnoCiYeH } 247971462beSGnoCiYeH 248971462beSGnoCiYeH let current_pcb = ProcessManager::current_pcb(); 249971462beSGnoCiYeH let new_kstack = KernelStack::new()?; 250971462beSGnoCiYeH let name = current_pcb.basic().name().to_string(); 251971462beSGnoCiYeH let pcb = ProcessControlBlock::new(name, new_kstack); 252971462beSGnoCiYeH // 克隆pcb 253971462beSGnoCiYeH ProcessManager::copy_process(¤t_pcb, &pcb, clone_args, current_trapframe)?; 254971462beSGnoCiYeH ProcessManager::add_pcb(pcb.clone()); 255971462beSGnoCiYeH 256971462beSGnoCiYeH // 向procfs注册进程 257971462beSGnoCiYeH procfs_register_pid(pcb.pid()).unwrap_or_else(|e| { 258971462beSGnoCiYeH panic!( 259971462beSGnoCiYeH "fork: Failed to register pid to procfs, pid: [{:?}]. Error: {:?}", 260971462beSGnoCiYeH pcb.pid(), 261971462beSGnoCiYeH e 262971462beSGnoCiYeH ) 263971462beSGnoCiYeH }); 264971462beSGnoCiYeH 265971462beSGnoCiYeH if flags.contains(CloneFlags::CLONE_VFORK) { 266971462beSGnoCiYeH pcb.thread.write().vfork_done = Some(vfork.clone()); 267971462beSGnoCiYeH } 268971462beSGnoCiYeH 269971462beSGnoCiYeH if pcb.thread.read().set_child_tid.is_some() { 270971462beSGnoCiYeH let addr = pcb.thread.read().set_child_tid.unwrap(); 271971462beSGnoCiYeH let mut writer = 272971462beSGnoCiYeH UserBufferWriter::new(addr.as_ptr::<i32>(), core::mem::size_of::<i32>(), true)?; 273971462beSGnoCiYeH writer.copy_one_to_user(&(pcb.pid().data() as i32), 0)?; 274971462beSGnoCiYeH } 275971462beSGnoCiYeH 276971462beSGnoCiYeH ProcessManager::wakeup(&pcb).unwrap_or_else(|e| { 277971462beSGnoCiYeH panic!( 278971462beSGnoCiYeH "fork: Failed to wakeup new process, pid: [{:?}]. Error: {:?}", 279971462beSGnoCiYeH pcb.pid(), 280971462beSGnoCiYeH e 281971462beSGnoCiYeH ) 282971462beSGnoCiYeH }); 283971462beSGnoCiYeH 284971462beSGnoCiYeH if flags.contains(CloneFlags::CLONE_VFORK) { 285971462beSGnoCiYeH // 等待子进程结束或者exec; 286971462beSGnoCiYeH vfork.wait_for_completion_interruptible()?; 287971462beSGnoCiYeH } 288971462beSGnoCiYeH 289971462beSGnoCiYeH return Ok(pcb.pid().0); 290971462beSGnoCiYeH } 291971462beSGnoCiYeH 292971462beSGnoCiYeH /// 设置线程地址 293971462beSGnoCiYeH pub fn set_tid_address(ptr: usize) -> Result<usize, SystemError> { 294971462beSGnoCiYeH if !unsafe { verify_area(ptr as u64, core::mem::size_of::<i32>() as u64) } { 295971462beSGnoCiYeH return Err(SystemError::EFAULT); 296971462beSGnoCiYeH } 297971462beSGnoCiYeH 298971462beSGnoCiYeH let pcb = ProcessManager::current_pcb(); 299971462beSGnoCiYeH pcb.thread.write().clear_child_tid = Some(VirtAddr::new(ptr)); 300971462beSGnoCiYeH Ok(pcb.pid.0) 301971462beSGnoCiYeH } 302393f6915SLoGin 303393f6915SLoGin pub fn gettid() -> Result<Pid, SystemError> { 304393f6915SLoGin let pcb = ProcessManager::current_pcb(); 305393f6915SLoGin Ok(pcb.pid) 306393f6915SLoGin } 30702e249f3SLoGin 30802e249f3SLoGin pub fn getuid() -> Result<usize, SystemError> { 30902e249f3SLoGin // todo: 增加credit功能之后,需要修改 31002e249f3SLoGin return Ok(0); 31102e249f3SLoGin } 31202e249f3SLoGin 31302e249f3SLoGin pub fn getgid() -> Result<usize, SystemError> { 31402e249f3SLoGin // todo: 增加credit功能之后,需要修改 31502e249f3SLoGin return Ok(0); 31602e249f3SLoGin } 31702e249f3SLoGin 31802e249f3SLoGin pub fn geteuid() -> Result<usize, SystemError> { 31902e249f3SLoGin // todo: 增加credit功能之后,需要修改 32002e249f3SLoGin return Ok(0); 32102e249f3SLoGin } 32202e249f3SLoGin 32302e249f3SLoGin pub fn getegid() -> Result<usize, SystemError> { 32402e249f3SLoGin // todo: 增加credit功能之后,需要修改 32502e249f3SLoGin return Ok(0); 32602e249f3SLoGin } 327be8cdf4bSLoGin 328be8cdf4bSLoGin pub fn get_rusage(who: i32, rusage: *mut RUsage) -> Result<usize, SystemError> { 329be8cdf4bSLoGin let who = RUsageWho::try_from(who)?; 330be8cdf4bSLoGin let mut writer = UserBufferWriter::new(rusage, core::mem::size_of::<RUsage>(), true)?; 331be8cdf4bSLoGin let pcb = ProcessManager::current_pcb(); 332be8cdf4bSLoGin let rusage = pcb.get_rusage(who).ok_or(SystemError::EINVAL)?; 333be8cdf4bSLoGin 334be8cdf4bSLoGin let ubuf = writer.buffer::<RUsage>(0).unwrap(); 335be8cdf4bSLoGin ubuf.copy_from_slice(&[rusage]); 336be8cdf4bSLoGin 337be8cdf4bSLoGin return Ok(0); 338be8cdf4bSLoGin } 339*0d9b7d92SLoGin 340*0d9b7d92SLoGin /// # 设置资源限制 341*0d9b7d92SLoGin /// 342*0d9b7d92SLoGin /// TODO: 目前暂时不支持设置资源限制,只提供读取默认值的功能 343*0d9b7d92SLoGin /// 344*0d9b7d92SLoGin /// ## 参数 345*0d9b7d92SLoGin /// 346*0d9b7d92SLoGin /// - pid: 进程号 347*0d9b7d92SLoGin /// - resource: 资源类型 348*0d9b7d92SLoGin /// - new_limit: 新的资源限制 349*0d9b7d92SLoGin /// - old_limit: 旧的资源限制 350*0d9b7d92SLoGin /// 351*0d9b7d92SLoGin /// ## 返回值 352*0d9b7d92SLoGin /// 353*0d9b7d92SLoGin /// - 成功,0 354*0d9b7d92SLoGin /// - 如果old_limit不为NULL,则返回旧的资源限制到old_limit 355*0d9b7d92SLoGin /// 356*0d9b7d92SLoGin pub fn prlimit64( 357*0d9b7d92SLoGin _pid: Pid, 358*0d9b7d92SLoGin resource: usize, 359*0d9b7d92SLoGin new_limit: *const RLimit64, 360*0d9b7d92SLoGin old_limit: *mut RLimit64, 361*0d9b7d92SLoGin ) -> Result<usize, SystemError> { 362*0d9b7d92SLoGin let resource = RLimitID::try_from(resource)?; 363*0d9b7d92SLoGin let mut writer = None; 364*0d9b7d92SLoGin 365*0d9b7d92SLoGin if new_limit.is_null() { 366*0d9b7d92SLoGin return Err(SystemError::EINVAL); 367*0d9b7d92SLoGin } 368*0d9b7d92SLoGin 369*0d9b7d92SLoGin if !old_limit.is_null() { 370*0d9b7d92SLoGin writer = Some(UserBufferWriter::new( 371*0d9b7d92SLoGin old_limit, 372*0d9b7d92SLoGin core::mem::size_of::<RLimit64>(), 373*0d9b7d92SLoGin true, 374*0d9b7d92SLoGin )?); 375*0d9b7d92SLoGin } 376*0d9b7d92SLoGin 377*0d9b7d92SLoGin let _reader = UserBufferReader::new(new_limit, core::mem::size_of::<RLimit64>(), true)?; 378*0d9b7d92SLoGin 379*0d9b7d92SLoGin match resource { 380*0d9b7d92SLoGin RLimitID::Stack => { 381*0d9b7d92SLoGin if let Some(mut writer) = writer { 382*0d9b7d92SLoGin let mut rlimit = writer.buffer::<RLimit64>(0).unwrap()[0]; 383*0d9b7d92SLoGin rlimit.rlim_cur = UserStack::DEFAULT_USER_STACK_SIZE as u64; 384*0d9b7d92SLoGin rlimit.rlim_max = UserStack::DEFAULT_USER_STACK_SIZE as u64; 385*0d9b7d92SLoGin } 386*0d9b7d92SLoGin return Ok(0); 387*0d9b7d92SLoGin } 388*0d9b7d92SLoGin 389*0d9b7d92SLoGin RLimitID::Nofile => { 390*0d9b7d92SLoGin if let Some(mut writer) = writer { 391*0d9b7d92SLoGin let mut rlimit = writer.buffer::<RLimit64>(0).unwrap()[0]; 392*0d9b7d92SLoGin rlimit.rlim_cur = FileDescriptorVec::PROCESS_MAX_FD as u64; 393*0d9b7d92SLoGin rlimit.rlim_max = FileDescriptorVec::PROCESS_MAX_FD as u64; 394*0d9b7d92SLoGin } 395*0d9b7d92SLoGin return Ok(0); 396*0d9b7d92SLoGin } 397*0d9b7d92SLoGin 398*0d9b7d92SLoGin RLimitID::As | RLimitID::Rss => { 399*0d9b7d92SLoGin if let Some(mut writer) = writer { 400*0d9b7d92SLoGin let mut rlimit = writer.buffer::<RLimit64>(0).unwrap()[0]; 401*0d9b7d92SLoGin rlimit.rlim_cur = MMArch::USER_END_VADDR.data() as u64; 402*0d9b7d92SLoGin rlimit.rlim_max = MMArch::USER_END_VADDR.data() as u64; 403*0d9b7d92SLoGin } 404*0d9b7d92SLoGin return Ok(0); 405*0d9b7d92SLoGin } 406*0d9b7d92SLoGin 407*0d9b7d92SLoGin _ => { 408*0d9b7d92SLoGin return Err(SystemError::ENOSYS); 409*0d9b7d92SLoGin } 410*0d9b7d92SLoGin } 411*0d9b7d92SLoGin } 412ab5c8ca4Slogin } 413