MCPcopy Create free account
hub / github.com/bytecodealliance/rustix / stat

Function stat

src/backend/linux_raw/fs/syscalls.rs:546–582  ·  view source on GitHub ↗
(path: &CStr)

Source from the content-addressed store, hash-verified

544
545#[inline]
546pub(crate) fn stat(path: &CStr) -> io::Result<Stat> {
547 // See the comments in `fstat` about using `crate::fs::statx` here.
548 #[cfg(any(
549 target_pointer_width = "32",
550 target_arch = "mips64",
551 target_arch = "mips64r6"
552 ))]
553 {
554 match crate::fs::statx(
555 crate::fs::CWD,
556 path,
557 AtFlags::empty(),
558 StatxFlags::BASIC_STATS,
559 ) {
560 Ok(x) => statx_to_stat(x),
561 Err(io::Errno::NOSYS) => stat_old(path),
562 Err(err) => Err(err),
563 }
564 }
565
566 #[cfg(all(
567 target_pointer_width = "64",
568 not(target_arch = "mips64"),
569 not(target_arch = "mips64r6"),
570 ))]
571 unsafe {
572 let mut result = MaybeUninit::<Stat>::uninit();
573 ret(syscall!(
574 __NR_newfstatat,
575 raw_fd(AT_FDCWD),
576 path,
577 &mut result,
578 c_uint(0)
579 ))?;
580 Ok(result.assume_init())
581 }
582}
583
584#[cfg(any(
585 target_pointer_width = "32",

Callers 1

ttynameFunction · 0.50

Calls 5

stat_oldFunction · 0.85
assume_initMethod · 0.80
statxFunction · 0.70
statx_to_statFunction · 0.70
retFunction · 0.50

Tested by

no test coverage detected