From ad7368498e8495e93592c4acfe854bcc7660f92c Mon Sep 17 00:00:00 2001 From: Christoph Herzog Date: Mon, 5 Jun 2023 19:08:12 +0200 Subject: [PATCH] feat(virtual-fs): Add FsError::StorageFull variant Needed for some applciations, like the FsMemoryLimiter. Followup to #3865 --- lib/virtual-fs/src/lib.rs | 8 ++++++++ lib/wasi/src/fs/mod.rs | 1 + 2 files changed, 9 insertions(+) diff --git a/lib/virtual-fs/src/lib.rs b/lib/virtual-fs/src/lib.rs index f39a05b15de..f88dd97f574 100644 --- a/lib/virtual-fs/src/lib.rs +++ b/lib/virtual-fs/src/lib.rs @@ -462,6 +462,8 @@ pub enum FsError { /// Directory not Empty #[error("directory not empty")] DirectoryNotEmpty, + #[error("storage full")] + StorageFull, /// Some other unhandled error. If you see this, it's probably a bug. #[error("unknown error found")] UnknownError, @@ -487,6 +489,8 @@ impl From for FsError { io::ErrorKind::UnexpectedEof => FsError::UnexpectedEof, io::ErrorKind::WouldBlock => FsError::WouldBlock, io::ErrorKind::WriteZero => FsError::WriteZero, + // NOTE: Add this once the "io_error_more" Rust feature is stabilized + // io::ErrorKind::StorageFull => FsError::StorageFull, io::ErrorKind::Other => FsError::IOError, // if the following triggers, a new error type was added to this non-exhaustive enum _ => FsError::UnknownError, @@ -522,6 +526,10 @@ impl From for io::Error { FsError::NoDevice => io::ErrorKind::Other, FsError::DirectoryNotEmpty => io::ErrorKind::Other, FsError::UnknownError => io::ErrorKind::Other, + FsError::StorageFull => io::ErrorKind::Other, + // NOTE: Add this once the "io_error_more" Rust feature is stabilized + // io::ErrorKind::StorageFull => FsError::StorageFull, + // FsError::StorageFull => io::ErrorKind::StorageFull, }; kind.into() } diff --git a/lib/wasi/src/fs/mod.rs b/lib/wasi/src/fs/mod.rs index 851355b985d..0c561b6b763 100644 --- a/lib/wasi/src/fs/mod.rs +++ b/lib/wasi/src/fs/mod.rs @@ -1884,6 +1884,7 @@ pub fn fs_error_into_wasi_err(fs_error: FsError) -> Errno { FsError::WouldBlock => Errno::Again, FsError::WriteZero => Errno::Nospc, FsError::DirectoryNotEmpty => Errno::Notempty, + FsError::StorageFull => Errno::Overflow, FsError::Lock | FsError::UnknownError => Errno::Io, } }