mirror of
https://github.com/asterinas/asterinas.git
synced 2025-06-24 09:53:24 +00:00
Move the check location following Linux behaviors
This commit is contained in:
committed by
Tate, Hongliang Tian
parent
18607c33ea
commit
22f9c072f3
@ -14,6 +14,14 @@ pub fn sys_madvise(
|
|||||||
"start = 0x{:x}, len = 0x{:x}, behavior = {:?}",
|
"start = 0x{:x}, len = 0x{:x}, behavior = {:?}",
|
||||||
start, len, behavior
|
start, len, behavior
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if start % PAGE_SIZE != 0 {
|
||||||
|
return_errno_with_message!(Errno::EINVAL, "the start address should be page aligned");
|
||||||
|
}
|
||||||
|
if len == 0 {
|
||||||
|
return Ok(SyscallReturn::Return(0));
|
||||||
|
}
|
||||||
|
|
||||||
match behavior {
|
match behavior {
|
||||||
MadviseBehavior::MADV_NORMAL
|
MadviseBehavior::MADV_NORMAL
|
||||||
| MadviseBehavior::MADV_SEQUENTIAL
|
| MadviseBehavior::MADV_SEQUENTIAL
|
||||||
@ -33,16 +41,8 @@ pub fn sys_madvise(
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn madv_free(start: Vaddr, len: usize, ctx: &Context) -> Result<()> {
|
fn madv_free(start: Vaddr, len: usize, ctx: &Context) -> Result<()> {
|
||||||
if start % PAGE_SIZE != 0 {
|
|
||||||
return_errno_with_message!(Errno::EINVAL, "the start address should be page aligned");
|
|
||||||
}
|
|
||||||
|
|
||||||
if len % PAGE_SIZE != 0 {
|
if len % PAGE_SIZE != 0 {
|
||||||
return_errno_with_message!(Errno::EINVAL, "the length should be page aligned");
|
return Ok(());
|
||||||
}
|
|
||||||
|
|
||||||
if len == 0 {
|
|
||||||
return_errno_with_message!(Errno::EINVAL, "madv_free len cannot be zero");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let root_vmar = ctx.process.root_vmar();
|
let root_vmar = ctx.process.root_vmar();
|
||||||
|
Reference in New Issue
Block a user