mirror of
https://github.com/asterinas/asterinas.git
synced 2025-06-10 05:46:48 +00:00
Add vfork syscall and related clone flags
This commit is contained in:
parent
9a974a0483
commit
43e43ca133
@ -137,6 +137,14 @@ impl CloneArgs {
|
||||
..Default::default()
|
||||
}
|
||||
}
|
||||
|
||||
pub fn for_vfork() -> Self {
|
||||
Self {
|
||||
flags: CloneFlags::CLONE_VFORK | CloneFlags::CLONE_VM,
|
||||
exit_signal: Some(SIGCHLD),
|
||||
..Default::default()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<u64> for CloneFlags {
|
||||
@ -158,7 +166,8 @@ impl CloneFlags {
|
||||
| CloneFlags::CLONE_SETTLS
|
||||
| CloneFlags::CLONE_PARENT_SETTID
|
||||
| CloneFlags::CLONE_CHILD_SETTID
|
||||
| CloneFlags::CLONE_CHILD_CLEARTID;
|
||||
| CloneFlags::CLONE_CHILD_CLEARTID
|
||||
| CloneFlags::CLONE_VFORK;
|
||||
let unsupported_flags = *self - supported_flags;
|
||||
if !unsupported_flags.is_empty() {
|
||||
warn!("contains unsupported clone flags: {:?}", unsupported_flags);
|
||||
|
@ -26,7 +26,7 @@ use crate::syscall::{
|
||||
fallocate::sys_fallocate,
|
||||
fcntl::sys_fcntl,
|
||||
flock::sys_flock,
|
||||
fork::sys_fork,
|
||||
fork::{sys_fork, sys_vfork},
|
||||
fsync::{sys_fdatasync, sys_fsync},
|
||||
futex::sys_futex,
|
||||
get_priority::sys_get_priority,
|
||||
@ -205,6 +205,7 @@ impl_syscall_nums_and_dispatch_fn! {
|
||||
SYS_GETSOCKOPT = 55 => sys_getsockopt(args[..5]);
|
||||
SYS_CLONE = 56 => sys_clone(args[..5], &user_ctx);
|
||||
SYS_FORK = 57 => sys_fork(args[..0], &user_ctx);
|
||||
SYS_VFORK = 58 => sys_vfork(args[..0], &user_ctx);
|
||||
SYS_EXECVE = 59 => sys_execve(args[..3], &mut user_ctx);
|
||||
SYS_EXIT = 60 => sys_exit(args[..1]);
|
||||
SYS_WAIT4 = 61 => sys_wait4(args[..4]);
|
||||
|
@ -13,3 +13,9 @@ pub fn sys_fork(ctx: &Context, parent_context: &UserContext) -> Result<SyscallRe
|
||||
let child_pid = clone_child(ctx, parent_context, clone_args).unwrap();
|
||||
Ok(SyscallReturn::Return(child_pid as _))
|
||||
}
|
||||
|
||||
pub fn sys_vfork(ctx: &Context, parent_context: &UserContext) -> Result<SyscallReturn> {
|
||||
let clone_args = CloneArgs::for_vfork();
|
||||
let child_pid = clone_child(ctx, parent_context, clone_args).unwrap();
|
||||
Ok(SyscallReturn::Return(child_pid as _))
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user