Introduce syscall6. Add unlinkat and remove unlink and rmdir.

This commit is contained in:
Ibuki Omatsu
2025-12-18 01:31:04 +00:00
committed by Jeremy Soller
parent d9eae6bb75
commit e30ed9ab6a
23 changed files with 204 additions and 112 deletions
+21 -13
View File
@@ -42,20 +42,28 @@ unsafe fn read_struct<T>(ptr: usize) -> Result<T> {
}
//TODO: calling format_call with arguments from another process space will not work
pub fn format_call(a: usize, b: usize, c: usize, d: usize, e: usize, f: usize) -> String {
pub fn format_call(a: usize, b: usize, c: usize, d: usize, e: usize, f: usize, g: usize) -> String {
match a {
SYS_OPEN => format!(
"open({:?}, {:#X})",
debug_path(b, c).as_ref().map(|p| ByteStr(p.as_bytes())),
d
),
SYS_RMDIR => format!(
"rmdir({:?})",
debug_path(b, c).as_ref().map(|p| ByteStr(p.as_bytes())),
SYS_OPENAT => format!(
"openat({} {:?}, {:#0x}, {}, {})",
b,
debug_path(c, d).as_ref().map(|p| ByteStr(p.as_bytes())),
e,
f,
g
),
SYS_UNLINK => format!(
"unlink({:?})",
debug_path(b, c).as_ref().map(|p| ByteStr(p.as_bytes())),
SYS_UNLINKAT => format!(
"unlinkat({} {:?}, {:#0x}, {}, {})",
b,
debug_path(c, d).as_ref().map(|p| ByteStr(p.as_bytes())),
e,
f,
g,
),
SYS_CLOSE => format!("close({})", b),
SYS_DUP => format!(
@@ -186,8 +194,8 @@ pub fn format_call(a: usize, b: usize, c: usize, d: usize, e: usize, f: usize) -
),
SYS_YIELD => format!("yield()"),
_ => format!(
"UNKNOWN{} {:#X}({:#X}, {:#X}, {:#X}, {:#X}, {:#X})",
a, a, b, c, d, e, f
"UNKNOWN{} {:#X}({:#X}, {:#X}, {:#X}, {:#X}, {:#X}, {:#X})",
a, a, b, c, d, e, f, g
),
}
}
@@ -219,7 +227,7 @@ impl SyscallDebugInfo {
}
#[cfg_attr(feature = "syscall_debug", inline)]
pub fn debug_start([a, b, c, d, e, f]: [usize; 6], token: &mut CleanLockToken) {
pub fn debug_start([a, b, c, d, e, f, g]: [usize; 7], token: &mut CleanLockToken) {
if cfg!(not(feature = "syscall_debug")) {
return;
}
@@ -252,7 +260,7 @@ pub fn debug_start([a, b, c, d, e, f]: [usize; 6], token: &mut CleanLockToken) {
// Do format_call outside print! so possible exception handlers cannot reentrantly
// deadlock.
let string = format_call(a, b, c, d, e, f);
let string = format_call(a, b, c, d, e, f, g);
println!("{}", string);
crate::time::monotonic()
@@ -271,7 +279,7 @@ pub fn debug_start([a, b, c, d, e, f]: [usize; 6], token: &mut CleanLockToken) {
#[cfg_attr(feature = "syscall_debug", inline)]
pub fn debug_end(
[a, b, c, d, e, f]: [usize; 6],
[a, b, c, d, e, f, g]: [usize; 7],
result: Result<usize>,
token: &mut CleanLockToken,
) {
@@ -297,7 +305,7 @@ pub fn debug_end(
// Do format_call outside print! so possible exception handlers cannot reentrantly
// deadlock.
let string = format_call(a, b, c, d, e, f);
let string = format_call(a, b, c, d, e, f, g);
print!("{} = ", string);
match result {