Skip to content

Commit 493a05e

Browse files
Linux: check for both ENOSUP and EISDIR when creating anonymous files
1 parent ae0f307 commit 493a05e

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/imp/unix/linux.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,10 @@ impl TemporaryFile {
8484
// generic Unix implementation would do.
8585
let (file, temporary_name) = match create_unnamed_temporary_file(&dir, opts) {
8686
Ok(file) => (file, None),
87-
Err(Errno::ENOTSUP) => {
87+
// Linux >= 3.11 may return ENOTSUP if the filesystem does not support unnamed
88+
// temporary files; Linux < 3.11 will return EISDIR because O_TMPFILE is not supported
89+
// at all.
90+
Err(Errno::ENOTSUP) | Err(Errno::EISDIR) => {
8891
let (file, temporary_name) = create_temporary_file(&dir, opts, &name)?;
8992
(file, Some(temporary_name))
9093
}

0 commit comments

Comments
 (0)