scheme-utils: Have FpathWriter handle writing the scheme name

This commit is contained in:
bjorn3
2026-04-19 14:49:11 +02:00
parent 64d23e9e05
commit daf726c30d
24 changed files with 58 additions and 73 deletions
+3 -3
View File
@@ -250,14 +250,14 @@ impl<'a> SchemeSocket for IcmpSocket<'a> {
}
fn fpath(&self, file: &SchemeFile<Self>, buf: &mut [u8]) -> SyscallResult<usize> {
FpathWriter::with(buf, |w| {
FpathWriter::with(buf, "icmp", |w| {
if let SchemeFile::Socket(ref socket_file) = *file {
match socket_file.data.socket_type {
IcmpSocketType::Echo => {
write!(w, "/scheme/icmp/echo/{}", socket_file.data.ip).unwrap();
write!(w, "echo/{}", socket_file.data.ip).unwrap();
}
IcmpSocketType::Udp => {
write!(w, "/scheme/icmp/udp/{}", socket_file.data.ip).unwrap();
write!(w, "udp/{}", socket_file.data.ip).unwrap();
}
}
Ok(())
+2 -2
View File
@@ -138,8 +138,8 @@ impl<'a> SchemeSocket for RawSocket<'a> {
}
fn fpath(&self, _file: &SchemeFile<Self>, buf: &mut [u8]) -> SyscallResult<usize> {
FpathWriter::with(buf, |w| {
write!(w, "/scheme/ip/{}", self.ip_protocol()).unwrap();
FpathWriter::with(buf, "ip", |w| {
write!(w, "{}", self.ip_protocol()).unwrap();
Ok(())
})
}
+1 -2
View File
@@ -273,9 +273,8 @@ impl<'a> SchemeSocket for TcpSocket<'a> {
}
fn fpath(&self, file: &SchemeFile<Self>, buf: &mut [u8]) -> SyscallResult<usize> {
FpathWriter::with(buf, |w| {
FpathWriter::with(buf, "tcp", |w| {
let unspecified = "0.0.0.0:0";
write!(w, "/scheme/tcp/").unwrap();
match self.remote_endpoint() {
Some(endpoint) => write!(w, "{}", endpoint).unwrap(),
None => w.push_str(unspecified),
+1 -2
View File
@@ -269,9 +269,8 @@ impl<'a> SchemeSocket for UdpSocket<'a> {
}
fn fpath(&self, file: &SchemeFile<Self>, buf: &mut [u8]) -> SyscallResult<usize> {
FpathWriter::with(buf, |w| {
FpathWriter::with(buf, "udp", |w| {
let unspecified = "0.0.0.0:0";
w.push_str("/scheme/udp/");
// remote
match file {