Skip to content

Commit 5ccee0e

Browse files
authored
Rollup merge of rust-lang#90955 - JohnTitor:os-error-123-as-invalid-input, r=m-ou-se
Rename `FilenameTooLong` to `InvalidFilename` and also use it for Windows' `ERROR_INVALID_NAME` Address rust-lang#90940 (comment) `ERROR_INVALID_NAME` (i.e. "The filename, directory name, or volume label syntax is incorrect") happens if we pass an invalid filename, directory name, or label syntax, so mapping as `InvalidInput` is reasonable to me.
2 parents 6499c5e + a898b31 commit 5ccee0e

File tree

4 files changed

+8
-8
lines changed

4 files changed

+8
-8
lines changed

library/std/src/io/error.rs

+4-5
Original file line numberDiff line numberDiff line change
@@ -296,12 +296,11 @@ pub enum ErrorKind {
296296
/// The filesystem does not support making so many hardlinks to the same file.
297297
#[unstable(feature = "io_error_more", issue = "86442")]
298298
TooManyLinks,
299-
/// Filename too long.
299+
/// A filename was invalid.
300300
///
301-
/// The limit might be from the underlying filesystem or API, or an administratively imposed
302-
/// resource limit.
301+
/// This error can also cause if it exceeded the filename length limit.
303302
#[unstable(feature = "io_error_more", issue = "86442")]
304-
FilenameTooLong,
303+
InvalidFilename,
305304
/// Program argument list too long.
306305
///
307306
/// When trying to run an external program, a system or process limit on the size of the
@@ -382,12 +381,12 @@ impl ErrorKind {
382381
DirectoryNotEmpty => "directory not empty",
383382
ExecutableFileBusy => "executable file busy",
384383
FileTooLarge => "file too large",
385-
FilenameTooLong => "filename too long",
386384
FilesystemLoop => "filesystem loop or indirection limit (e.g. symlink loop)",
387385
FilesystemQuotaExceeded => "filesystem quota exceeded",
388386
HostUnreachable => "host unreachable",
389387
Interrupted => "operation interrupted",
390388
InvalidData => "invalid data",
389+
InvalidFilename => "invalid filename",
391390
InvalidInput => "invalid input parameter",
392391
IsADirectory => "is a directory",
393392
NetworkDown => "network down",

library/std/src/io/error/repr_bitpacked.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ fn kind_from_prim(ek: u32) -> Option<ErrorKind> {
315315
Deadlock,
316316
CrossesDevices,
317317
TooManyLinks,
318-
FilenameTooLong,
318+
InvalidFilename,
319319
ArgumentListTooLong,
320320
Interrupted,
321321
Other,

library/std/src/sys/unix/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ pub fn decode_error_kind(errno: i32) -> ErrorKind {
159159
libc::ENOSPC => StorageFull,
160160
libc::ENOSYS => Unsupported,
161161
libc::EMLINK => TooManyLinks,
162-
libc::ENAMETOOLONG => FilenameTooLong,
162+
libc::ENAMETOOLONG => InvalidFilename,
163163
libc::ENETDOWN => NetworkDown,
164164
libc::ENETUNREACH => NetworkUnreachable,
165165
libc::ENOTCONN => NotConnected,

library/std/src/sys/windows/mod.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ pub fn decode_error_kind(errno: i32) -> ErrorKind {
7171
c::ERROR_FILE_NOT_FOUND => return NotFound,
7272
c::ERROR_PATH_NOT_FOUND => return NotFound,
7373
c::ERROR_NO_DATA => return BrokenPipe,
74+
c::ERROR_INVALID_NAME => return InvalidFilename,
7475
c::ERROR_INVALID_PARAMETER => return InvalidInput,
7576
c::ERROR_NOT_ENOUGH_MEMORY | c::ERROR_OUTOFMEMORY => return OutOfMemory,
7677
c::ERROR_SEM_TIMEOUT
@@ -104,7 +105,7 @@ pub fn decode_error_kind(errno: i32) -> ErrorKind {
104105
c::ERROR_POSSIBLE_DEADLOCK => return Deadlock,
105106
c::ERROR_NOT_SAME_DEVICE => return CrossesDevices,
106107
c::ERROR_TOO_MANY_LINKS => return TooManyLinks,
107-
c::ERROR_FILENAME_EXCED_RANGE => return FilenameTooLong,
108+
c::ERROR_FILENAME_EXCED_RANGE => return InvalidFilename,
108109
_ => {}
109110
}
110111

0 commit comments

Comments
 (0)