Skip to content

Commit

Permalink
[tmp] Commit for test
Browse files Browse the repository at this point in the history
  • Loading branch information
Azure-stars committed Nov 12, 2024
1 parent ed2162b commit 5b398d2
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 4 deletions.
6 changes: 5 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,23 @@ linkme = "0.3"
axerrno = "0.1"
memory_addr = "0.3"
xmas-elf = "0.9"
spin = "0.9"
crate_interface = "0.1"
bitflags = "2.6"

kernel-elf-parser = "0.1.0"
num_enum = { version = "0.7", default-features = false }
syscalls = { version = "0.6", default-features = false }

axfs = { git = "https://github.com/arceos-org/arceos.git", features = ["thread-local"] }
axstd = { git = "https://github.com/arceos-org/arceos.git", features = ["paging"] }
axhal = { git = "https://github.com/arceos-org/arceos.git", features = ["uspace"] }
axmm = { git = "https://github.com/arceos-org/arceos.git" }
axtask = { git = "https://github.com/arceos-org/arceos.git" }
axsync = { git = "https://github.com/arceos-org/arceos.git" }
axruntime = { git = "https://github.com/arceos-org/arceos.git", features = ["multitask"] }
arceos_posix_api = { git = "https://github.com/arceos-org/arceos.git" }
arceos_posix_api = { git = "https://github.com/arceos-org/arceos.git", features = ["uspace"] }
axns = { git = "https://github.com/arceos-org/arceos.git", features = ["thread-local"] }

[target.'cfg(target_arch = "x86_64")'.dependencies]
x86 = "0.52"
Expand Down
2 changes: 1 addition & 1 deletion apps/nimbos/test_cmd
Original file line number Diff line number Diff line change
@@ -1 +1 @@
test_one "LOG=off" "expect_off.out"
test_one "LOG=info" "expect_off.out"
2 changes: 2 additions & 0 deletions scripts/config.toml.temp
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@ axmm = { path = "%AX_ROOT%/modules/axmm" }
axtask = { path = "%AX_ROOT%/modules/axtask" }
axsync = { path = "%AX_ROOT%/modules/axsync" }
axruntime = { path = "%AX_ROOT%/modules/axruntime" }
axns = { path = "%AX_ROOT%/modules/axns" }
axfs = { path = "%AX_ROOT%/modules/axfs" }
2 changes: 1 addition & 1 deletion scripts/get_deps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
AX_ROOT=.arceos

test ! -d "$AX_ROOT" && echo "Cloning repositories ..." || true
test ! -d "$AX_ROOT" && git clone https://github.com/arceos-org/arceos -b monolithic "$AX_ROOT" --depth=1 || true
test ! -d "$AX_ROOT" && git clone https://github.com/Azure-stars/Starry -b monolithic "$AX_ROOT" --depth=1 || true

$(dirname $0)/set_ax_root.sh $AX_ROOT
2 changes: 2 additions & 0 deletions src/syscall_imp/fs/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
mod ctl;
mod io;
mod path;

pub(crate) use self::ctl::*;
pub(crate) use self::io::*;
pub(crate) use self::path::*;
12 changes: 12 additions & 0 deletions src/syscall_imp/fs/path.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
use core::ffi::c_char;

use crate::syscall_body;
use axerrno::LinuxError;

pub(crate) fn sys_getcwd(buf: *mut c_char, size: usize) -> *mut c_char {
arceos_posix_api::sys_getcwd(buf, size)
}

pub(crate) fn sys_chdir(path: *const c_char) -> i32 {
arceos_posix_api::sys_chdir(path)
}
21 changes: 20 additions & 1 deletion src/task.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use alloc::sync::Arc;

use axhal::arch::UspaceContext;
use axmm::AddrSpace;
use axns::{AxNamespace, AxNamespaceIf};
use axsync::Mutex;
use axtask::{AxTaskRef, TaskExtRef, TaskInner};

Expand All @@ -21,15 +22,18 @@ pub struct TaskExt {
pub uctx: UspaceContext,
/// The virtual memory address space.
pub aspace: Arc<Mutex<AddrSpace>>,
/// The resource namespace
pub ns: AxNamespace,
}

impl TaskExt {
pub const fn new(uctx: UspaceContext, aspace: Arc<Mutex<AddrSpace>>) -> Self {
pub fn new(uctx: UspaceContext, aspace: Arc<Mutex<AddrSpace>>) -> Self {
Self {
proc_id: 233,
uctx,
clear_child_tid: AtomicU64::new(0),
aspace,
ns: AxNamespace::new_thread_local(),
}
}

Expand All @@ -44,6 +48,21 @@ impl TaskExt {
}
}

struct AxNamespaceImpl;

#[crate_interface::impl_interface]
impl AxNamespaceIf for AxNamespaceImpl {
#[inline(never)]
fn current_namespace_base() -> *mut u8 {
log::info!("current_namespace_base {}", axtask::current().id_name());
let current = axtask::current();
if current.name() == "main" {
return axns::AxNamespace::global().base();
}
axtask::current().task_ext().ns.base()
}
}

axtask::def_task_ext!(TaskExt);

pub fn spawn_user_task(aspace: Arc<Mutex<AddrSpace>>, uctx: UspaceContext) -> AxTaskRef {
Expand Down

0 comments on commit 5b398d2

Please sign in to comment.