diff --git a/sandbox/src/syscall/file.rs b/sandbox/src/syscall/file.rs index 2823cb81..8bfa6c4f 100644 --- a/sandbox/src/syscall/file.rs +++ b/sandbox/src/syscall/file.rs @@ -1592,3 +1592,20 @@ pub async fn handle_getpeername>( // FD not in table, let the original syscall through (will likely fail with EBADF) Ok(None) } + +/// The `rmdir` system call. +/// +/// This intercepts `rmdir` system calls and translates paths according to the mount table. +pub async fn handle_rmdir>( + guest: &mut T, + args: &reverie::syscalls::Rmdir, + mount_table: &MountTable, +) -> Result, Error> { + if let Some(path_addr) = args.path() { + if let Some(new_path_addr) = translate_path(guest, path_addr, mount_table).await? { + let new_syscall = args.with_path(Some(new_path_addr)); + return Ok(Some(Syscall::Rmdir(new_syscall))); + } + } + Ok(None) +} \ No newline at end of file diff --git a/sandbox/src/syscall/mod.rs b/sandbox/src/syscall/mod.rs index b324fc01..ff5fd758 100644 --- a/sandbox/src/syscall/mod.rs +++ b/sandbox/src/syscall/mod.rs @@ -132,6 +132,13 @@ pub async fn dispatch_syscall>( Ok(SyscallResult::Syscall(syscall)) } } + Syscall::Rmdir(args) => { + if let Some(modified) = file::handle_rmdir(guest, args, mount_table).await? { + Ok(SyscallResult::Syscall(modified)) + } else { + Ok(SyscallResult::Syscall(syscall)) + } + } Syscall::Fork(args) => { if let Some(result) = process::handle_fork(guest, args, fd_table).await? { Ok(SyscallResult::Value(result))