From 2e0dcf8ea9e8f96d7006224c6b6fc6c2e8c1efc3 Mon Sep 17 00:00:00 2001 From: marc0246 <40955683+marc0246@users.noreply.github.com> Date: Fri, 17 May 2024 22:51:26 +0200 Subject: [PATCH] Add missing mappings for `ENOTSUP` and `EOPNOTSUPP` error codes --- library/std/src/sys/pal/unix/mod.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/library/std/src/sys/pal/unix/mod.rs b/library/std/src/sys/pal/unix/mod.rs index 21f233e22620c..c38dc16c902b9 100644 --- a/library/std/src/sys/pal/unix/mod.rs +++ b/library/std/src/sys/pal/unix/mod.rs @@ -262,7 +262,6 @@ pub fn decode_error_kind(errno: i32) -> ErrorKind { libc::ENOENT => NotFound, libc::ENOMEM => OutOfMemory, libc::ENOSPC => StorageFull, - libc::ENOSYS => Unsupported, libc::EMLINK => TooManyLinks, libc::ENAMETOOLONG => InvalidFilename, libc::ENETDOWN => NetworkDown, @@ -286,6 +285,10 @@ pub fn decode_error_kind(errno: i32) -> ErrorKind { // clause x if x == libc::EAGAIN || x == libc::EWOULDBLOCK => WouldBlock, + // `ENOTSUP` and `EOPNOTSUPP` can also have the same value, + // so we can't use a match clause. + x if x == libc::ENOTSUP || x == libc::EOPNOTSUPP || x == libc::ENOSYS => Unsupported, + _ => Uncategorized, } }