Skip to content

Commit

Permalink
Added some Socket filtype return for fdstat syscall (wasmerio#4199)
Browse files Browse the repository at this point in the history
  • Loading branch information
ptitSeb authored Sep 4, 2023
1 parent 037b4bd commit b03102d
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions lib/wasix/src/fs/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand All @@ -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,
},
};

Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit b03102d

Please sign in to comment.