Skip to content

Commit 0267cbf

Browse files
authored
Merge pull request rust-lang#4046 from CraftSpider/windows-error-mapping
Fill out windows io error mapping table
2 parents 12ac750 + 0a7e63a commit 0267cbf

File tree

1 file changed

+64
-3
lines changed

1 file changed

+64
-3
lines changed

src/tools/miri/src/shims/io_error.rs

Lines changed: 64 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,11 +82,72 @@ const UNIX_IO_ERROR_TABLE: &[(&str, std::io::ErrorKind)] = {
8282
// <https://github.com/rust-lang/rust/blob/master/library/std/src/sys/pal/windows/mod.rs>.
8383
const WINDOWS_IO_ERROR_TABLE: &[(&str, std::io::ErrorKind)] = {
8484
use std::io::ErrorKind::*;
85-
// FIXME: this is still incomplete.
85+
// It's common for multiple error codes to map to the same io::ErrorKind. We have all for the
86+
// forwards mapping; only the first one will be used for the backwards mapping.
87+
// Slightly arbitrarily, we prefer non-WSA and the most generic sounding variant for backwards
88+
// mapping.
8689
&[
87-
("ERROR_ACCESS_DENIED", PermissionDenied),
88-
("ERROR_FILE_NOT_FOUND", NotFound),
90+
("WSAEADDRINUSE", AddrInUse),
91+
("WSAEADDRNOTAVAIL", AddrNotAvailable),
92+
("ERROR_ALREADY_EXISTS", AlreadyExists),
93+
("ERROR_FILE_EXISTS", AlreadyExists),
94+
("ERROR_NO_DATA", BrokenPipe),
95+
("WSAECONNABORTED", ConnectionAborted),
96+
("WSAECONNREFUSED", ConnectionRefused),
97+
("WSAECONNRESET", ConnectionReset),
98+
("ERROR_NOT_SAME_DEVICE", CrossesDevices),
99+
("ERROR_POSSIBLE_DEADLOCK", Deadlock),
100+
("ERROR_DIR_NOT_EMPTY", DirectoryNotEmpty),
101+
("ERROR_CANT_RESOLVE_FILENAME", FilesystemLoop),
102+
("ERROR_DISK_QUOTA_EXCEEDED", FilesystemQuotaExceeded),
103+
("WSAEDQUOT", FilesystemQuotaExceeded),
104+
("ERROR_FILE_TOO_LARGE", FileTooLarge),
105+
("ERROR_HOST_UNREACHABLE", HostUnreachable),
106+
("WSAEHOSTUNREACH", HostUnreachable),
107+
("ERROR_INVALID_NAME", InvalidFilename),
108+
("ERROR_BAD_PATHNAME", InvalidFilename),
109+
("ERROR_FILENAME_EXCED_RANGE", InvalidFilename),
89110
("ERROR_INVALID_PARAMETER", InvalidInput),
111+
("WSAEINVAL", InvalidInput),
112+
("ERROR_DIRECTORY_NOT_SUPPORTED", IsADirectory),
113+
("WSAENETDOWN", NetworkDown),
114+
("ERROR_NETWORK_UNREACHABLE", NetworkUnreachable),
115+
("WSAENETUNREACH", NetworkUnreachable),
116+
("ERROR_DIRECTORY", NotADirectory),
117+
("WSAENOTCONN", NotConnected),
118+
("ERROR_FILE_NOT_FOUND", NotFound),
119+
("ERROR_PATH_NOT_FOUND", NotFound),
120+
("ERROR_INVALID_DRIVE", NotFound),
121+
("ERROR_BAD_NETPATH", NotFound),
122+
("ERROR_BAD_NET_NAME", NotFound),
123+
("ERROR_SEEK_ON_DEVICE", NotSeekable),
124+
("ERROR_NOT_ENOUGH_MEMORY", OutOfMemory),
125+
("ERROR_OUTOFMEMORY", OutOfMemory),
126+
("ERROR_ACCESS_DENIED", PermissionDenied),
127+
("WSAEACCES", PermissionDenied),
128+
("ERROR_WRITE_PROTECT", ReadOnlyFilesystem),
129+
("ERROR_BUSY", ResourceBusy),
130+
("ERROR_DISK_FULL", StorageFull),
131+
("ERROR_HANDLE_DISK_FULL", StorageFull),
132+
("WAIT_TIMEOUT", TimedOut),
133+
("WSAETIMEDOUT", TimedOut),
134+
("ERROR_DRIVER_CANCEL_TIMEOUT", TimedOut),
135+
("ERROR_OPERATION_ABORTED", TimedOut),
136+
("ERROR_SERVICE_REQUEST_TIMEOUT", TimedOut),
137+
("ERROR_COUNTER_TIMEOUT", TimedOut),
138+
("ERROR_TIMEOUT", TimedOut),
139+
("ERROR_RESOURCE_CALL_TIMED_OUT", TimedOut),
140+
("ERROR_CTX_MODEM_RESPONSE_TIMEOUT", TimedOut),
141+
("ERROR_CTX_CLIENT_QUERY_TIMEOUT", TimedOut),
142+
("FRS_ERR_SYSVOL_POPULATE_TIMEOUT", TimedOut),
143+
("ERROR_DS_TIMELIMIT_EXCEEDED", TimedOut),
144+
("DNS_ERROR_RECORD_TIMED_OUT", TimedOut),
145+
("ERROR_IPSEC_IKE_TIMED_OUT", TimedOut),
146+
("ERROR_RUNLEVEL_SWITCH_TIMEOUT", TimedOut),
147+
("ERROR_RUNLEVEL_SWITCH_AGENT_TIMEOUT", TimedOut),
148+
("ERROR_TOO_MANY_LINKS", TooManyLinks),
149+
("ERROR_CALL_NOT_IMPLEMENTED", Unsupported),
150+
("WSAEWOULDBLOCK", WouldBlock),
90151
]
91152
};
92153

0 commit comments

Comments
 (0)