Skip to content
Open
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
13 changes: 12 additions & 1 deletion crates/kernel/src/process.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
extern crate alloc;

use alloc::vec::Vec;
use alloc::{boxed::Box, vec::Vec};
use wasm_posix_shared::{Errno, WasmStat, WasmStatfs};

use crate::fd::FdTable;
Expand Down Expand Up @@ -597,6 +597,17 @@ impl Process {
/// - OFD 1 = stdout (CharDevice, O_WRONLY, host_handle=1)
/// - OFD 2 = stderr (CharDevice, O_WRONLY, host_handle=2)
pub fn new(pid: u32) -> Self {
*Self::new_boxed(pid)
}

/// Heap-allocate a new process record for call sites that should avoid
/// keeping a `Process` value in their own stack frame.
#[inline(never)]
pub fn new_boxed(pid: u32) -> Box<Self> {
Box::new(Self::new_value(pid))
}

fn new_value(pid: u32) -> Self {
use crate::ofd::FileType;
use wasm_posix_shared::flags::{O_RDONLY, O_WRONLY};

Expand Down
21 changes: 21 additions & 0 deletions crates/shared/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -733,6 +733,27 @@ pub struct WasmStat {
pub _pad: u32,
}

impl Default for WasmStat {
fn default() -> Self {
Self {
st_dev: 0,
st_ino: 0,
st_mode: 0,
st_nlink: 0,
st_uid: 0,
st_gid: 0,
st_size: 0,
st_atime_sec: 0,
st_atime_nsec: 0,
st_mtime_sec: 0,
st_mtime_nsec: 0,
st_ctime_sec: 0,
st_ctime_nsec: 0,
_pad: 0,
}
}
}

/// Directory entry structure for the Wasm POSIX interface.
///
/// Uses `repr(C)` for a stable, predictable memory layout that can be
Expand Down
Loading