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指令入口
x86::msr::wrmsr(x86::msr::IA32_LSTAR, syscall_64 as usize as u64);
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_WAITID: usize = 247;
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`
/// 对应于 Posix `getsockopt` 获取socket选项
fn get_option(
&self,
level: PSOL,
name: usize,
value: &mut [u8],
) -> Result<usize, SystemError> {
fn get_option(&self, level: PSOL, name: usize, value: &mut [u8]) -> Result<usize, SystemError> {
log::warn!("getsockopt is not implemented");
Ok(0)
}
@ -106,12 +101,7 @@ pub trait Socket: Sync + Send + Debug + Any {
Err(ENOSYS)
}
/// # `send_to`
fn send_to(
&self,
buffer: &[u8],
flags: PMSG,
address: Endpoint,
) -> Result<usize, SystemError> {
fn send_to(&self, buffer: &[u8], flags: PMSG, address: Endpoint) -> Result<usize, SystemError> {
Err(ENOSYS)
}
/// # `set_option`

View File

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

View File

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

View File

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

View File

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

View File

@ -1,5 +1,5 @@
// 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
mod msg_flag;
mod option;

View File

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

View File

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

View File

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