It's wiggle time! (#1202)
* Use wiggle in place of wig in wasi-common This is a rather massive commit that introduces `wiggle` into the picture. We still use `wig`'s macro in `old` snapshot and to generate `wasmtime-wasi` glue, but everything else is now autogenerated by `wiggle`. In summary, thanks to `wiggle`, we no longer need to worry about serialising and deserialising to and from the guest memory, and all guest (WASI) types are now proper idiomatic Rust types. While we're here, in preparation for the ephemeral snapshot, I went ahead and reorganised the internal structure of the crate. Instead of modules like `hostcalls_impl` or `hostcalls_impl::fs`, the structure now resembles that in ephemeral with modules like `path`, `fd`, etc. Now, I'm not requiring we leave it like this, but I reckon it looks cleaner this way after all. * Fix wig to use new first-class access to caller's mem * Ignore warning in proc_exit for the moment * Group unsafes together in args and environ calls * Simplify pwrite; more unsafe blocks * Simplify fd_read * Bundle up unsafes in fd_readdir * Simplify fd_write * Add comment to path_readlink re zero-len buffers * Simplify unsafes in random_get * Hide GuestPtr<str> to &str in path::get * Rewrite pread and pwrite using SeekFrom and read/write_vectored I've left the implementation of VirtualFs pretty much untouched as I don't feel that comfortable in changing the API too much. Having said that, I reckon `pread` and `pwrite` could be refactored out, and `preadv` and `pwritev` could be entirely rewritten using `seek` and `read_vectored` and `write_vectored`. * Add comment about VirtFs unsafety * Fix all mentions of FdEntry to Entry * Fix warnings on Win * Add aux struct EntryTable responsible for Fds and Entries This commit adds aux struct `EntryTable` which is private to `WasiCtx` and is basically responsible for `Fd` alloc/dealloc as well as storing matching `Entry`s. This struct is entirely private to `WasiCtx` and as such as should remain transparent to `WasiCtx` users. * Remove redundant check for empty buffer in path_readlink * Preserve and rewind file cursor in pread/pwrite * Use GuestPtr<[u8]>::copy_from_slice wherever copying bytes directly * Use GuestPtr<[u8]>::copy_from_slice in fd_readdir * Clean up unsafes around WasiCtx accessors * Fix bugs in args_get and environ_get * Fix conflicts after rebase
This commit is contained in:
@@ -1,237 +1,217 @@
|
||||
//! Types and constants shared between 32-bit and 64-bit wasi. Types involving
|
||||
//! pointer or `usize`-sized data are excluded here, so this file only contains
|
||||
//! fixed-size types, so it's host/target independent.
|
||||
use crate::WasiCtx;
|
||||
|
||||
#![allow(non_camel_case_types)]
|
||||
#![allow(non_snake_case)]
|
||||
#![allow(dead_code)]
|
||||
wiggle::from_witx!({
|
||||
witx: ["wig/WASI/phases/snapshot/witx/wasi_snapshot_preview1.witx"],
|
||||
ctx: WasiCtx,
|
||||
});
|
||||
|
||||
use wig::witx_wasi_types;
|
||||
pub use types::Errno;
|
||||
pub type Result<T> = std::result::Result<T, Errno>;
|
||||
|
||||
witx_wasi_types!("snapshot" "wasi_snapshot_preview1");
|
||||
impl<'a> wiggle_runtime::GuestErrorType<'a> for Errno {
|
||||
type Context = WasiCtx;
|
||||
|
||||
pub type WasiResult<T> = Result<T, WasiError>;
|
||||
fn success() -> Self {
|
||||
Self::Success
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, thiserror::Error, Eq, PartialEq)]
|
||||
#[repr(u16)]
|
||||
#[error("{:?} ({})", self, strerror(*self as __wasi_errno_t))]
|
||||
pub enum WasiError {
|
||||
ESUCCESS = __WASI_ERRNO_SUCCESS,
|
||||
E2BIG = __WASI_ERRNO_2BIG,
|
||||
EACCES = __WASI_ERRNO_ACCES,
|
||||
EADDRINUSE = __WASI_ERRNO_ADDRINUSE,
|
||||
EADDRNOTAVAIL = __WASI_ERRNO_ADDRNOTAVAIL,
|
||||
EAFNOSUPPORT = __WASI_ERRNO_AFNOSUPPORT,
|
||||
EAGAIN = __WASI_ERRNO_AGAIN,
|
||||
EALREADY = __WASI_ERRNO_ALREADY,
|
||||
EBADF = __WASI_ERRNO_BADF,
|
||||
EBADMSG = __WASI_ERRNO_BADMSG,
|
||||
EBUSY = __WASI_ERRNO_BUSY,
|
||||
ECANCELED = __WASI_ERRNO_CANCELED,
|
||||
ECHILD = __WASI_ERRNO_CHILD,
|
||||
ECONNABORTED = __WASI_ERRNO_CONNABORTED,
|
||||
ECONNREFUSED = __WASI_ERRNO_CONNREFUSED,
|
||||
ECONNRESET = __WASI_ERRNO_CONNRESET,
|
||||
EDEADLK = __WASI_ERRNO_DEADLK,
|
||||
EDESTADDRREQ = __WASI_ERRNO_DESTADDRREQ,
|
||||
EDOM = __WASI_ERRNO_DOM,
|
||||
EDQUOT = __WASI_ERRNO_DQUOT,
|
||||
EEXIST = __WASI_ERRNO_EXIST,
|
||||
EFAULT = __WASI_ERRNO_FAULT,
|
||||
EFBIG = __WASI_ERRNO_FBIG,
|
||||
EHOSTUNREACH = __WASI_ERRNO_HOSTUNREACH,
|
||||
EIDRM = __WASI_ERRNO_IDRM,
|
||||
EILSEQ = __WASI_ERRNO_ILSEQ,
|
||||
EINPROGRESS = __WASI_ERRNO_INPROGRESS,
|
||||
EINTR = __WASI_ERRNO_INTR,
|
||||
EINVAL = __WASI_ERRNO_INVAL,
|
||||
EIO = __WASI_ERRNO_IO,
|
||||
EISCONN = __WASI_ERRNO_ISCONN,
|
||||
EISDIR = __WASI_ERRNO_ISDIR,
|
||||
ELOOP = __WASI_ERRNO_LOOP,
|
||||
EMFILE = __WASI_ERRNO_MFILE,
|
||||
EMLINK = __WASI_ERRNO_MLINK,
|
||||
EMSGSIZE = __WASI_ERRNO_MSGSIZE,
|
||||
EMULTIHOP = __WASI_ERRNO_MULTIHOP,
|
||||
ENAMETOOLONG = __WASI_ERRNO_NAMETOOLONG,
|
||||
ENETDOWN = __WASI_ERRNO_NETDOWN,
|
||||
ENETRESET = __WASI_ERRNO_NETRESET,
|
||||
ENETUNREACH = __WASI_ERRNO_NETUNREACH,
|
||||
ENFILE = __WASI_ERRNO_NFILE,
|
||||
ENOBUFS = __WASI_ERRNO_NOBUFS,
|
||||
ENODEV = __WASI_ERRNO_NODEV,
|
||||
ENOENT = __WASI_ERRNO_NOENT,
|
||||
ENOEXEC = __WASI_ERRNO_NOEXEC,
|
||||
ENOLCK = __WASI_ERRNO_NOLCK,
|
||||
ENOLINK = __WASI_ERRNO_NOLINK,
|
||||
ENOMEM = __WASI_ERRNO_NOMEM,
|
||||
ENOMSG = __WASI_ERRNO_NOMSG,
|
||||
ENOPROTOOPT = __WASI_ERRNO_NOPROTOOPT,
|
||||
ENOSPC = __WASI_ERRNO_NOSPC,
|
||||
ENOSYS = __WASI_ERRNO_NOSYS,
|
||||
ENOTCONN = __WASI_ERRNO_NOTCONN,
|
||||
ENOTDIR = __WASI_ERRNO_NOTDIR,
|
||||
ENOTEMPTY = __WASI_ERRNO_NOTEMPTY,
|
||||
ENOTRECOVERABLE = __WASI_ERRNO_NOTRECOVERABLE,
|
||||
ENOTSOCK = __WASI_ERRNO_NOTSOCK,
|
||||
ENOTSUP = __WASI_ERRNO_NOTSUP,
|
||||
ENOTTY = __WASI_ERRNO_NOTTY,
|
||||
ENXIO = __WASI_ERRNO_NXIO,
|
||||
EOVERFLOW = __WASI_ERRNO_OVERFLOW,
|
||||
EOWNERDEAD = __WASI_ERRNO_OWNERDEAD,
|
||||
EPERM = __WASI_ERRNO_PERM,
|
||||
EPIPE = __WASI_ERRNO_PIPE,
|
||||
EPROTO = __WASI_ERRNO_PROTO,
|
||||
EPROTONOSUPPORT = __WASI_ERRNO_PROTONOSUPPORT,
|
||||
EPROTOTYPE = __WASI_ERRNO_PROTOTYPE,
|
||||
ERANGE = __WASI_ERRNO_RANGE,
|
||||
EROFS = __WASI_ERRNO_ROFS,
|
||||
ESPIPE = __WASI_ERRNO_SPIPE,
|
||||
ESRCH = __WASI_ERRNO_SRCH,
|
||||
ESTALE = __WASI_ERRNO_STALE,
|
||||
ETIMEDOUT = __WASI_ERRNO_TIMEDOUT,
|
||||
ETXTBSY = __WASI_ERRNO_TXTBSY,
|
||||
EXDEV = __WASI_ERRNO_XDEV,
|
||||
ENOTCAPABLE = __WASI_ERRNO_NOTCAPABLE,
|
||||
}
|
||||
|
||||
impl WasiError {
|
||||
pub fn as_raw_errno(self) -> __wasi_errno_t {
|
||||
self as __wasi_errno_t
|
||||
fn from_error(e: wiggle_runtime::GuestError, _ctx: &Self::Context) -> Self {
|
||||
eprintln!("Guest error: {:?}", e);
|
||||
// TODO proper error mapping
|
||||
Self::Inval
|
||||
}
|
||||
}
|
||||
|
||||
impl From<std::convert::Infallible> for WasiError {
|
||||
impl From<wiggle_runtime::GuestError> for Errno {
|
||||
fn from(err: wiggle_runtime::GuestError) -> Self {
|
||||
use wiggle_runtime::GuestError::*;
|
||||
match err {
|
||||
InvalidFlagValue { .. } => Self::Inval,
|
||||
InvalidEnumValue { .. } => Self::Inval,
|
||||
PtrOverflow { .. } => Self::Fault,
|
||||
PtrOutOfBounds { .. } => Self::Fault,
|
||||
PtrNotAligned { .. } => Self::Inval,
|
||||
PtrBorrowed { .. } => Self::Fault,
|
||||
InvalidUtf8 { .. } => Self::Ilseq,
|
||||
TryFromIntError { .. } => Self::Overflow,
|
||||
InFunc { .. } => Self::Inval,
|
||||
InDataField { .. } => Self::Inval,
|
||||
SliceLengthsDiffer { .. } => Self::Fault,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<std::convert::Infallible> for Errno {
|
||||
fn from(_err: std::convert::Infallible) -> Self {
|
||||
unreachable!()
|
||||
}
|
||||
}
|
||||
|
||||
impl From<std::num::TryFromIntError> for WasiError {
|
||||
impl From<std::num::TryFromIntError> for Errno {
|
||||
fn from(_err: std::num::TryFromIntError) -> Self {
|
||||
Self::EOVERFLOW
|
||||
Self::Overflow
|
||||
}
|
||||
}
|
||||
|
||||
impl From<std::str::Utf8Error> for WasiError {
|
||||
impl From<std::str::Utf8Error> for Errno {
|
||||
fn from(_err: std::str::Utf8Error) -> Self {
|
||||
Self::EILSEQ
|
||||
Self::Ilseq
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) const RIGHTS_ALL: __wasi_rights_t = __WASI_RIGHTS_FD_DATASYNC
|
||||
| __WASI_RIGHTS_FD_READ
|
||||
| __WASI_RIGHTS_FD_SEEK
|
||||
| __WASI_RIGHTS_FD_FDSTAT_SET_FLAGS
|
||||
| __WASI_RIGHTS_FD_SYNC
|
||||
| __WASI_RIGHTS_FD_TELL
|
||||
| __WASI_RIGHTS_FD_WRITE
|
||||
| __WASI_RIGHTS_FD_ADVISE
|
||||
| __WASI_RIGHTS_FD_ALLOCATE
|
||||
| __WASI_RIGHTS_PATH_CREATE_DIRECTORY
|
||||
| __WASI_RIGHTS_PATH_CREATE_FILE
|
||||
| __WASI_RIGHTS_PATH_LINK_SOURCE
|
||||
| __WASI_RIGHTS_PATH_LINK_TARGET
|
||||
| __WASI_RIGHTS_PATH_OPEN
|
||||
| __WASI_RIGHTS_FD_READDIR
|
||||
| __WASI_RIGHTS_PATH_READLINK
|
||||
| __WASI_RIGHTS_PATH_RENAME_SOURCE
|
||||
| __WASI_RIGHTS_PATH_RENAME_TARGET
|
||||
| __WASI_RIGHTS_PATH_FILESTAT_GET
|
||||
| __WASI_RIGHTS_PATH_FILESTAT_SET_SIZE
|
||||
| __WASI_RIGHTS_PATH_FILESTAT_SET_TIMES
|
||||
| __WASI_RIGHTS_FD_FILESTAT_GET
|
||||
| __WASI_RIGHTS_FD_FILESTAT_SET_SIZE
|
||||
| __WASI_RIGHTS_FD_FILESTAT_SET_TIMES
|
||||
| __WASI_RIGHTS_PATH_SYMLINK
|
||||
| __WASI_RIGHTS_PATH_UNLINK_FILE
|
||||
| __WASI_RIGHTS_PATH_REMOVE_DIRECTORY
|
||||
| __WASI_RIGHTS_POLL_FD_READWRITE
|
||||
| __WASI_RIGHTS_SOCK_SHUTDOWN;
|
||||
|
||||
// Block and character device interaction is outside the scope of
|
||||
// WASI. Simply allow everything.
|
||||
pub(crate) const RIGHTS_BLOCK_DEVICE_BASE: __wasi_rights_t = RIGHTS_ALL;
|
||||
pub(crate) const RIGHTS_BLOCK_DEVICE_INHERITING: __wasi_rights_t = RIGHTS_ALL;
|
||||
pub(crate) const RIGHTS_CHARACTER_DEVICE_BASE: __wasi_rights_t = RIGHTS_ALL;
|
||||
pub(crate) const RIGHTS_CHARACTER_DEVICE_INHERITING: __wasi_rights_t = RIGHTS_ALL;
|
||||
|
||||
// Only allow directory operations on directories. Directories can only
|
||||
// yield file descriptors to other directories and files.
|
||||
pub(crate) const RIGHTS_DIRECTORY_BASE: __wasi_rights_t = __WASI_RIGHTS_FD_FDSTAT_SET_FLAGS
|
||||
| __WASI_RIGHTS_FD_SYNC
|
||||
| __WASI_RIGHTS_FD_ADVISE
|
||||
| __WASI_RIGHTS_PATH_CREATE_DIRECTORY
|
||||
| __WASI_RIGHTS_PATH_CREATE_FILE
|
||||
| __WASI_RIGHTS_PATH_LINK_SOURCE
|
||||
| __WASI_RIGHTS_PATH_LINK_TARGET
|
||||
| __WASI_RIGHTS_PATH_OPEN
|
||||
| __WASI_RIGHTS_FD_READDIR
|
||||
| __WASI_RIGHTS_PATH_READLINK
|
||||
| __WASI_RIGHTS_PATH_RENAME_SOURCE
|
||||
| __WASI_RIGHTS_PATH_RENAME_TARGET
|
||||
| __WASI_RIGHTS_PATH_FILESTAT_GET
|
||||
| __WASI_RIGHTS_PATH_FILESTAT_SET_SIZE
|
||||
| __WASI_RIGHTS_PATH_FILESTAT_SET_TIMES
|
||||
| __WASI_RIGHTS_FD_FILESTAT_GET
|
||||
| __WASI_RIGHTS_FD_FILESTAT_SET_TIMES
|
||||
| __WASI_RIGHTS_PATH_SYMLINK
|
||||
| __WASI_RIGHTS_PATH_UNLINK_FILE
|
||||
| __WASI_RIGHTS_PATH_REMOVE_DIRECTORY
|
||||
| __WASI_RIGHTS_POLL_FD_READWRITE;
|
||||
pub(crate) const RIGHTS_DIRECTORY_INHERITING: __wasi_rights_t =
|
||||
RIGHTS_DIRECTORY_BASE | RIGHTS_REGULAR_FILE_BASE;
|
||||
|
||||
// Operations that apply to regular files.
|
||||
pub(crate) const RIGHTS_REGULAR_FILE_BASE: __wasi_rights_t = __WASI_RIGHTS_FD_DATASYNC
|
||||
| __WASI_RIGHTS_FD_READ
|
||||
| __WASI_RIGHTS_FD_SEEK
|
||||
| __WASI_RIGHTS_FD_FDSTAT_SET_FLAGS
|
||||
| __WASI_RIGHTS_FD_SYNC
|
||||
| __WASI_RIGHTS_FD_TELL
|
||||
| __WASI_RIGHTS_FD_WRITE
|
||||
| __WASI_RIGHTS_FD_ADVISE
|
||||
| __WASI_RIGHTS_FD_ALLOCATE
|
||||
| __WASI_RIGHTS_FD_FILESTAT_GET
|
||||
| __WASI_RIGHTS_FD_FILESTAT_SET_SIZE
|
||||
| __WASI_RIGHTS_FD_FILESTAT_SET_TIMES
|
||||
| __WASI_RIGHTS_POLL_FD_READWRITE;
|
||||
pub(crate) const RIGHTS_REGULAR_FILE_INHERITING: __wasi_rights_t = 0;
|
||||
|
||||
// Operations that apply to sockets and socket pairs.
|
||||
pub(crate) const RIGHTS_SOCKET_BASE: __wasi_rights_t = __WASI_RIGHTS_FD_READ
|
||||
| __WASI_RIGHTS_FD_FDSTAT_SET_FLAGS
|
||||
| __WASI_RIGHTS_FD_WRITE
|
||||
| __WASI_RIGHTS_FD_FILESTAT_GET
|
||||
| __WASI_RIGHTS_POLL_FD_READWRITE
|
||||
| __WASI_RIGHTS_SOCK_SHUTDOWN;
|
||||
pub(crate) const RIGHTS_SOCKET_INHERITING: __wasi_rights_t = RIGHTS_ALL;
|
||||
|
||||
// Operations that apply to TTYs.
|
||||
pub(crate) const RIGHTS_TTY_BASE: __wasi_rights_t = __WASI_RIGHTS_FD_READ
|
||||
| __WASI_RIGHTS_FD_FDSTAT_SET_FLAGS
|
||||
| __WASI_RIGHTS_FD_WRITE
|
||||
| __WASI_RIGHTS_FD_FILESTAT_GET
|
||||
| __WASI_RIGHTS_POLL_FD_READWRITE;
|
||||
#[allow(unused)]
|
||||
pub(crate) const RIGHTS_TTY_INHERITING: __wasi_rights_t = 0;
|
||||
|
||||
pub fn whence_to_str(whence: __wasi_whence_t) -> &'static str {
|
||||
match whence {
|
||||
__WASI_WHENCE_CUR => "__WASI_WHENCE_CUR",
|
||||
__WASI_WHENCE_END => "__WASI_WHENCE_END",
|
||||
__WASI_WHENCE_SET => "__WASI_WHENCE_SET",
|
||||
other => panic!("Undefined whence value {:?}", other),
|
||||
impl From<std::fs::FileType> for types::Filetype {
|
||||
fn from(ftype: std::fs::FileType) -> Self {
|
||||
if ftype.is_file() {
|
||||
Self::RegularFile
|
||||
} else if ftype.is_dir() {
|
||||
Self::Directory
|
||||
} else if ftype.is_symlink() {
|
||||
Self::SymbolicLink
|
||||
} else {
|
||||
Self::Unknown
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub const __WASI_DIRCOOKIE_START: __wasi_dircookie_t = 0;
|
||||
pub(crate) trait AsBytes {
|
||||
fn as_bytes(&self) -> Result<Vec<u8>>;
|
||||
}
|
||||
|
||||
impl crate::fdpool::Fd for __wasi_fd_t {
|
||||
impl AsBytes for types::Dirent {
|
||||
fn as_bytes(&self) -> Result<Vec<u8>> {
|
||||
use std::convert::TryInto;
|
||||
use wiggle_runtime::GuestType;
|
||||
|
||||
assert_eq!(
|
||||
Self::guest_size(),
|
||||
std::mem::size_of::<Self>() as _,
|
||||
"guest repr of types::Dirent and host repr should match"
|
||||
);
|
||||
|
||||
let offset = Self::guest_size().try_into()?;
|
||||
let mut bytes: Vec<u8> = Vec::with_capacity(offset);
|
||||
bytes.resize(offset, 0);
|
||||
let ptr = bytes.as_mut_ptr() as *mut Self;
|
||||
unsafe { ptr.write_unaligned(*self) };
|
||||
Ok(bytes)
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) trait RightsExt: Sized {
|
||||
fn block_device_base() -> Self;
|
||||
fn block_device_inheriting() -> Self;
|
||||
fn character_device_base() -> Self;
|
||||
fn character_device_inheriting() -> Self;
|
||||
fn directory_base() -> Self;
|
||||
fn directory_inheriting() -> Self;
|
||||
fn regular_file_base() -> Self;
|
||||
fn regular_file_inheriting() -> Self;
|
||||
fn socket_base() -> Self;
|
||||
fn socket_inheriting() -> Self;
|
||||
fn tty_base() -> Self;
|
||||
fn tty_inheriting() -> Self;
|
||||
}
|
||||
|
||||
impl RightsExt for types::Rights {
|
||||
// Block and character device interaction is outside the scope of
|
||||
// WASI. Simply allow everything.
|
||||
fn block_device_base() -> Self {
|
||||
Self::all()
|
||||
}
|
||||
fn block_device_inheriting() -> Self {
|
||||
Self::all()
|
||||
}
|
||||
fn character_device_base() -> Self {
|
||||
Self::all()
|
||||
}
|
||||
fn character_device_inheriting() -> Self {
|
||||
Self::all()
|
||||
}
|
||||
|
||||
// Only allow directory operations on directories. Directories can only
|
||||
// yield file descriptors to other directories and files.
|
||||
fn directory_base() -> Self {
|
||||
Self::FD_FDSTAT_SET_FLAGS
|
||||
| Self::FD_SYNC
|
||||
| Self::FD_ADVISE
|
||||
| Self::PATH_CREATE_DIRECTORY
|
||||
| Self::PATH_CREATE_FILE
|
||||
| Self::PATH_LINK_SOURCE
|
||||
| Self::PATH_LINK_TARGET
|
||||
| Self::PATH_OPEN
|
||||
| Self::FD_READDIR
|
||||
| Self::PATH_READLINK
|
||||
| Self::PATH_RENAME_SOURCE
|
||||
| Self::PATH_RENAME_TARGET
|
||||
| Self::PATH_FILESTAT_GET
|
||||
| Self::PATH_FILESTAT_SET_SIZE
|
||||
| Self::PATH_FILESTAT_SET_TIMES
|
||||
| Self::FD_FILESTAT_GET
|
||||
| Self::FD_FILESTAT_SET_TIMES
|
||||
| Self::PATH_SYMLINK
|
||||
| Self::PATH_UNLINK_FILE
|
||||
| Self::PATH_REMOVE_DIRECTORY
|
||||
| Self::POLL_FD_READWRITE
|
||||
}
|
||||
fn directory_inheriting() -> Self {
|
||||
Self::all() ^ Self::SOCK_SHUTDOWN
|
||||
}
|
||||
|
||||
// Operations that apply to regular files.
|
||||
fn regular_file_base() -> Self {
|
||||
Self::FD_DATASYNC
|
||||
| Self::FD_READ
|
||||
| Self::FD_SEEK
|
||||
| Self::FD_FDSTAT_SET_FLAGS
|
||||
| Self::FD_SYNC
|
||||
| Self::FD_TELL
|
||||
| Self::FD_WRITE
|
||||
| Self::FD_ADVISE
|
||||
| Self::FD_ALLOCATE
|
||||
| Self::FD_FILESTAT_GET
|
||||
| Self::FD_FILESTAT_SET_SIZE
|
||||
| Self::FD_FILESTAT_SET_TIMES
|
||||
| Self::POLL_FD_READWRITE
|
||||
}
|
||||
fn regular_file_inheriting() -> Self {
|
||||
Self::empty()
|
||||
}
|
||||
|
||||
// Operations that apply to sockets and socket pairs.
|
||||
fn socket_base() -> Self {
|
||||
Self::FD_READ
|
||||
| Self::FD_FDSTAT_SET_FLAGS
|
||||
| Self::FD_WRITE
|
||||
| Self::FD_FILESTAT_GET
|
||||
| Self::POLL_FD_READWRITE
|
||||
| Self::SOCK_SHUTDOWN
|
||||
}
|
||||
fn socket_inheriting() -> Self {
|
||||
Self::all()
|
||||
}
|
||||
|
||||
// Operations that apply to TTYs.
|
||||
fn tty_base() -> Self {
|
||||
Self::FD_READ
|
||||
| Self::FD_FDSTAT_SET_FLAGS
|
||||
| Self::FD_WRITE
|
||||
| Self::FD_FILESTAT_GET
|
||||
| Self::POLL_FD_READWRITE
|
||||
}
|
||||
fn tty_inheriting() -> Self {
|
||||
Self::empty()
|
||||
}
|
||||
}
|
||||
pub(crate) const DIRCOOKIE_START: types::Dircookie = 0;
|
||||
|
||||
impl crate::fdpool::Fd for types::Fd {
|
||||
fn as_raw(&self) -> u32 {
|
||||
*self
|
||||
(*self).into()
|
||||
}
|
||||
fn from_raw(raw_fd: u32) -> Self {
|
||||
raw_fd
|
||||
Self::from(raw_fd)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user