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
17 changes: 17 additions & 0 deletions sandbox/src/syscall/file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1592,3 +1592,20 @@ pub async fn handle_getpeername<T: Guest<Sandbox>>(
// 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<T: Guest<Sandbox>>(
guest: &mut T,
args: &reverie::syscalls::Rmdir,
mount_table: &MountTable,
) -> Result<Option<Syscall>, 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)
}
7 changes: 7 additions & 0 deletions sandbox/src/syscall/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,13 @@ pub async fn dispatch_syscall<T: Guest<Sandbox>>(
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))
Expand Down