From 87ecf7faf75301179f8300aad97e135aae55c0d2 Mon Sep 17 00:00:00 2001 From: ShE3py <52315535+she3py@users.noreply.github.com> Date: Thu, 10 Aug 2023 22:15:47 +0200 Subject: [PATCH] Use `io_error_more` on WASI --- library/std/src/sys/wasi/mod.rs | 84 ++++++++++++++++++++++++++++----- 1 file changed, 71 insertions(+), 13 deletions(-) diff --git a/library/std/src/sys/wasi/mod.rs b/library/std/src/sys/wasi/mod.rs index 98517da1d0feb..64d981bab6b06 100644 --- a/library/std/src/sys/wasi/mod.rs +++ b/library/std/src/sys/wasi/mod.rs @@ -83,24 +83,82 @@ pub fn decode_error_kind(errno: i32) -> std_io::ErrorKind { } match errno { + e if e == wasi::ERRNO_2BIG.raw().into() => ArgumentListTooLong, + e if e == wasi::ERRNO_ACCES.raw().into() => PermissionDenied, + e if e == wasi::ERRNO_ADDRINUSE.raw().into() => AddrInUse, + e if e == wasi::ERRNO_ADDRNOTAVAIL.raw().into() => AddrNotAvailable, + // wasi::ERRNO_AFNOSUPPORT.raw().into() => "address family not supported", + e if e == wasi::ERRNO_AGAIN.raw().into() => WouldBlock, + // wasi::ERRNO_ALREADY.raw().into() => "connection already in progress", + // wasi::ERRNO_BADF.raw().into() => "bad file descriptor", + // wasi::ERRNO_BADMSG.raw().into() => "bad message", + e if e == wasi::ERRNO_BUSY.raw().into() => ResourceBusy, + // wasi::ERRNO_CANCELED.raw().into() => "operation canceled", + // wasi::ERRNO_CHILD.raw().into() => "no child processes", + e if e == wasi::ERRNO_CONNABORTED.raw().into() => ConnectionAborted, e if e == wasi::ERRNO_CONNREFUSED.raw().into() => ConnectionRefused, e if e == wasi::ERRNO_CONNRESET.raw().into() => ConnectionReset, - e if e == wasi::ERRNO_PERM.raw().into() || e == wasi::ERRNO_ACCES.raw().into() => { - PermissionDenied - } - e if e == wasi::ERRNO_PIPE.raw().into() => BrokenPipe, - e if e == wasi::ERRNO_NOTCONN.raw().into() => NotConnected, - e if e == wasi::ERRNO_CONNABORTED.raw().into() => ConnectionAborted, - e if e == wasi::ERRNO_ADDRNOTAVAIL.raw().into() => AddrNotAvailable, - e if e == wasi::ERRNO_ADDRINUSE.raw().into() => AddrInUse, - e if e == wasi::ERRNO_NOENT.raw().into() => NotFound, + e if e == wasi::ERRNO_DEADLK.raw().into() => Deadlock, + // wasi::ERRNO_DESTADDRREQ.raw().into() => "destination address required", + // wasi::ERRNO_DOM.raw().into() => "mathematics argument out of domain of function", + // wasi::ERRNO_DQUOT.raw().into() => "reserved", + e if e == wasi::ERRNO_EXIST.raw().into() => AlreadyExists, + // wasi::ERRNO_FAULT.raw().into() => "bad address", + e if e == wasi::ERRNO_FBIG.raw().into() => FileTooLarge, + e if e == wasi::ERRNO_HOSTUNREACH.raw().into() => HostUnreachable, + // wasi::ERRNO_IDRM.raw().into() => "identifier removed", + // wasi::ERRNO_ILSEQ.raw().into() => "illegal byte sequence", + // wasi::ERRNO_INPROGRESS.raw().into() => "operation in progress", e if e == wasi::ERRNO_INTR.raw().into() => Interrupted, e if e == wasi::ERRNO_INVAL.raw().into() => InvalidInput, - e if e == wasi::ERRNO_TIMEDOUT.raw().into() => TimedOut, - e if e == wasi::ERRNO_EXIST.raw().into() => AlreadyExists, - e if e == wasi::ERRNO_AGAIN.raw().into() => WouldBlock, - e if e == wasi::ERRNO_NOSYS.raw().into() => Unsupported, + e if e == wasi::ERRNO_IO.raw().into() => Uncategorized, + // wasi::ERRNO_ISCONN.raw().into() => "socket is connected", + e if e == wasi::ERRNO_ISDIR.raw().into() => IsADirectory, + e if e == wasi::ERRNO_LOOP.raw().into() => FilesystemLoop, + // wasi::ERRNO_MFILE.raw().into() => "file descriptor value too large", + e if e == wasi::ERRNO_MLINK.raw().into() => TooManyLinks, + // wasi::ERRNO_MSGSIZE.raw().into() => "message too large", + // wasi::ERRNO_MULTIHOP.raw().into() => "reserved", + e if e == wasi::ERRNO_NAMETOOLONG.raw().into() => InvalidFilename, + e if e == wasi::ERRNO_NETDOWN.raw().into() => NetworkDown, + // wasi::ERRNO_NETRESET.raw().into() => "connection aborted by network", + e if e == wasi::ERRNO_NETUNREACH.raw().into() => NetworkUnreachable, + // wasi::ERRNO_NFILE.raw().into() => "too many files open in system", + // wasi::ERRNO_NOBUFS.raw().into() => "no buffer space available", + e if e == wasi::ERRNO_NODEV.raw().into() => NotFound, + e if e == wasi::ERRNO_NOENT.raw().into() => NotFound, + e if e == wasi::ERRNO_NOEXEC.raw().into() => InvalidData, + // wasi::ERRNO_NOLCK.raw().into() => "no locks available", + // wasi::ERRNO_NOLINK.raw().into() => "reserved", e if e == wasi::ERRNO_NOMEM.raw().into() => OutOfMemory, + // wasi::ERRNO_NOMSG.raw().into() => "no message of the desired type", + // wasi::ERRNO_NOPROTOOPT.raw().into() => "protocol not available", + e if e == wasi::ERRNO_NOSPC.raw().into() => StorageFull, + e if e == wasi::ERRNO_NOSYS.raw().into() => Unsupported, + e if e == wasi::ERRNO_NOTCONN.raw().into() => NotConnected, + e if e == wasi::ERRNO_NOTDIR.raw().into() => NotADirectory, + e if e == wasi::ERRNO_NOTEMPTY.raw().into() => DirectoryNotEmpty, + // wasi::ERRNO_NOTRECOVERABLE.raw().into() => "state not recoverable", + e if e == wasi::ERRNO_NOTSOCK.raw().into() => InvalidInput, + e if e == wasi::ERRNO_NOTSUP.raw().into() => Unsupported, + // wasi::ERRNO_NOTTY.raw().into() => "inappropriate I/O control operation", + e if e == wasi::ERRNO_NXIO.raw().into() => NotFound, + // wasi::ERRNO_OVERFLOW.raw().into() => "value too large to be stored in data type", + // wasi::ERRNO_OWNERDEAD.raw().into() => "previous owner died", + e if e == wasi::ERRNO_PERM.raw().into() => PermissionDenied, + e if e == wasi::ERRNO_PIPE.raw().into() => BrokenPipe, + // wasi::ERRNO_PROTO.raw().into() => "protocol error", + e if e == wasi::ERRNO_PROTONOSUPPORT.raw().into() => Unsupported, + e if e == wasi::ERRNO_PROTOTYPE.raw().into() => InvalidInput, + // wasi::ERRNO_RANGE.raw().into() => "result too large", + e if e == wasi::ERRNO_ROFS.raw().into() => ReadOnlyFilesystem, + // wasi::ERRNO_SPIPE.raw().into() => "invalid seek", + e if e == wasi::ERRNO_SRCH.raw().into() => NotFound, + // wasi::ERRNO_STALE.raw().into() => "reserved", + e if e == wasi::ERRNO_TIMEDOUT.raw().into() => TimedOut, + e if e == wasi::ERRNO_TXTBSY.raw().into() => ResourceBusy, + e if e == wasi::ERRNO_XDEV.raw().into() => CrossesDevices, + e if e == wasi::ERRNO_NOTCAPABLE.raw().into() => PermissionDenied, _ => Uncategorized, } }