Implement sys_prlimit64 for nginx

master
Jiajie Chen 6 years ago
parent c2a90e2ab1
commit 524865ebd8

@ -135,3 +135,40 @@ pub struct SysInfo {
freehigh: u64,
mem_unit: u32,
}
const RLIMIT_NOFILE: usize = 7;
pub fn sys_prlimit64(
pid: usize,
resource: usize,
new_limit: *const RLimit,
old_limit: *mut RLimit,
) -> SysResult {
let proc = process();
info!(
"prlimit64: pid: {}, resource: {}, new_limit: {:x?}, old_limit: {:x?}",
pid, resource, new_limit, old_limit
);
match resource {
RLIMIT_NOFILE => {
if !old_limit.is_null() {
proc.vm.check_write_ptr(old_limit)?;
unsafe {
*old_limit = RLimit {
cur: 1024,
max: 1024,
};
}
}
Ok(0)
}
_ => Err(SysError::ENOSYS),
}
}
#[repr(C)]
#[derive(Debug, Default)]
pub struct RLimit {
cur: u64, // soft limit
max: u64, // hard limit
}

@ -269,11 +269,12 @@ pub fn syscall(id: usize, args: [usize; 6], tf: &mut TrapFrame) -> isize {
}
SYS_DUP3 => sys_dup2(args[0], args[1]), // TODO: handle `flags`
SYS_PIPE2 => sys_pipe(args[0] as *mut u32), // TODO: handle `flags`
SYS_PRLIMIT64 => {
warn!("sys_prlimit64 is unimplemented");
Ok(0)
}
SYS_PRLIMIT64 => sys_prlimit64(
args[0],
args[1],
args[2] as *const RLimit,
args[3] as *mut RLimit,
),
// custom temporary syscall
SYS_MAP_PCI_DEVICE => sys_map_pci_device(args[0], args[1]),
SYS_GET_PADDR => sys_get_paddr(args[0] as *const u64, args[1] as *mut u64, args[2]),

@ -1 +1 @@
Subproject commit bf70c66685de6c99e302ed10965e5c05fb8ae0e6
Subproject commit 69febc9fcc64df60329687b4f24b9b5309c99adf
Loading…
Cancel
Save