fix: format check

This commit is contained in:
Samuka007 2024-10-17 06:45:35 +00:00
parent 251e1bca41
commit 6c812d2607
11 changed files with 18 additions and 45 deletions

View File

@ -148,4 +148,4 @@ pub(super) unsafe fn init_syscall_64() {
// 初始化LSTAR,该寄存器存储syscall指令入口 // 初始化LSTAR,该寄存器存储syscall指令入口
x86::msr::wrmsr(x86::msr::IA32_LSTAR, syscall_64 as usize as u64); x86::msr::wrmsr(x86::msr::IA32_LSTAR, syscall_64 as usize as u64);
x86::msr::wrmsr(x86::msr::IA32_FMASK, 0xfffffffe); x86::msr::wrmsr(x86::msr::IA32_FMASK, 0xfffffffe);
} }

View File

@ -354,4 +354,4 @@ pub const SYS_VSERVER: usize = 236;
pub const SYS_WAIT4: usize = 61; pub const SYS_WAIT4: usize = 61;
pub const SYS_WAITID: usize = 247; pub const SYS_WAITID: usize = 247;
pub const SYS_WRITE: usize = 1; pub const SYS_WRITE: usize = 1;
pub const SYS_WRITEV: usize = 20; pub const SYS_WRITEV: usize = 20;

View File

@ -58,12 +58,7 @@ pub trait Socket: Sync + Send + Debug + Any {
} }
/// # `get_option` /// # `get_option`
/// 对应于 Posix `getsockopt` 获取socket选项 /// 对应于 Posix `getsockopt` 获取socket选项
fn get_option( fn get_option(&self, level: PSOL, name: usize, value: &mut [u8]) -> Result<usize, SystemError> {
&self,
level: PSOL,
name: usize,
value: &mut [u8],
) -> Result<usize, SystemError> {
log::warn!("getsockopt is not implemented"); log::warn!("getsockopt is not implemented");
Ok(0) Ok(0)
} }
@ -106,12 +101,7 @@ pub trait Socket: Sync + Send + Debug + Any {
Err(ENOSYS) Err(ENOSYS)
} }
/// # `send_to` /// # `send_to`
fn send_to( fn send_to(&self, buffer: &[u8], flags: PMSG, address: Endpoint) -> Result<usize, SystemError> {
&self,
buffer: &[u8],
flags: PMSG,
address: Endpoint,
) -> Result<usize, SystemError> {
Err(ENOSYS) Err(ENOSYS)
} }
/// # `set_option` /// # `set_option`

View File

@ -215,12 +215,7 @@ impl Socket for UdpSocket {
return self.try_send(buffer, None); return self.try_send(buffer, None);
} }
fn send_to( fn send_to(&self, buffer: &[u8], flags: PMSG, address: Endpoint) -> Result<usize, SystemError> {
&self,
buffer: &[u8],
flags: PMSG,
address: Endpoint,
) -> Result<usize, SystemError> {
if flags.contains(PMSG::DONTWAIT) { if flags.contains(PMSG::DONTWAIT) {
log::warn!("Nonblock send is not implemented yet"); log::warn!("Nonblock send is not implemented yet");
} }

View File

@ -303,8 +303,10 @@ impl Socket for TcpSocket {
} }
fn close(&self) -> Result<(), SystemError> { fn close(&self) -> Result<(), SystemError> {
self.inner.read().as_ref().map( self.inner
|inner| match inner { .read()
.as_ref()
.map(|inner| match inner {
Inner::Connecting(_) => Err(EINPROGRESS), Inner::Connecting(_) => Err(EINPROGRESS),
Inner::Established(es) => { Inner::Established(es) => {
es.close(); es.close();
@ -312,8 +314,8 @@ impl Socket for TcpSocket {
Ok(()) Ok(())
} }
_ => Ok(()), _ => Ok(()),
} })
).unwrap_or(Ok(())) .unwrap_or(Ok(()))
} }
} }

View File

@ -99,12 +99,7 @@ impl Inode {
self.inner.bind(endpoint) self.inner.bind(endpoint)
} }
pub fn set_option( pub fn set_option(&self, level: PSOL, name: usize, value: &[u8]) -> Result<(), SystemError> {
&self,
level: PSOL,
name: usize,
value: &[u8],
) -> Result<(), SystemError> {
self.inner.set_option(level, name, value) self.inner.set_option(level, name, value)
} }

View File

@ -1,11 +1,11 @@
mod base; mod base;
mod buffer; mod buffer;
mod common; mod common;
mod posix;
mod endpoint; mod endpoint;
mod family; mod family;
pub mod inet; pub mod inet;
mod inode; mod inode;
mod posix;
pub mod unix; pub mod unix;
mod utils; mod utils;
@ -17,10 +17,10 @@ pub use common::{
// poll_unit::{EPollItems, WaitQueue}, // poll_unit::{EPollItems, WaitQueue},
EPollItems, EPollItems,
}; };
pub use posix::*;
pub use endpoint::*; pub use endpoint::*;
pub use family::{AddressFamily, Family}; pub use family::{AddressFamily, Family};
pub use inode::Inode; pub use inode::Inode;
pub use posix::*;
pub use utils::create_socket; pub use utils::create_socket;
pub use crate::net::event_poll::EPollEventType; pub use crate::net::event_poll::EPollEventType;

View File

@ -1,5 +1,5 @@
// posix socket and arguments definitions // posix socket and arguments definitions
// now all posix definitions are with P front like MSG -> PMSG, // now all posix definitions are with P front like MSG -> PMSG,
// for better understanding and avoiding conflicts with other definitions // for better understanding and avoiding conflicts with other definitions
mod msg_flag; mod msg_flag;
mod option; mod option;

View File

@ -349,11 +349,7 @@ impl Socket for SeqpacketSocket {
Err(SystemError::ENOSYS) Err(SystemError::ENOSYS)
} }
fn send( fn send(&self, buffer: &[u8], flags: crate::net::socket::PMSG) -> Result<usize, SystemError> {
&self,
buffer: &[u8],
flags: crate::net::socket::PMSG,
) -> Result<usize, SystemError> {
if flags.contains(PMSG::OOB) { if flags.contains(PMSG::OOB) {
return Err(SystemError::EOPNOTSUPP_OR_ENOTSUP); return Err(SystemError::EOPNOTSUPP_OR_ENOTSUP);
} }

View File

@ -241,12 +241,7 @@ impl Socket for StreamSocket {
} }
} }
fn set_option( fn set_option(&self, _level: PSOL, _optname: usize, _optval: &[u8]) -> Result<(), SystemError> {
&self,
_level: PSOL,
_optname: usize,
_optval: &[u8],
) -> Result<(), SystemError> {
log::warn!("setsockopt is not implemented"); log::warn!("setsockopt is not implemented");
Ok(()) Ok(())
} }

View File

@ -142,7 +142,7 @@ impl Syscall {
.get_socket(fd as i32) .get_socket(fd as i32)
.ok_or(EBADF)?; .ok_or(EBADF)?;
use socket::{PSOL, PSO}; use socket::{PSO, PSOL};
let level = PSOL::try_from(level as u32)?; let level = PSOL::try_from(level as u32)?;