scheme-utils: Have FpathWriter handle writing the scheme name
This commit is contained in:
@@ -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(())
|
||||
|
||||
@@ -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(())
|
||||
})
|
||||
}
|
||||
|
||||
@@ -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),
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user