Skip to content

Commit

Permalink
syscall: add sock_shutdown()
Browse files Browse the repository at this point in the history
Signed-off-by: Anhad Singh <[email protected]>
  • Loading branch information
Andy-Python-Programmer committed Aug 3, 2023
1 parent 21b6afb commit 43a71aa
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/aero_kernel/src/fs/inode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,10 @@ pub trait INodeInterface: Send + Sync {
Ok(aero_syscall::Stat::default())
}

fn shutdown(&self, _how: usize) -> Result<()> {
Err(FileSystemError::NotSupported)
}

/// Creates a new dev inode with the provided `name` and the device `marker` in
/// the filesystem.
///
Expand Down
5 changes: 5 additions & 0 deletions src/aero_kernel/src/socket/unix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -434,4 +434,9 @@ impl INodeInterface for UnixSocket {

Ok(events)
}

fn shutdown(&self, how: usize) -> fs::Result<()> {
log::warn!("shutdown how={how}");
Ok(())
}
}
1 change: 1 addition & 0 deletions src/aero_kernel/src/syscall/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,7 @@ pub fn generic_do_syscall(
SYS_SOCK_RECV => net::sock_recv(b, c, d),
SYS_SOCK_SEND => net::sock_send(b, c, d),
SYS_SOCKET_PAIR => net::socket_pair(b, c, d, e),
SYS_SOCK_SHUTDOWN => net::shutdown(b, c),

SYS_GETTIME => time::gettime(b, c),
SYS_SLEEP => time::sleep(b),
Expand Down
9 changes: 9 additions & 0 deletions src/aero_kernel/src/syscall/net.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,15 @@ fn socket_addr_from_addr<'sys>(address: VirtAddr) -> Result<SocketAddr<'sys>, Sy
SocketAddr::from_family(address, family)
}

#[syscall]
pub fn shutdown(fd: usize, how: usize) -> Result<usize, SyscallError> {
let file_table = &scheduler::get_scheduler().current_task().file_table;
let socket = file_table.get_handle(fd).ok_or(SyscallError::EINVAL)?;

socket.inode().shutdown(how)?;
Ok(0)
}

/// Connects the socket to the specified address.
#[syscall]
pub fn connect(fd: usize, address: usize, length: usize) -> Result<usize, SyscallError> {
Expand Down
1 change: 1 addition & 0 deletions src/aero_syscall/src/consts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ pub const SYS_TRACE: usize = 71;
pub const SYS_SETPGID: usize = 72;
pub const SYS_SETSID: usize = 73;
pub const SYS_GETPGID: usize = 74;
pub const SYS_SOCK_SHUTDOWN: usize = 75;

// constants for fcntl()'s command argument:
pub const F_DUPFD: usize = 1;
Expand Down

0 comments on commit 43a71aa

Please sign in to comment.