Adjust as_socket signature

This commit is contained in:
Ruihan Li
2024-12-26 22:04:14 +08:00
committed by Tate, Hongliang Tian
parent a7741a8a75
commit 16db96e496
20 changed files with 110 additions and 92 deletions

View File

@ -1,16 +1,19 @@
// SPDX-License-Identifier: MPL-2.0
use super::SyscallReturn;
use crate::{
fs::file_table::FileDesc, net::socket::SockShutdownCmd, prelude::*,
util::net::get_socket_from_fd,
};
use crate::{fs::file_table::FileDesc, net::socket::SockShutdownCmd, prelude::*};
pub fn sys_shutdown(sockfd: FileDesc, how: i32, _ctx: &Context) -> Result<SyscallReturn> {
pub fn sys_shutdown(sockfd: FileDesc, how: i32, ctx: &Context) -> Result<SyscallReturn> {
let shutdown_cmd = SockShutdownCmd::try_from(how)?;
debug!("sockfd = {sockfd}, cmd = {shutdown_cmd:?}");
let socket = get_socket_from_fd(sockfd)?;
let file = {
let file_table = ctx.posix_thread.file_table().lock();
file_table.get_file(sockfd)?.clone()
};
let socket = file.as_socket_or_err()?;
socket.shutdown(shutdown_cmd)?;
Ok(SyscallReturn::Return(0))
}