Skip to content
Merged
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
34 changes: 9 additions & 25 deletions sandbox/src/syscall/file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,10 +154,7 @@ pub async fn handle_read<T: Guest<Sandbox>>(
match entry {
FdEntry::Passthrough { kernel_fd, .. } => {
// Passthrough file - rewrite FD and return modified syscall for tail_inject
let new_syscall = reverie::syscalls::Read::new()
.with_fd(kernel_fd)
.with_buf(args.buf())
.with_len(args.len());
let new_syscall = args.with_fd(kernel_fd);

return Ok(crate::syscall::SyscallResult::Syscall(Syscall::Read(
new_syscall,
Expand Down Expand Up @@ -216,10 +213,7 @@ pub async fn handle_write<T: Guest<Sandbox>>(
match entry {
FdEntry::Passthrough { kernel_fd, .. } => {
// Passthrough file - rewrite FD and return modified syscall for tail_inject
let new_syscall = reverie::syscalls::Write::new()
.with_fd(kernel_fd)
.with_buf(args.buf())
.with_len(args.len());
let new_syscall = args.with_fd(kernel_fd);

return Ok(crate::syscall::SyscallResult::Syscall(Syscall::Write(
new_syscall,
Expand Down Expand Up @@ -277,7 +271,7 @@ pub async fn handle_close<T: Guest<Sandbox>>(
match entry {
FdEntry::Passthrough { kernel_fd, .. } => {
// Passthrough file - rewrite FD and return modified syscall for tail_inject
let new_syscall = reverie::syscalls::Close::new().with_fd(kernel_fd);
let new_syscall = args.with_fd(kernel_fd);

return Ok(crate::syscall::SyscallResult::Syscall(Syscall::Close(
new_syscall,
Expand Down Expand Up @@ -967,10 +961,7 @@ pub async fn handle_getdents64<T: Guest<Sandbox>>(
match entry {
FdEntry::Passthrough { kernel_fd, .. } => {
// Passthrough file - rewrite FD and return modified syscall for tail_inject
let new_syscall = reverie::syscalls::Getdents64::new()
.with_fd(kernel_fd as u32)
.with_dirent(args.dirent())
.with_count(args.count());
let new_syscall = args.with_fd(kernel_fd as u32);

return Ok(crate::syscall::SyscallResult::Syscall(Syscall::Getdents64(
new_syscall,
Expand Down Expand Up @@ -1056,9 +1047,7 @@ pub async fn handle_fstat<T: Guest<Sandbox>>(
match entry {
FdEntry::Passthrough { kernel_fd, .. } => {
// Passthrough file - rewrite FD and return modified syscall for tail_inject
let new_syscall = reverie::syscalls::Fstat::new()
.with_fd(kernel_fd)
.with_stat(args.stat());
let new_syscall = args.with_fd(kernel_fd);

return Ok(crate::syscall::SyscallResult::Syscall(Syscall::Fstat(
new_syscall,
Expand Down Expand Up @@ -1170,10 +1159,7 @@ pub async fn handle_lseek<T: Guest<Sandbox>>(
match entry {
FdEntry::Passthrough { kernel_fd, .. } => {
// Passthrough file - rewrite FD and return modified syscall for tail_inject
let new_syscall = reverie::syscalls::Lseek::new()
.with_fd(kernel_fd)
.with_offset(args.offset())
.with_whence(args.whence());
let new_syscall = args.with_fd(kernel_fd);

return Ok(crate::syscall::SyscallResult::Syscall(Syscall::Lseek(
new_syscall,
Expand Down Expand Up @@ -1257,9 +1243,7 @@ pub async fn handle_access<T: Guest<Sandbox>>(
) -> 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 = reverie::syscalls::Access::new()
.with_path(Some(new_path_addr))
.with_mode(args.mode());
let new_syscall = args.with_path(Some(new_path_addr));

return Ok(Some(Syscall::Access(new_syscall)));
}
Expand Down Expand Up @@ -1342,7 +1326,7 @@ pub async fn handle_rename<T: Guest<Sandbox>>(
}

// Build new syscall with translated paths
let mut new_syscall = reverie::syscalls::Rename::new();
let mut new_syscall = *args;
let mut modified = false;

// Translate oldpath
Expand Down Expand Up @@ -1382,7 +1366,7 @@ pub async fn handle_unlink<T: Guest<Sandbox>>(
) -> 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 = reverie::syscalls::Unlink::new().with_path(Some(new_path_addr));
let new_syscall = args.with_path(Some(new_path_addr));

return Ok(Some(Syscall::Unlink(new_syscall)));
}
Expand Down
4 changes: 1 addition & 3 deletions sandbox/src/syscall/stat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,9 +148,7 @@ pub async fn handle_statfs<T: Guest<Sandbox>>(
) -> 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 = reverie::syscalls::Statfs::new()
.with_path(Some(new_path_addr))
.with_buf(args.buf());
let new_syscall = args.with_path(Some(new_path_addr));

return Ok(Some(Syscall::Statfs(new_syscall)));
}
Expand Down
11 changes: 2 additions & 9 deletions sandbox/src/syscall/xattr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,7 @@ pub async fn handle_llistxattr<T: Guest<Sandbox>>(
) -> 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 = reverie::syscalls::Llistxattr::new()
.with_path(Some(new_path_addr))
.with_list(args.list())
.with_size(args.size());
let new_syscall = args.with_path(Some(new_path_addr));

return Ok(Some(Syscall::Llistxattr(new_syscall)));
}
Expand All @@ -36,11 +33,7 @@ pub async fn handle_lgetxattr<T: Guest<Sandbox>>(
) -> 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 = reverie::syscalls::Lgetxattr::new()
.with_path(Some(new_path_addr))
.with_name(args.name())
.with_value(args.value())
.with_size(args.size());
let new_syscall = args.with_path(Some(new_path_addr));

return Ok(Some(Syscall::Lgetxattr(new_syscall)));
}
Expand Down