(fd: BorrowedFd<'_>)
| 486 | |
| 487 | #[inline] |
| 488 | pub(crate) fn fstat(fd: BorrowedFd<'_>) -> io::Result<Stat> { |
| 489 | // 32-bit and mips64 Linux: `struct stat64` is not y2038 compatible; use |
| 490 | // `statx`. |
| 491 | // |
| 492 | // And, some old platforms don't support `statx`, and some fail with a |
| 493 | // confusing error code, so we call `crate::fs::statx` to handle that. If |
| 494 | // `statx` isn't available, fall back to the buggy system call. |
| 495 | #[cfg(any( |
| 496 | target_pointer_width = "32", |
| 497 | target_arch = "mips64", |
| 498 | target_arch = "mips64r6" |
| 499 | ))] |
| 500 | { |
| 501 | match crate::fs::statx(fd, cstr!(""), AtFlags::EMPTY_PATH, StatxFlags::BASIC_STATS) { |
| 502 | Ok(x) => statx_to_stat(x), |
| 503 | Err(io::Errno::NOSYS) => fstat_old(fd), |
| 504 | Err(err) => Err(err), |
| 505 | } |
| 506 | } |
| 507 | |
| 508 | #[cfg(all( |
| 509 | target_pointer_width = "64", |
| 510 | not(target_arch = "mips64"), |
| 511 | not(target_arch = "mips64r6") |
| 512 | ))] |
| 513 | unsafe { |
| 514 | let mut result = MaybeUninit::<Stat>::uninit(); |
| 515 | ret(syscall!(__NR_fstat, fd, &mut result))?; |
| 516 | |
| 517 | #[cfg(sanitize_memory)] |
| 518 | crate::msan::unpoison_maybe_uninit(&result); |
| 519 | |
| 520 | Ok(result.assume_init()) |
| 521 | } |
| 522 | } |
| 523 | |
| 524 | #[cfg(any( |
| 525 | target_pointer_width = "32", |
no test coverage detected