Skip to content

Commit 43a71aa

Browse files
syscall: add sock_shutdown()
Signed-off-by: Anhad Singh <[email protected]>
1 parent 21b6afb commit 43a71aa

File tree

5 files changed

+20
-0
lines changed

5 files changed

+20
-0
lines changed

src/aero_kernel/src/fs/inode.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,10 @@ pub trait INodeInterface: Send + Sync {
157157
Ok(aero_syscall::Stat::default())
158158
}
159159

160+
fn shutdown(&self, _how: usize) -> Result<()> {
161+
Err(FileSystemError::NotSupported)
162+
}
163+
160164
/// Creates a new dev inode with the provided `name` and the device `marker` in
161165
/// the filesystem.
162166
///

src/aero_kernel/src/socket/unix.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -434,4 +434,9 @@ impl INodeInterface for UnixSocket {
434434

435435
Ok(events)
436436
}
437+
438+
fn shutdown(&self, how: usize) -> fs::Result<()> {
439+
log::warn!("shutdown how={how}");
440+
Ok(())
441+
}
437442
}

src/aero_kernel/src/syscall/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,7 @@ pub fn generic_do_syscall(
289289
SYS_SOCK_RECV => net::sock_recv(b, c, d),
290290
SYS_SOCK_SEND => net::sock_send(b, c, d),
291291
SYS_SOCKET_PAIR => net::socket_pair(b, c, d, e),
292+
SYS_SOCK_SHUTDOWN => net::shutdown(b, c),
292293

293294
SYS_GETTIME => time::gettime(b, c),
294295
SYS_SLEEP => time::sleep(b),

src/aero_kernel/src/syscall/net.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,15 @@ fn socket_addr_from_addr<'sys>(address: VirtAddr) -> Result<SocketAddr<'sys>, Sy
2323
SocketAddr::from_family(address, family)
2424
}
2525

26+
#[syscall]
27+
pub fn shutdown(fd: usize, how: usize) -> Result<usize, SyscallError> {
28+
let file_table = &scheduler::get_scheduler().current_task().file_table;
29+
let socket = file_table.get_handle(fd).ok_or(SyscallError::EINVAL)?;
30+
31+
socket.inode().shutdown(how)?;
32+
Ok(0)
33+
}
34+
2635
/// Connects the socket to the specified address.
2736
#[syscall]
2837
pub fn connect(fd: usize, address: usize, length: usize) -> Result<usize, SyscallError> {

src/aero_syscall/src/consts.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ pub const SYS_TRACE: usize = 71;
9595
pub const SYS_SETPGID: usize = 72;
9696
pub const SYS_SETSID: usize = 73;
9797
pub const SYS_GETPGID: usize = 74;
98+
pub const SYS_SOCK_SHUTDOWN: usize = 75;
9899

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

0 commit comments

Comments
 (0)