mirror of
https://github.com/asterinas/asterinas.git
synced 2025-06-22 08:53:29 +00:00
Adjust as_socket
signature
This commit is contained in:
committed by
Tate, Hongliang Tian
parent
a7741a8a75
commit
16db96e496
@ -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))
|
||||
}
|
||||
|
Reference in New Issue
Block a user