From 2325b81d0412dda2a9d50c25848456d15c952f38 Mon Sep 17 00:00:00 2001 From: Tobias Bucher Date: Sun, 14 Apr 2024 17:04:41 +0200 Subject: [PATCH] `statx` probe: `ENOSYS` might come from a faulty FUSE driver Do the availability check regardless of the error returned from `statx`. CC https://github.com/rust-lang/rust/pull/122079#discussion_r1564761281 --- library/std/src/sys/pal/unix/fs.rs | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/library/std/src/sys/pal/unix/fs.rs b/library/std/src/sys/pal/unix/fs.rs index 422a99380cc59..9b12474d67a72 100644 --- a/library/std/src/sys/pal/unix/fs.rs +++ b/library/std/src/sys/pal/unix/fs.rs @@ -193,20 +193,17 @@ cfg_has_statx! {{ return Some(Err(err)); } - // Availability not checked yet. + // `ENOSYS` might come from a faulty FUSE driver. // - // First try the cheap way. - if err.raw_os_error() == Some(libc::ENOSYS) { - STATX_SAVED_STATE.store(STATX_STATE::Unavailable as u8, Ordering::Relaxed); - return None; - } - - // Error other than `ENOSYS` is not a good enough indicator -- it is + // Other errors are not a good enough indicator either -- it is // known that `EPERM` can be returned as a result of using seccomp to // block the syscall. + // // Availability is checked by performing a call which expects `EFAULT` // if the syscall is usable. + // // See: https://github.com/rust-lang/rust/issues/65662 + // // FIXME this can probably just do the call if `EPERM` was received, but // previous iteration of the code checked it for all errors and for now // this is retained.