Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions library/core/src/io/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,11 @@ pub enum ErrorKind {
#[unstable(feature = "io_error_inprogress", issue = "130840")]
InProgress,

/// The process or the whole system has reached its limit on the number of
/// open files or sockets.
#[unstable(feature = "io_error_too_many_open_files", issue = "158319")]
TooManyOpenFiles,

// "Unusual" error kinds which do not correspond simply to (sets
// of) OS error codes, should be added just above this comment.
// `Other` and `Uncategorized` should remain at the end:
Expand Down Expand Up @@ -309,6 +314,7 @@ impl ErrorKind {
StorageFull => "no storage space",
TimedOut => "timed out",
TooManyLinks => "too many links",
TooManyOpenFiles => "too many open files",
Uncategorized => "uncategorized error",
UnexpectedEof => "unexpected end of file",
Unsupported => "unsupported",
Expand Down Expand Up @@ -379,6 +385,7 @@ impl ErrorKind {
Unsupported,
OutOfMemory,
InProgress,
TooManyOpenFiles,
Uncategorized,
})
}
Expand Down
1 change: 1 addition & 0 deletions library/std/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,7 @@
#![feature(int_from_ascii)]
#![feature(io_error_inprogress)]
#![feature(io_error_more)]
#![feature(io_error_too_many_open_files)]
#![feature(io_error_uncategorized)]
#![feature(io_slice_as_bytes)]
#![feature(ip)]
Expand Down
2 changes: 1 addition & 1 deletion library/std/src/sys/fs/vexos.rs
Original file line number Diff line number Diff line change
Expand Up @@ -612,7 +612,7 @@ fn map_fresult(fresult: vex_sdk::FRESULT) -> io::Result<()> {
Err(io::const_error!(io::ErrorKind::OutOfMemory, "not enough memory for the operation"))
}
vex_sdk::FRESULT::FR_TOO_MANY_OPEN_FILES => Err(io::const_error!(
io::ErrorKind::Uncategorized,
io::ErrorKind::TooManyOpenFiles,
"maximum number of open files has been reached",
)),
vex_sdk::FRESULT::FR_INVALID_PARAMETER => {
Expand Down
1 change: 1 addition & 0 deletions library/std/src/sys/io/error/unix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ pub fn decode_error_kind(errno: i32) -> io::ErrorKind {
libc::ETXTBSY => ExecutableFileBusy,
libc::EXDEV => CrossesDevices,
libc::EINPROGRESS => InProgress,
libc::EMFILE | libc::ENFILE => TooManyOpenFiles,
libc::EOPNOTSUPP => Unsupported,

libc::EACCES | libc::EPERM => PermissionDenied,
Expand Down
1 change: 1 addition & 0 deletions library/std/src/sys/io/error/wasi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ pub fn decode_error_kind(errno: i32) -> std_io::ErrorKind {
libc::ETXTBSY => ExecutableFileBusy,
libc::EXDEV => CrossesDevices,
libc::EINPROGRESS => InProgress,
libc::EMFILE | libc::ENFILE => TooManyOpenFiles,
libc::EOPNOTSUPP => Unsupported,
libc::EACCES | libc::EPERM => PermissionDenied,
libc::EWOULDBLOCK => WouldBlock,
Expand Down
2 changes: 2 additions & 0 deletions library/std/src/sys/io/error/windows.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ pub fn decode_error_kind(errno: i32) -> io::ErrorKind {
c::ERROR_POSSIBLE_DEADLOCK => return Deadlock,
c::ERROR_NOT_SAME_DEVICE => return CrossesDevices,
c::ERROR_TOO_MANY_LINKS => return TooManyLinks,
c::ERROR_TOO_MANY_OPEN_FILES => return TooManyOpenFiles,
c::ERROR_FILENAME_EXCED_RANGE => return InvalidFilename,
c::ERROR_CANT_RESOLVE_FILENAME => return FilesystemLoop,
_ => {}
Expand All @@ -81,6 +82,7 @@ pub fn decode_error_kind(errno: i32) -> io::ErrorKind {
c::WSAENETDOWN => NetworkDown,
c::WSAENETUNREACH => NetworkUnreachable,
c::WSAEDQUOT => QuotaExceeded,
c::WSAEMFILE => TooManyOpenFiles,
// Not a perfect mapping but this error is only returned when writing to
// a socket after shutting down the write-end. On Unix targets, EPIPE is
// returned in those cases.
Expand Down
Loading