diff --git a/src/aero_kernel/src/fs/inode.rs b/src/aero_kernel/src/fs/inode.rs index 7d416803d09..ed6588e00bb 100644 --- a/src/aero_kernel/src/fs/inode.rs +++ b/src/aero_kernel/src/fs/inode.rs @@ -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. /// diff --git a/src/aero_kernel/src/socket/unix.rs b/src/aero_kernel/src/socket/unix.rs index 87bc36840e3..2e860279590 100644 --- a/src/aero_kernel/src/socket/unix.rs +++ b/src/aero_kernel/src/socket/unix.rs @@ -434,4 +434,9 @@ impl INodeInterface for UnixSocket { Ok(events) } + + fn shutdown(&self, how: usize) -> fs::Result<()> { + log::warn!("shutdown how={how}"); + Ok(()) + } } diff --git a/src/aero_kernel/src/syscall/mod.rs b/src/aero_kernel/src/syscall/mod.rs index 6e8f7916122..40cd9190f37 100644 --- a/src/aero_kernel/src/syscall/mod.rs +++ b/src/aero_kernel/src/syscall/mod.rs @@ -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), diff --git a/src/aero_kernel/src/syscall/net.rs b/src/aero_kernel/src/syscall/net.rs index 8e6b94b1d82..05d90a22f55 100644 --- a/src/aero_kernel/src/syscall/net.rs +++ b/src/aero_kernel/src/syscall/net.rs @@ -23,6 +23,15 @@ fn socket_addr_from_addr<'sys>(address: VirtAddr) -> Result, Sy SocketAddr::from_family(address, family) } +#[syscall] +pub fn shutdown(fd: usize, how: usize) -> Result { + 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 { diff --git a/src/aero_syscall/src/consts.rs b/src/aero_syscall/src/consts.rs index f62eefc4fa7..036420483d1 100644 --- a/src/aero_syscall/src/consts.rs +++ b/src/aero_syscall/src/consts.rs @@ -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;