Skip to content
This repository was archived by the owner on Nov 26, 2025. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions api/src/imp/fs/ctl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,11 @@ pub fn sys_linkat(
.map_err(|err| err.into())
}

#[cfg(target_arch = "x86_64")]
pub fn sys_unlink(path: UserConstPtr<c_char>) -> LinuxResult<isize> {
sys_unlinkat(AT_FDCWD, path, 0)
}

/// remove link of specific file (can be used to delete file)
/// dir_fd: the directory of link to be removed
/// path: the name of link to be removed
Expand Down
4 changes: 4 additions & 0 deletions api/src/imp/fs/io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ pub fn sys_openat(
Ok(api::sys_openat(dirfd, path.as_ptr(), flags, modes) as _)
}

pub fn sys_lseek(fd: i32, offset: i32, whence: i32) -> LinuxResult<isize> {
Ok(api::sys_lseek(fd, offset.into(), whence) as _)
}

pub fn sys_open(path: UserConstPtr<c_char>, flags: i32, modes: mode_t) -> LinuxResult<isize> {
use arceos_posix_api::AT_FDCWD;
sys_openat(AT_FDCWD as _, path, flags, modes)
Expand Down
5 changes: 5 additions & 0 deletions api/src/imp/task/thread.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ pub fn sys_getppid() -> LinuxResult<isize> {
Ok(axtask::current().task_ext().get_parent() as _)
}

#[apply(syscall_instrument)]
pub fn sys_gettid() -> LinuxResult<isize> {
Ok(current().id().as_u64() as _)
}

pub fn sys_exit(status: i32) -> ! {
let curr = current();
let clear_child_tid = curr.task_ext().clear_child_tid() as *mut i32;
Expand Down
10 changes: 9 additions & 1 deletion apps/oscomp/judge_libctest.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,20 @@
import sys

# TODO: Add more commands to test here
libctest_baseline = """"""
libctest_baseline = """
========== START entry-static.exe argv ==========
Pass!
========== END entry-static.exe argv ==========
========== START entry-static.exe fdopen ==========
Pass!
========== END entry-static.exe fdopen ==========
"""

def parse_libctest(output):
ans = {}
key = ""
for line in output.split("\n"):
line = line.replace('\n', '').replace('\r', '')
if "START entry-static.exe" in line:
key = "libctest static " + line.split(" ")[3]
elif "START entry-dynamic.exe" in line:
Expand Down
2 changes: 1 addition & 1 deletion apps/oscomp/testcase_list
Original file line number Diff line number Diff line change
@@ -1 +1 @@
/musl/basic/waitpid
/musl/basic/waitpid
18 changes: 11 additions & 7 deletions core/src/task.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,32 +93,36 @@ impl TaskExt {
let kstack_top = curr.kernel_stack_top().unwrap();
info!(
"Enter user space: entry={:#x}, ustack={:#x}, kstack={:#x}",
curr.task_ext().uctx.get_ip(),
curr.task_ext().uctx.get_sp(),
curr.task_ext().uctx.ip(),
curr.task_ext().uctx.sp(),
kstack_top,
);
unsafe { curr.task_ext().uctx.enter_uspace(kstack_top) };
},
current().id_name(),
axconfig::plat::KERNEL_STACK_SIZE,
);

let current_task = current();
let mut current_aspace = current_task.task_ext().aspace.lock();
let mut new_aspace = current_aspace.clone_or_err()?;
copy_from_kernel(&mut new_aspace)?;
new_task
.ctx_mut()
.set_page_table_root(new_aspace.page_table_root());

new_task
.ctx_mut()
.set_tls(axhal::arch::read_thread_pointer().into());
let trap_frame = read_trapframe_from_kstack(current_task.get_kernel_stack_top().unwrap());
let mut new_uctx = UspaceContext::from(&trap_frame);
if let Some(stack) = stack {
new_uctx.set_sp(stack);
}
// Skip current instruction
#[cfg(any(target_arch = "riscv64", target_arch = "loongarch64"))]
new_uctx.set_ip(new_uctx.get_ip() + 4);
{
let new_ip = new_uctx.ip() + 4;
new_uctx.set_ip(new_ip);
}
new_uctx.set_retval(0);
let return_id: u64 = new_task.id().as_u64();
let new_task_ext = TaskExt::new(
Expand Down Expand Up @@ -248,8 +252,8 @@ pub fn spawn_user_task(
let kstack_top = curr.kernel_stack_top().unwrap();
info!(
"Enter user space: entry={:#x}, ustack={:#x}, kstack={:#x}",
curr.task_ext().uctx.get_ip(),
curr.task_ext().uctx.get_sp(),
curr.task_ext().uctx.ip(),
curr.task_ext().uctx.sp(),
kstack_top,
);
unsafe { curr.task_ext().uctx.enter_uspace(kstack_top) };
Expand Down
11 changes: 8 additions & 3 deletions scripts/oscomp_test.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

TIMEOUT=60s
TIMEOUT=600s
EXIT_STATUS=0
ROOT=$(realpath $(dirname $0))/../
AX_ROOT=$ROOT/.arceos
Expand All @@ -24,7 +24,9 @@ if [ "$ARCH" != "x86_64" ] && [ "$ARCH" != "riscv64" ] && [ "$ARCH" != "aarch64"
exit $S_FAILED
fi

LIBC=musl
if [ -z "$LIBC" ]; then
LIBC=musl
fi

if [ "$LIBC" != "musl" ] && [ "$LIBC" != "glibc" ]; then
echo "Unknown libc: $LIBC"
Expand Down Expand Up @@ -68,7 +70,10 @@ basic_testlist=(
busybox_testlist=("/$LIBC/busybox sh /$LIBC/busybox_testcode.sh")
iozone_testlist=("/$LIBC/busybox sh /$LIBC/iozone_testcode.sh")
lua_testlist=("/$LIBC/busybox sh /$LIBC/lua_testcode.sh")
libctest_testlist=("/$LIBC/busybox sh /$LIBC/libctest_testcode.sh")
libctest_testlist=(
"/$LIBC/runtest.exe -w entry-static.exe argv"
"/$LIBC/runtest.exe -w entry-static.exe fdopen"
)

testcases_type=(
"basic"
Expand Down
8 changes: 8 additions & 0 deletions src/syscall.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ fn handle_syscall(tf: &TrapFrame, syscall_num: usize) -> isize {
),
Sysno::ioctl => sys_ioctl(tf.arg0() as _, tf.arg1() as _, tf.arg2().into()),
Sysno::writev => sys_writev(tf.arg0() as _, tf.arg1().into(), tf.arg2() as _),
Sysno::prlimit64 => Ok(0),
Sysno::rt_sigtimedwait => Ok(0),
Sysno::sched_yield => sys_sched_yield(),
Sysno::nanosleep => sys_nanosleep(tf.arg0().into(), tf.arg1().into()),
Sysno::getpid => sys_getpid(),
Expand All @@ -34,6 +36,8 @@ fn handle_syscall(tf: &TrapFrame, syscall_num: usize) -> isize {
Sysno::dup => sys_dup(tf.arg0() as _),
Sysno::dup3 => sys_dup3(tf.arg0() as _, tf.arg1() as _),
Sysno::fcntl => sys_fcntl(tf.arg0() as _, tf.arg1() as _, tf.arg2() as _),
#[cfg(target_arch = "x86_64")]
Sysno::fork => sys_clone(17 /* SIGCHLD */, 0, 0, 0, 0),
Sysno::clone => sys_clone(
tf.arg0() as _,
tf.arg1() as _,
Expand All @@ -53,6 +57,7 @@ fn handle_syscall(tf: &TrapFrame, syscall_num: usize) -> isize {
tf.arg2() as _,
tf.arg3() as _,
),
Sysno::lseek => sys_lseek(tf.arg0() as _, tf.arg1() as _, tf.arg2() as _),
#[cfg(target_arch = "x86_64")]
Sysno::open => sys_open(tf.arg0().into(), tf.arg1() as _, tf.arg2() as _),
Sysno::getdents64 => sys_getdents64(tf.arg0() as _, tf.arg1().into(), tf.arg2() as _),
Expand All @@ -63,6 +68,8 @@ fn handle_syscall(tf: &TrapFrame, syscall_num: usize) -> isize {
tf.arg3().into(),
tf.arg4() as _,
),
#[cfg(target_arch = "x86_64")]
Sysno::unlink => sys_unlink(tf.arg0().into()),
Sysno::unlinkat => sys_unlinkat(tf.arg0() as _, tf.arg1().into(), tf.arg2() as _),
Sysno::uname => sys_uname(tf.arg0().into()),
Sysno::fstat => sys_fstat(tf.arg0() as _, tf.arg1().into()),
Expand Down Expand Up @@ -105,6 +112,7 @@ fn handle_syscall(tf: &TrapFrame, syscall_num: usize) -> isize {
Sysno::clock_gettime => sys_clock_gettime(tf.arg0() as _, tf.arg1().into()),
Sysno::exit_group => sys_exit_group(tf.arg0() as _),
Sysno::getuid => sys_getuid(),
Sysno::gettid => sys_gettid(),
Sysno::rt_sigprocmask => sys_rt_sigprocmask(
tf.arg0() as _,
tf.arg1().into(),
Expand Down
Loading