diff --git a/lib/wasix/src/fs/mod.rs b/lib/wasix/src/fs/mod.rs index f57f753c95f..51e49cc5e7e 100644 --- a/lib/wasix/src/fs/mod.rs +++ b/lib/wasix/src/fs/mod.rs @@ -15,7 +15,10 @@ use std::{ task::{Context, Poll}, }; -use crate::state::{Stderr, Stdin, Stdout}; +use crate::{ + net::socket::InodeSocketKind, + state::{Stderr, Stdin, Stdout}, +}; use futures::{future::BoxFuture, Future, TryStreamExt}; #[cfg(feature = "enable-serde")] use serde_derive::{Deserialize, Serialize}; @@ -26,7 +29,7 @@ use wasmer_wasix_types::{ types::{__WASI_STDERR_FILENO, __WASI_STDIN_FILENO, __WASI_STDOUT_FILENO}, wasi::{ Errno, Fd as WasiFd, Fdflags, Fdstat, Filesize, Filestat, Filetype, Preopentype, Prestat, - PrestatEnum, Rights, + PrestatEnum, Rights, Socktype, }, }; @@ -1490,6 +1493,18 @@ impl WasiFs { Kind::File { .. } => Filetype::RegularFile, Kind::Dir { .. } => Filetype::Directory, Kind::Symlink { .. } => Filetype::SymbolicLink, + Kind::Socket { socket } => match socket.inner.protected.read().unwrap().kind { + InodeSocketKind::TcpStream { .. } => Filetype::SocketStream, + InodeSocketKind::Raw { .. } => Filetype::SocketRaw, + InodeSocketKind::PreSocket { ty, .. } => match ty { + Socktype::Stream => Filetype::SocketStream, + Socktype::Dgram => Filetype::SocketDgram, + Socktype::Raw => Filetype::SocketRaw, + Socktype::Seqpacket => Filetype::SocketSeqpacket, + _ => Filetype::Unknown, + }, + _ => Filetype::Unknown, + }, _ => Filetype::Unknown, }, fs_flags: fd.flags,