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

Function utimensat

src/backend/libc/fs/syscalls.rs:888–1045  ·  view source on GitHub ↗
(
    dirfd: BorrowedFd<'_>,
    path: &CStr,
    times: &Timestamps,
    flags: AtFlags,
)

Source from the content-addressed store, hash-verified

886 target_os = "vita"
887)))]
888pub(crate) fn utimensat(
889 dirfd: BorrowedFd<'_>,
890 path: &CStr,
891 times: &Timestamps,
892 flags: AtFlags,
893) -> io::Result<()> {
894 // Old 32-bit version: libc has `utimensat` but it is not y2038 safe by
895 // default. But there may be a `__utimensat64` we can use.
896 #[cfg(all(fix_y2038, not(apple)))]
897 {
898 #[cfg(target_env = "gnu")]
899 if let Some(libc_utimensat) = __utimensat64.get() {
900 let libc_times: [LibcTimespec; 2] =
901 [times.last_access.into(), times.last_modification.into()];
902
903 unsafe {
904 return ret(libc_utimensat(
905 borrowed_fd(dirfd),
906 c_str(path),
907 libc_times.as_ptr(),
908 bitflags_bits!(flags),
909 ));
910 }
911 }
912
913 utimensat_old(dirfd, path, times, flags)
914 }
915
916 // Main version: libc is y2038 safe and has `utimensat`. Or, the platform
917 // is not y2038 safe and there's nothing practical we can do.
918 #[cfg(not(any(apple, fix_y2038)))]
919 unsafe {
920 use crate::utils::as_ptr;
921
922 ret(c::utimensat(
923 borrowed_fd(dirfd),
924 c_str(path),
925 as_ptr(times).cast(),
926 bitflags_bits!(flags),
927 ))
928 }
929
930 // Apple version: `utimensat` was introduced in macOS 10.13.
931 #[cfg(apple)]
932 unsafe {
933 use crate::utils::as_ptr;
934
935 // ABI details
936 weak! {
937 fn utimensat(
938 c::c_int,
939 *const ffi::c_char,
940 *const c::timespec,
941 c::c_int
942 ) -> c::c_int
943 }
944 extern "C" {
945 fn setattrlist(

Callers 1

utimensat_oldFunction · 0.70

Calls 14

borrowed_fdFunction · 0.85
c_strFunction · 0.85
utimensat_oldFunction · 0.85
as_ptrFunction · 0.85
times_to_attrlistFunction · 0.85
WIFEXITEDFunction · 0.85
WEXITSTATUSFunction · 0.85
containsMethod · 0.80
retFunction · 0.50
fchdirFunction · 0.50
ret_c_intFunction · 0.50
waitpidFunction · 0.50

Tested by

no test coverage detected