diff --git a/base/cp/Cargo.toml b/base/cp/Cargo.toml new file mode 100644 index 00000000..f26b3990 --- /dev/null +++ b/base/cp/Cargo.toml @@ -0,0 +1,14 @@ +[package] +name = "cp" +version = "0.1.0" +edition = "2021" +authors = ["vibix hackers"] +license = "MIT OR Apache-2.0" + +[[bin]] +name = "cp" +path = "src/main.rs" + +# Standalone package — not part of the main workspace. Built with +# `-Z build-std` against the in-repo std fork (see xtask build). +[workspace] diff --git a/base/cp/src/main.rs b/base/cp/src/main.rs new file mode 100644 index 00000000..1c13fc3c --- /dev/null +++ b/base/cp/src/main.rs @@ -0,0 +1,27 @@ +#![feature(restricted_std)] + +#[cfg(not(test))] +mod syscalls; + +use std::env; +use std::fs; +use std::process::ExitCode; + +fn main() -> ExitCode { + let args: Vec = env::args().collect(); + + if args.len() != 3 { + eprintln!("usage: cp "); + return ExitCode::from(1); + } + + let src = &args[1]; + let dst = &args[2]; + + if let Err(e) = fs::copy(src, dst) { + eprintln!("cp: {src} -> {dst}: {e}"); + return ExitCode::from(1); + } + + ExitCode::from(0) +} diff --git a/base/cp/src/syscalls.rs b/base/cp/src/syscalls.rs new file mode 100644 index 00000000..7dfed576 --- /dev/null +++ b/base/cp/src/syscalls.rs @@ -0,0 +1,50 @@ +//! C-ABI syscall shims required by the vibix std fork. +//! +//! The in-repo std fork links against POSIX symbols (`close`, etc.) that are +//! not provided by a system libc on vibix. We supply them here via raw +//! syscall instructions, mirroring the approach in `base/sh/src/syscalls.rs`. + +use core::arch::asm; + +const SYS_CLOSE: u64 = 3; + +extern "C" { + fn __errno_location() -> *mut i32; +} + +#[inline(always)] +unsafe fn raw1(nr: u64, a0: u64) -> i64 { + let ret: i64; + unsafe { + asm!( + "syscall", + inlateout("rax") nr => ret, + inlateout("rdi") a0 => _, + lateout("rcx") _, + lateout("r11") _, + lateout("rdx") _, + lateout("rsi") _, + lateout("r8") _, + lateout("r9") _, + lateout("r10") _, + options(nostack), + ); + } + ret +} + +/// Convert raw syscall return to C convention: on error set errno, return -1. +#[inline] +unsafe fn cvt(r: i64) -> i64 { + if r < 0 { + unsafe { *__errno_location() = (-r) as i32 }; + -1 + } else { + r + } +} + +#[no_mangle] +pub unsafe extern "C" fn close(fd: i32) -> i32 { + unsafe { cvt(raw1(SYS_CLOSE, fd as u64)) as i32 } +} diff --git a/base/mkdir/Cargo.toml b/base/mkdir/Cargo.toml new file mode 100644 index 00000000..e19a14fc --- /dev/null +++ b/base/mkdir/Cargo.toml @@ -0,0 +1,14 @@ +[package] +name = "mkdir" +version = "0.1.0" +edition = "2021" +authors = ["vibix hackers"] +license = "MIT OR Apache-2.0" + +[[bin]] +name = "mkdir" +path = "src/main.rs" + +# Standalone package — not part of the main workspace. Built with +# `-Z build-std` against the in-repo std fork (see xtask build). +[workspace] diff --git a/base/mkdir/src/main.rs b/base/mkdir/src/main.rs new file mode 100644 index 00000000..64898967 --- /dev/null +++ b/base/mkdir/src/main.rs @@ -0,0 +1,27 @@ +#![feature(restricted_std)] + +#[cfg(not(test))] +mod syscalls; + +use std::env; +use std::fs; +use std::process::ExitCode; + +fn main() -> ExitCode { + let args: Vec = env::args().collect(); + + if args.len() <= 1 { + eprintln!("mkdir: missing operand"); + return ExitCode::from(1); + } + + let mut status: u8 = 0; + for path in &args[1..] { + if let Err(e) = fs::create_dir(path) { + eprintln!("mkdir: {path}: {e}"); + status = 1; + } + } + + ExitCode::from(status) +} diff --git a/base/mkdir/src/syscalls.rs b/base/mkdir/src/syscalls.rs new file mode 100644 index 00000000..7dfed576 --- /dev/null +++ b/base/mkdir/src/syscalls.rs @@ -0,0 +1,50 @@ +//! C-ABI syscall shims required by the vibix std fork. +//! +//! The in-repo std fork links against POSIX symbols (`close`, etc.) that are +//! not provided by a system libc on vibix. We supply them here via raw +//! syscall instructions, mirroring the approach in `base/sh/src/syscalls.rs`. + +use core::arch::asm; + +const SYS_CLOSE: u64 = 3; + +extern "C" { + fn __errno_location() -> *mut i32; +} + +#[inline(always)] +unsafe fn raw1(nr: u64, a0: u64) -> i64 { + let ret: i64; + unsafe { + asm!( + "syscall", + inlateout("rax") nr => ret, + inlateout("rdi") a0 => _, + lateout("rcx") _, + lateout("r11") _, + lateout("rdx") _, + lateout("rsi") _, + lateout("r8") _, + lateout("r9") _, + lateout("r10") _, + options(nostack), + ); + } + ret +} + +/// Convert raw syscall return to C convention: on error set errno, return -1. +#[inline] +unsafe fn cvt(r: i64) -> i64 { + if r < 0 { + unsafe { *__errno_location() = (-r) as i32 }; + -1 + } else { + r + } +} + +#[no_mangle] +pub unsafe extern "C" fn close(fd: i32) -> i32 { + unsafe { cvt(raw1(SYS_CLOSE, fd as u64)) as i32 } +} diff --git a/base/mv/Cargo.toml b/base/mv/Cargo.toml new file mode 100644 index 00000000..3447a91b --- /dev/null +++ b/base/mv/Cargo.toml @@ -0,0 +1,14 @@ +[package] +name = "mv" +version = "0.1.0" +edition = "2021" +authors = ["vibix hackers"] +license = "MIT OR Apache-2.0" + +[[bin]] +name = "mv" +path = "src/main.rs" + +# Standalone package — not part of the main workspace. Built with +# `-Z build-std` against the in-repo std fork (see xtask build). +[workspace] diff --git a/base/mv/src/main.rs b/base/mv/src/main.rs new file mode 100644 index 00000000..4dd2a398 --- /dev/null +++ b/base/mv/src/main.rs @@ -0,0 +1,27 @@ +#![feature(restricted_std)] + +#[cfg(not(test))] +mod syscalls; + +use std::env; +use std::fs; +use std::process::ExitCode; + +fn main() -> ExitCode { + let args: Vec = env::args().collect(); + + if args.len() != 3 { + eprintln!("usage: mv "); + return ExitCode::from(1); + } + + let src = &args[1]; + let dst = &args[2]; + + if let Err(e) = fs::rename(src, dst) { + eprintln!("mv: {src} -> {dst}: {e}"); + return ExitCode::from(1); + } + + ExitCode::from(0) +} diff --git a/base/mv/src/syscalls.rs b/base/mv/src/syscalls.rs new file mode 100644 index 00000000..7dfed576 --- /dev/null +++ b/base/mv/src/syscalls.rs @@ -0,0 +1,50 @@ +//! C-ABI syscall shims required by the vibix std fork. +//! +//! The in-repo std fork links against POSIX symbols (`close`, etc.) that are +//! not provided by a system libc on vibix. We supply them here via raw +//! syscall instructions, mirroring the approach in `base/sh/src/syscalls.rs`. + +use core::arch::asm; + +const SYS_CLOSE: u64 = 3; + +extern "C" { + fn __errno_location() -> *mut i32; +} + +#[inline(always)] +unsafe fn raw1(nr: u64, a0: u64) -> i64 { + let ret: i64; + unsafe { + asm!( + "syscall", + inlateout("rax") nr => ret, + inlateout("rdi") a0 => _, + lateout("rcx") _, + lateout("r11") _, + lateout("rdx") _, + lateout("rsi") _, + lateout("r8") _, + lateout("r9") _, + lateout("r10") _, + options(nostack), + ); + } + ret +} + +/// Convert raw syscall return to C convention: on error set errno, return -1. +#[inline] +unsafe fn cvt(r: i64) -> i64 { + if r < 0 { + unsafe { *__errno_location() = (-r) as i32 }; + -1 + } else { + r + } +} + +#[no_mangle] +pub unsafe extern "C" fn close(fd: i32) -> i32 { + unsafe { cvt(raw1(SYS_CLOSE, fd as u64)) as i32 } +} diff --git a/base/rm/Cargo.toml b/base/rm/Cargo.toml new file mode 100644 index 00000000..dd35fda8 --- /dev/null +++ b/base/rm/Cargo.toml @@ -0,0 +1,14 @@ +[package] +name = "rm" +version = "0.1.0" +edition = "2021" +authors = ["vibix hackers"] +license = "MIT OR Apache-2.0" + +[[bin]] +name = "rm" +path = "src/main.rs" + +# Standalone package — not part of the main workspace. Built with +# `-Z build-std` against the in-repo std fork (see xtask build). +[workspace] diff --git a/base/rm/src/main.rs b/base/rm/src/main.rs new file mode 100644 index 00000000..a47d5457 --- /dev/null +++ b/base/rm/src/main.rs @@ -0,0 +1,27 @@ +#![feature(restricted_std)] + +#[cfg(not(test))] +mod syscalls; + +use std::env; +use std::fs; +use std::process::ExitCode; + +fn main() -> ExitCode { + let args: Vec = env::args().collect(); + + if args.len() <= 1 { + eprintln!("rm: missing operand"); + return ExitCode::from(1); + } + + let mut status: u8 = 0; + for path in &args[1..] { + if let Err(e) = fs::remove_file(path) { + eprintln!("rm: {path}: {e}"); + status = 1; + } + } + + ExitCode::from(status) +} diff --git a/base/rm/src/syscalls.rs b/base/rm/src/syscalls.rs new file mode 100644 index 00000000..7dfed576 --- /dev/null +++ b/base/rm/src/syscalls.rs @@ -0,0 +1,50 @@ +//! C-ABI syscall shims required by the vibix std fork. +//! +//! The in-repo std fork links against POSIX symbols (`close`, etc.) that are +//! not provided by a system libc on vibix. We supply them here via raw +//! syscall instructions, mirroring the approach in `base/sh/src/syscalls.rs`. + +use core::arch::asm; + +const SYS_CLOSE: u64 = 3; + +extern "C" { + fn __errno_location() -> *mut i32; +} + +#[inline(always)] +unsafe fn raw1(nr: u64, a0: u64) -> i64 { + let ret: i64; + unsafe { + asm!( + "syscall", + inlateout("rax") nr => ret, + inlateout("rdi") a0 => _, + lateout("rcx") _, + lateout("r11") _, + lateout("rdx") _, + lateout("rsi") _, + lateout("r8") _, + lateout("r9") _, + lateout("r10") _, + options(nostack), + ); + } + ret +} + +/// Convert raw syscall return to C convention: on error set errno, return -1. +#[inline] +unsafe fn cvt(r: i64) -> i64 { + if r < 0 { + unsafe { *__errno_location() = (-r) as i32 }; + -1 + } else { + r + } +} + +#[no_mangle] +pub unsafe extern "C" fn close(fd: i32) -> i32 { + unsafe { cvt(raw1(SYS_CLOSE, fd as u64)) as i32 } +} diff --git a/base/rmdir/Cargo.toml b/base/rmdir/Cargo.toml new file mode 100644 index 00000000..a8418acc --- /dev/null +++ b/base/rmdir/Cargo.toml @@ -0,0 +1,14 @@ +[package] +name = "rmdir" +version = "0.1.0" +edition = "2021" +authors = ["vibix hackers"] +license = "MIT OR Apache-2.0" + +[[bin]] +name = "rmdir" +path = "src/main.rs" + +# Standalone package — not part of the main workspace. Built with +# `-Z build-std` against the in-repo std fork (see xtask build). +[workspace] diff --git a/base/rmdir/src/main.rs b/base/rmdir/src/main.rs new file mode 100644 index 00000000..9d82259c --- /dev/null +++ b/base/rmdir/src/main.rs @@ -0,0 +1,27 @@ +#![feature(restricted_std)] + +#[cfg(not(test))] +mod syscalls; + +use std::env; +use std::fs; +use std::process::ExitCode; + +fn main() -> ExitCode { + let args: Vec = env::args().collect(); + + if args.len() <= 1 { + eprintln!("rmdir: missing operand"); + return ExitCode::from(1); + } + + let mut status: u8 = 0; + for path in &args[1..] { + if let Err(e) = fs::remove_dir(path) { + eprintln!("rmdir: {path}: {e}"); + status = 1; + } + } + + ExitCode::from(status) +} diff --git a/base/rmdir/src/syscalls.rs b/base/rmdir/src/syscalls.rs new file mode 100644 index 00000000..7dfed576 --- /dev/null +++ b/base/rmdir/src/syscalls.rs @@ -0,0 +1,50 @@ +//! C-ABI syscall shims required by the vibix std fork. +//! +//! The in-repo std fork links against POSIX symbols (`close`, etc.) that are +//! not provided by a system libc on vibix. We supply them here via raw +//! syscall instructions, mirroring the approach in `base/sh/src/syscalls.rs`. + +use core::arch::asm; + +const SYS_CLOSE: u64 = 3; + +extern "C" { + fn __errno_location() -> *mut i32; +} + +#[inline(always)] +unsafe fn raw1(nr: u64, a0: u64) -> i64 { + let ret: i64; + unsafe { + asm!( + "syscall", + inlateout("rax") nr => ret, + inlateout("rdi") a0 => _, + lateout("rcx") _, + lateout("r11") _, + lateout("rdx") _, + lateout("rsi") _, + lateout("r8") _, + lateout("r9") _, + lateout("r10") _, + options(nostack), + ); + } + ret +} + +/// Convert raw syscall return to C convention: on error set errno, return -1. +#[inline] +unsafe fn cvt(r: i64) -> i64 { + if r < 0 { + unsafe { *__errno_location() = (-r) as i32 }; + -1 + } else { + r + } +} + +#[no_mangle] +pub unsafe extern "C" fn close(fd: i32) -> i32 { + unsafe { cvt(raw1(SYS_CLOSE, fd as u64)) as i32 } +} diff --git a/base/stat/Cargo.toml b/base/stat/Cargo.toml new file mode 100644 index 00000000..206c42ae --- /dev/null +++ b/base/stat/Cargo.toml @@ -0,0 +1,14 @@ +[package] +name = "stat" +version = "0.1.0" +edition = "2021" +authors = ["vibix hackers"] +license = "MIT OR Apache-2.0" + +[[bin]] +name = "stat" +path = "src/main.rs" + +# Standalone package — not part of the main workspace. Built with +# `-Z build-std` against the in-repo std fork (see xtask build). +[workspace] diff --git a/base/stat/src/main.rs b/base/stat/src/main.rs new file mode 100644 index 00000000..e6ebcb82 --- /dev/null +++ b/base/stat/src/main.rs @@ -0,0 +1,55 @@ +#![feature(restricted_std)] + +#[cfg(not(test))] +mod syscalls; + +use std::env; +use std::fs; +use std::os::unix::fs::MetadataExt; +use std::process::ExitCode; + +fn stat_path(path: &str) -> u8 { + let meta = match fs::symlink_metadata(path) { + Ok(m) => m, + Err(e) => { + eprintln!("stat: {path}: {e}"); + return 1; + } + }; + + let file_type = if meta.is_dir() { + "directory" + } else if meta.is_symlink() { + "symbolic link" + } else { + "regular file" + }; + + println!(" File: {path}"); + println!(" Size: {}", meta.len()); + println!(" Type: {file_type}"); + println!(" Mode: {:o}", meta.mode()); + println!(" Inode: {}", meta.ino()); + println!(" Links: {}", meta.nlink()); + + 0 +} + +fn main() -> ExitCode { + let args: Vec = env::args().collect(); + + if args.len() <= 1 { + eprintln!("stat: missing operand"); + return ExitCode::from(1); + } + + let mut status: u8 = 0; + for path in &args[1..] { + let s = stat_path(path); + if s != 0 { + status = s; + } + } + + ExitCode::from(status) +} diff --git a/base/stat/src/syscalls.rs b/base/stat/src/syscalls.rs new file mode 100644 index 00000000..7dfed576 --- /dev/null +++ b/base/stat/src/syscalls.rs @@ -0,0 +1,50 @@ +//! C-ABI syscall shims required by the vibix std fork. +//! +//! The in-repo std fork links against POSIX symbols (`close`, etc.) that are +//! not provided by a system libc on vibix. We supply them here via raw +//! syscall instructions, mirroring the approach in `base/sh/src/syscalls.rs`. + +use core::arch::asm; + +const SYS_CLOSE: u64 = 3; + +extern "C" { + fn __errno_location() -> *mut i32; +} + +#[inline(always)] +unsafe fn raw1(nr: u64, a0: u64) -> i64 { + let ret: i64; + unsafe { + asm!( + "syscall", + inlateout("rax") nr => ret, + inlateout("rdi") a0 => _, + lateout("rcx") _, + lateout("r11") _, + lateout("rdx") _, + lateout("rsi") _, + lateout("r8") _, + lateout("r9") _, + lateout("r10") _, + options(nostack), + ); + } + ret +} + +/// Convert raw syscall return to C convention: on error set errno, return -1. +#[inline] +unsafe fn cvt(r: i64) -> i64 { + if r < 0 { + unsafe { *__errno_location() = (-r) as i32 }; + -1 + } else { + r + } +} + +#[no_mangle] +pub unsafe extern "C" fn close(fd: i32) -> i32 { + unsafe { cvt(raw1(SYS_CLOSE, fd as u64)) as i32 } +} diff --git a/base/touch/Cargo.toml b/base/touch/Cargo.toml new file mode 100644 index 00000000..444fbc1f --- /dev/null +++ b/base/touch/Cargo.toml @@ -0,0 +1,14 @@ +[package] +name = "touch" +version = "0.1.0" +edition = "2021" +authors = ["vibix hackers"] +license = "MIT OR Apache-2.0" + +[[bin]] +name = "touch" +path = "src/main.rs" + +# Standalone package — not part of the main workspace. Built with +# `-Z build-std` against the in-repo std fork (see xtask build). +[workspace] diff --git a/base/touch/src/main.rs b/base/touch/src/main.rs new file mode 100644 index 00000000..cdbcb654 --- /dev/null +++ b/base/touch/src/main.rs @@ -0,0 +1,27 @@ +#![feature(restricted_std)] + +#[cfg(not(test))] +mod syscalls; + +use std::env; +use std::fs::OpenOptions; +use std::process::ExitCode; + +fn main() -> ExitCode { + let args: Vec = env::args().collect(); + + if args.len() <= 1 { + eprintln!("touch: missing operand"); + return ExitCode::from(1); + } + + let mut status: u8 = 0; + for path in &args[1..] { + if let Err(e) = OpenOptions::new().create(true).write(true).open(path) { + eprintln!("touch: {path}: {e}"); + status = 1; + } + } + + ExitCode::from(status) +} diff --git a/base/touch/src/syscalls.rs b/base/touch/src/syscalls.rs new file mode 100644 index 00000000..7dfed576 --- /dev/null +++ b/base/touch/src/syscalls.rs @@ -0,0 +1,50 @@ +//! C-ABI syscall shims required by the vibix std fork. +//! +//! The in-repo std fork links against POSIX symbols (`close`, etc.) that are +//! not provided by a system libc on vibix. We supply them here via raw +//! syscall instructions, mirroring the approach in `base/sh/src/syscalls.rs`. + +use core::arch::asm; + +const SYS_CLOSE: u64 = 3; + +extern "C" { + fn __errno_location() -> *mut i32; +} + +#[inline(always)] +unsafe fn raw1(nr: u64, a0: u64) -> i64 { + let ret: i64; + unsafe { + asm!( + "syscall", + inlateout("rax") nr => ret, + inlateout("rdi") a0 => _, + lateout("rcx") _, + lateout("r11") _, + lateout("rdx") _, + lateout("rsi") _, + lateout("r8") _, + lateout("r9") _, + lateout("r10") _, + options(nostack), + ); + } + ret +} + +/// Convert raw syscall return to C convention: on error set errno, return -1. +#[inline] +unsafe fn cvt(r: i64) -> i64 { + if r < 0 { + unsafe { *__errno_location() = (-r) as i32 }; + -1 + } else { + r + } +} + +#[no_mangle] +pub unsafe extern "C" fn close(fd: i32) -> i32 { + unsafe { cvt(raw1(SYS_CLOSE, fd as u64)) as i32 } +} diff --git a/base/uname/Cargo.toml b/base/uname/Cargo.toml new file mode 100644 index 00000000..64c78227 --- /dev/null +++ b/base/uname/Cargo.toml @@ -0,0 +1,14 @@ +[package] +name = "uname" +version = "0.1.0" +edition = "2021" +authors = ["vibix hackers"] +license = "MIT OR Apache-2.0" + +[[bin]] +name = "uname" +path = "src/main.rs" + +# Standalone package — not part of the main workspace. Built with +# `-Z build-std` against the in-repo std fork (see xtask build). +[workspace] diff --git a/base/uname/src/main.rs b/base/uname/src/main.rs new file mode 100644 index 00000000..16a2b982 --- /dev/null +++ b/base/uname/src/main.rs @@ -0,0 +1,26 @@ +#![feature(restricted_std)] + +#[cfg(not(test))] +mod syscalls; + +use std::env; +use std::process::ExitCode; + +fn main() -> ExitCode { + let args: Vec = env::args().collect(); + + match args.len() { + 1 => { + println!("vibix"); + } + 2 if args[1] == "-a" => { + println!("vibix vibix 0.1.0 x86_64"); + } + _ => { + eprintln!("usage: uname [-a]"); + return ExitCode::from(1); + } + } + + ExitCode::from(0) +} diff --git a/base/uname/src/syscalls.rs b/base/uname/src/syscalls.rs new file mode 100644 index 00000000..7dfed576 --- /dev/null +++ b/base/uname/src/syscalls.rs @@ -0,0 +1,50 @@ +//! C-ABI syscall shims required by the vibix std fork. +//! +//! The in-repo std fork links against POSIX symbols (`close`, etc.) that are +//! not provided by a system libc on vibix. We supply them here via raw +//! syscall instructions, mirroring the approach in `base/sh/src/syscalls.rs`. + +use core::arch::asm; + +const SYS_CLOSE: u64 = 3; + +extern "C" { + fn __errno_location() -> *mut i32; +} + +#[inline(always)] +unsafe fn raw1(nr: u64, a0: u64) -> i64 { + let ret: i64; + unsafe { + asm!( + "syscall", + inlateout("rax") nr => ret, + inlateout("rdi") a0 => _, + lateout("rcx") _, + lateout("r11") _, + lateout("rdx") _, + lateout("rsi") _, + lateout("r8") _, + lateout("r9") _, + lateout("r10") _, + options(nostack), + ); + } + ret +} + +/// Convert raw syscall return to C convention: on error set errno, return -1. +#[inline] +unsafe fn cvt(r: i64) -> i64 { + if r < 0 { + unsafe { *__errno_location() = (-r) as i32 }; + -1 + } else { + r + } +} + +#[no_mangle] +pub unsafe extern "C" fn close(fd: i32) -> i32 { + unsafe { cvt(raw1(SYS_CLOSE, fd as u64)) as i32 } +} diff --git a/xtask/src/main.rs b/xtask/src/main.rs index f18322ee..f59ee711 100644 --- a/xtask/src/main.rs +++ b/xtask/src/main.rs @@ -860,6 +860,46 @@ fn build_userspace_ls() -> R { build_userspace_std_bin("base/ls/Cargo.toml", "ls") } +/// Build the `/bin/stat` binary — display file status. +fn build_userspace_stat() -> R { + build_userspace_std_bin("base/stat/Cargo.toml", "stat") +} + +/// Build the `/bin/cp` binary — copy files. +fn build_userspace_cp() -> R { + build_userspace_std_bin("base/cp/Cargo.toml", "cp") +} + +/// Build the `/bin/mv` binary — move/rename files. +fn build_userspace_mv() -> R { + build_userspace_std_bin("base/mv/Cargo.toml", "mv") +} + +/// Build the `/bin/rm` binary — remove files. +fn build_userspace_rm() -> R { + build_userspace_std_bin("base/rm/Cargo.toml", "rm") +} + +/// Build the `/bin/mkdir` binary — create directories. +fn build_userspace_mkdir() -> R { + build_userspace_std_bin("base/mkdir/Cargo.toml", "mkdir") +} + +/// Build the `/bin/rmdir` binary — remove empty directories. +fn build_userspace_rmdir() -> R { + build_userspace_std_bin("base/rmdir/Cargo.toml", "rmdir") +} + +/// Build the `/bin/touch` binary — create empty files. +fn build_userspace_touch() -> R { + build_userspace_std_bin("base/touch/Cargo.toml", "touch") +} + +/// Build the `/bin/uname` binary — print system information. +fn build_userspace_uname() -> R { + build_userspace_std_bin("base/uname/Cargo.toml", "uname") +} + /// Generate a minimal stub dynamic-linker ELF for the #764 integration test. /// /// Produces an ET_DYN ELF64 with a single page-aligned PT_LOAD segment. @@ -1741,10 +1781,26 @@ fn run_with_root(opts: &BuildOpts, root_flag: Option<&str>, cmdline_extras: &[&s let sh_bin = build_userspace_sh()?; let cat_bin = build_userspace_cat()?; let ls_bin = build_userspace_ls()?; + let stat_bin = build_userspace_stat()?; + let cp_bin = build_userspace_cp()?; + let mv_bin = build_userspace_mv()?; + let rm_bin = build_userspace_rm()?; + let mkdir_bin = build_userspace_mkdir()?; + let rmdir_bin = build_userspace_rmdir()?; + let touch_bin = build_userspace_touch()?; + let uname_bin = build_userspace_uname()?; let extras: Vec<(&Path, &str)> = vec![ (&sh_bin, "/bin/sh"), (&cat_bin, "/bin/cat"), (&ls_bin, "/bin/ls"), + (&stat_bin, "/bin/stat"), + (&cp_bin, "/bin/cp"), + (&mv_bin, "/bin/mv"), + (&rm_bin, "/bin/rm"), + (&mkdir_bin, "/bin/mkdir"), + (&rmdir_bin, "/bin/rmdir"), + (&touch_bin, "/bin/touch"), + (&uname_bin, "/bin/uname"), ]; let img = ext2_image::build_with_extras(&workspace_root(), Some(&init_bin), &extras, true)?; @@ -1763,10 +1819,26 @@ fn run_with_root(opts: &BuildOpts, root_flag: Option<&str>, cmdline_extras: &[&s let sh_bin = build_userspace_sh()?; let cat_bin = build_userspace_cat()?; let ls_bin = build_userspace_ls()?; + let stat_bin = build_userspace_stat()?; + let cp_bin = build_userspace_cp()?; + let mv_bin = build_userspace_mv()?; + let rm_bin = build_userspace_rm()?; + let mkdir_bin = build_userspace_mkdir()?; + let rmdir_bin = build_userspace_rmdir()?; + let touch_bin = build_userspace_touch()?; + let uname_bin = build_userspace_uname()?; let extras: Vec<(&Path, &str)> = vec![ (&sh_bin, "/bin/sh"), (&cat_bin, "/bin/cat"), (&ls_bin, "/bin/ls"), + (&stat_bin, "/bin/stat"), + (&cp_bin, "/bin/cp"), + (&mv_bin, "/bin/mv"), + (&rm_bin, "/bin/rm"), + (&mkdir_bin, "/bin/mkdir"), + (&rmdir_bin, "/bin/rmdir"), + (&touch_bin, "/bin/touch"), + (&uname_bin, "/bin/uname"), ]; let img = ext2_image::build_with_extras(&workspace_root(), Some(&init_bin), &extras, true)?; @@ -2110,10 +2182,26 @@ fn smoke(opts: &BuildOpts) -> R<()> { let sh_bin = build_userspace_sh()?; let cat_bin = build_userspace_cat()?; let ls_bin = build_userspace_ls()?; + let stat_bin = build_userspace_stat()?; + let cp_bin = build_userspace_cp()?; + let mv_bin = build_userspace_mv()?; + let rm_bin = build_userspace_rm()?; + let mkdir_bin = build_userspace_mkdir()?; + let rmdir_bin = build_userspace_rmdir()?; + let touch_bin = build_userspace_touch()?; + let uname_bin = build_userspace_uname()?; let extras: Vec<(&Path, &str)> = vec![ (&sh_bin, "/bin/sh"), (&cat_bin, "/bin/cat"), (&ls_bin, "/bin/ls"), + (&stat_bin, "/bin/stat"), + (&cp_bin, "/bin/cp"), + (&mv_bin, "/bin/mv"), + (&rm_bin, "/bin/rm"), + (&mkdir_bin, "/bin/mkdir"), + (&rmdir_bin, "/bin/rmdir"), + (&touch_bin, "/bin/touch"), + (&uname_bin, "/bin/uname"), ]; let disk = ext2_image::build_with_extras(&workspace_root(), Some(&userspace_init), &extras, true)?; @@ -2894,12 +2982,28 @@ fn sh_test(opts: &BuildOpts) -> R<()> { let sh_bin = build_userspace_sh()?; let cat_bin = build_userspace_cat()?; let ls_bin = build_userspace_ls()?; - - // Install init as /init and sh/cat/ls as /bin/* in the ext2 rootfs image. + let stat_bin = build_userspace_stat()?; + let cp_bin = build_userspace_cp()?; + let mv_bin = build_userspace_mv()?; + let rm_bin = build_userspace_rm()?; + let mkdir_bin = build_userspace_mkdir()?; + let rmdir_bin = build_userspace_rmdir()?; + let touch_bin = build_userspace_touch()?; + let uname_bin = build_userspace_uname()?; + + // Install init as /init and sh/cat/ls/etc. as /bin/* in the ext2 rootfs image. let extras: Vec<(&Path, &str)> = vec![ (&sh_bin, "/bin/sh"), (&cat_bin, "/bin/cat"), (&ls_bin, "/bin/ls"), + (&stat_bin, "/bin/stat"), + (&cp_bin, "/bin/cp"), + (&mv_bin, "/bin/mv"), + (&rm_bin, "/bin/rm"), + (&mkdir_bin, "/bin/mkdir"), + (&rmdir_bin, "/bin/rmdir"), + (&touch_bin, "/bin/touch"), + (&uname_bin, "/bin/uname"), ]; let disk = ext2_image::build_with_extras(&workspace_root(), Some(&init_bin), &extras, true)?; let iso = workspace_root().join("target").join("vibix-sh.iso");