Skip to content

Commit

Permalink
feat(virtual-fs): Add FsError::StorageFull variant
Browse files Browse the repository at this point in the history
Needed for some applciations, like the FsMemoryLimiter.

Followup to #3865
  • Loading branch information
theduke committed Jun 5, 2023
1 parent 470e6e1 commit ad73684
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
8 changes: 8 additions & 0 deletions lib/virtual-fs/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -487,6 +489,8 @@ impl From<io::Error> 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,
Expand Down Expand Up @@ -522,6 +526,10 @@ impl From<FsError> 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()
}
Expand Down
1 change: 1 addition & 0 deletions lib/wasi/src/fs/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
}

0 comments on commit ad73684

Please sign in to comment.