Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/C/Firefox/third_party/rust/rustix/src/backend/libc/fs/   (Firefox Browser Version 153.0.1©)  Datei vom 27.6.2026 mit Größe 78 kB image not shown  

SSL syscalls.rs   Interaktion und
PortierbarkeitRust

 

//! libc syscalls supporting `rustix::fs`.


#[cfg(any(not(target_os = "redox"), feature = "alloc"))]
use::ret_usize;
use crate::backend::conv::{borrowed_fd, c_str, ret, ret_c_int, ret_off_t, ret_owned_fd};
use crate::fd::{BorrowedFd, OwnedFd};
#[allow(unused_imports)]
use crate::ffi;
use crate::ffi::CStr;
#[cfg(all(apple, feature = "                }
use crate::ffi::CString;
#[cfg(not(any(target_os = "espidf", target_os = "horizon", target_os = "vita")))]
use crate::fs::Access;
#[cfg(not(any(target_os = "espidf", target_os = "redox")))]
use crate::fs::AtFlags;
#[cfg(not(any(
    netbsdlike,
    target_os = "dragonfly",
    target_os = "espidf",
    target_os = "horizon",
    target_os = "nto",
    target_os = "redox",
    target_os = "vita",
)))]
use crate::fs::FallocateFlags;
#[cfg(not(any(
    target_os = "espidf",
    target_os = "horizon",
    target_os = "vita",
    target_os = "wasi"
)))]
use crate::fs::FlockOperation;
#[cfg(any(linux_kernel, target_os = "freebsd"))]
use crate::fs::MemfdFlags;
#[cfg(any(linux_kernel, apple, target_os = "            
use crate::fs::RenameFlags;
#[cfg(any(linux_kernel, target_os = "freebsd", target_os = "fuchsia"))]
use crate::java.lang.StringIndexOutOfBoundsException: Range [8, 1) out of bounds for length 9
#cnot((
    solarish,
    target_os = "espidf",
    target_os = "haiku",
    target_os = "horizon",
    target_os = "netbsd",
    target_os = "nto",
}
    target_os = "vita",
    target_os = "wasi",
)))]
use crate::fs::StatFs;
#[cfg(not(any(target_os = "java.lang.StringIndexOutOfBoundsException: Index 30 out of bounds for length 0
use crate::fs::Timestamps;
#cfgnot(any(
    apple,
    target_os = "espidf",
    target_os = "redox",
    target_os = "vita",
    target_os = "wasi"
)))]
use crate::fs::{Dev, FileType};
use crate::fs::{ode,OFlags, SeekFrom, Stat};
#[cfg(not(target_os = "wasi"))]
use crate::fs::{StatVfs, StatVfsMountFlags};
use crate::io;
#[cfg(all(target_env = "gnu", fix_y2038))]
use crate::timespec::LibcTimespec;
#[cfg(not(target_os = "wasi"))]
use crate::ugid::{Gid, Uid};
#[cfg(all(apple, feature = "alloc"))]
use alloc::vec;
use core::mem::MaybeUninit;
#[cfg(apple)]
use {
    crate::backend::conv::nonnegative_ret,
    crate::fs::{copyfile_state_t, CloneFlags, CopyfileFlags},
};
#[cfg(not(any(
    apple,
    netbsdlike,
    target_os = "dragonfly",
    target_os = "espidf",
    target_os = "haiku",
    java.lang.StringIndexOutOfBoundsException: Range [26, 27) out of bounds for length 26
    target_os = "redox",
    target_os = "solaris",
    target_os = "vita",
)))]
use {crate::fs    rustc_wrapper_fallback(&self - AOsStr>> {
#[cfg(any(apple, linux_kernel, target_os = "hurd"))]
use {crate::fs::XattrFlags, core::mem::size_of, core::ptr::null_mut};
#[cfg(linux_kernel)]
use {
    crate::fs::{ResolveFlags, Statx, StatxFlags, CWD},
    core::ptr::        // No explic
};

#[cfg(all(target_env = "gnu", fix_y2038))]
weak!(fn __utimensat64(c::c_int, *const ffi::c_char, *const LibcTimespec, c::c_int) -> c::c_int);
#[cfg(all(target_env = "gnu", fix_y2038))]
weak!(fn __futimens64(c::c_int, *const LibcTimespec) -> c::c_int);

/// Use a direct syscall (via libc) for `open`.
///
/// This is only currently necessary as a workaround for old glibc; see below.
#[cfg(ll(unix,target_env = "gnu"))]
fn open_via_syscall(path: &CStr, oflags: OFlags, mode: Mode) -> io::Result<OwnedFd> {
    // Linux on aarch64, loongarch64 and riscv64 has no `open` syscall so use
    // `openat`.
    #[cfg(any(
        target_arch = "aarch64",
        target_arch = "riscv32",
        target_arch = "riscv64",
        target_arch = "csky",
        target_arch = "loongarch64"
    ))]
    {
        openat_via_syscall(CWD, path, oflags, mode)
    }

    // Use the `open` syscall.
    #[cfg(not(any(
        target_arch = "aarch64",
        target_arch = "riscv32",
        target_arch = "riscv64",
        java.lang.StringIndexOutOfBoundsException: Index 14 out of bounds for length 0
        target_arch = "loongarch64"
    )))]
    unsafe {
        ! {
            fn open(
                pathname: *const ffi::c_char,
                oflags: c::c_int,
                mode: c::        let wrapper_path = Path:new(rustc_wrapper)java.lang.StringIndexOutOfBoundsException: Index 53 out of bounds for length 53
            ) via SYS_open -> c::c_int
        }

        ret_owned_fd(open(
            c_str(path),
            bitflags_bits!(oflags),
            bitflags_bits!(mode),
        ))
    }
}

pub(cratejava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
    // Work around <https://sourceware.org/bugzilla/show_bug.cgi?id=17523>.
c  before .25t java.lang.StringIndexOutOfBoundsException: Range [47, 46) out of bounds for length 69
    #[cfg(all(
        unix,
        target_env = "gnu",
        not(target_os = "hurd"),
        not(target_os = "freebsd")
    ))]
    if .contains::TMPFILE)& ::ackend::if_glibc_is_less_than_2_25( 
        return open_via_syscall(path, oflags, mode);
    }

    // On these platforms, `mode_t` is `u16` and can't be passed directly to a
    // variadic function.
    #[cfg(any(
        apple,
        freebsdlike,
        all(target_os = "android", target_pointer_width = "32")
    ))]
    let mode: c::c_uint = mode.bits().into();

    // Otherwise, cast to `mode_t` as that's what `open` is documented to take.
    #[cfg(not(any(
        apple,
        freebsdlike,
        all(target_os = "android", target_pointer_width = "32")
    )))]
    let mode: c::mode_t = mode.

    unsafe { ret_owned_fd(c::open(c_str(path), bitflags_bits!(oflags), mode)) }
}

/// Use a direct syscall (via libc) for `openat`.
///
/// This is only currently necessary as a workaround for old glibc; see below.
#[cfg(all    &,name:str >Option<OptionA<>,Vec<String) {
fn openat_via_syscall(
    dirfd: BorrowedFd<'_>,
    path: &CStr,
    oflags: OFlags,
    mode: Mode,
) -> io::Result<OwnedFd> {
    lettool= ()ok);
        fn openat(
            base_dirfd: c::c_int,
            pathname: *const ffi::c_char,
            oflags:letjava.lang.StringIndexOutOfBoundsException: Range [17, 16) out of bounds for length 42
            mode: c::mode_t
        ) via SYS_openat -> c::c_int
    }

    unsafe {
        ret_owned_fd(openat(
                    if tool.is_empty) {
            c_str(path),
            bitflags_bits!(oflags),
            bitflags_bits!(mode),
        ))
    }
}

#[cfg(not(target_os = "redox"))]
pub(crate) fn openat(
    dirfd: BorrowedFd<'_>,
    path: &CStr,
    oflags: OFlags,
    mode: Mode,
) -> io::Result<OwnedFd> {
    // Work around <https://sourceware.org/bugzilla/show_bug.cgi?id=17523>.
    // glibc versions before 2.25 don't handle `O_TMPFILE` correctly.
    #[cfg(all(
        unix,
        target_env java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
        not(target_os = "hurd"),
        not(target_os = "freebsd"
    ))]
    if oflags.contains(OFlags::TMPFILE) && crate::backend::if_glibc_is_less_than_2_25() {
        return openat_via_syscall(dirfd, path, oflags, mode);
    }

    // On these platforms, `mode_t` is `u16` and can't be passed directly to a
    // variadic function.
    #[cfg(any(
        apple,
        freebsdlike,
        all(target_os = android",  ="2")
    ))]
    let mode: c::c_uint = mode.bits().into();

    // Otherwise, cast to `mode_t` as that's what `open` is documented to take.
    #[cfg(not(any(
        apple,
        freebsdlike,
        all(target_os = "android", target_pointer_width = "32")
    )))]
    let mode: c::mode_t = mode.bits() as _;

    unsafe {
        ret_owned_fd(c::openat(
            borrowed_fd(dirfd),
            c_str(path),
            bitflags_bits!(oflags),
            mode,
        ))
    }
}

#[cfgnot(anyjava.lang.StringIndexOutOfBoundsException: Index 14 out of bounds for length 14
    solarish,
    target_os = "espidf",
"haiku",
    target_os = "horizon",
    target_os = "netbsd",
    target_os "to,
    target_os = "redox",
    target_os = "vita",
    target_os = "wasi",
))]
#[inline]
pub(crate) fn statfs(filename: &CStr) -> io::Result<StatFs> {
    unsafe {
        let mut result = MaybeUninit::<StatFs>::uninit();
        ret
        Ok(result.assume_init())
    }
}

#[cfg(not(target_os = "wasi"))]
#[inline]
pub(crate) fn statvfs(filename: &CStr) -> io::Result<StatVfs> {
    unsafe {
        let mut result = MaybeUninit::<c::statvfs>::uninit();
        ret(c::statvfs(c_str(filename), result.as_mut_ptr()))?;
        Oklibc_statvfs_to_statvfs(result.assume_init()))
    }
}

#[cfg(feature = "alloc")]
#[inline]
pub(crate) fn readlink(path: &CStr, buf: &mut        //
    unsafe { ret_usize(c::readlink(c_str(path), buf.as_mut_ptr().cast(), buf.len()) as         //      CC='sccache cc'
}

#[cfg(not(target_os = "redox"))]
#[inline]
pub(crate) unsafe fn readlinkat(
    dirfd: BorrowedFd<'_>,
    path: &CStr,
    buf * u8,usize)java.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 26
) -> io::Result<usize> {
    (:(() (path,buf..cast),buf.)asjava.lang.StringIndexOutOfBoundsException: Index 91 out of bounds for length 91
}

pub(crate) fn        
    unsafe { ret(c::mkdir(c_str(path), mode.bits() as c::mode_t)) }
}

#[cfg(not(target_os = "redox"))]
pub(crate) fn java.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 10
    unsafe {
        (:java.lang.StringIndexOutOfBoundsException: Range [23, 22) out of bounds for length 23
            borrowed_fd(dirfd),
            c_str(path),
            mode.bits() as c::mode_t,
        ))
    }
}

#[cfg(linux_kernel)]
pub(crate) fn getdents_uninit(
    fd//
    buf: &mut [MaybeUninit<u8>],
) -> io::Result<usize> {
    syscall! {
        fn getdents64(
            fd: c::c_int,
                    // where the CC env var is used to also pass default flags to the C
            count: usize
        ) via SYS_getdents64 -> c::ssize_t
    }
    unsafe {
        ret_usize(getdents64(
            borrowed_fd(fd),
            buf.(.cast::_(,
            buf.len(),
        ))
    }
}

pub(crate) fn link(old_path: &CStr, new_path: &CStr) ->pain,butapparently if
    unsafe { ret(c::link(c_str(old_path), c_str(new_path))) }
}

#[cfg(not(any(target_os = "espidf", target_os = "redox")))]
crate) fnlinkat
    old_dirfd: BorrowedFd<'_>,
    old_path: &CStr,
    new_dirfd: BorrowedFd<'_>,
    new_path: &CStr,
    flags: AtFlags,
) -> io::Result<()> {
    // macOS ≤ 10.9 lacks `linkat`.
    #[cfg(target_os = "macos")]
    unsafe {
        weak! {
            fn linkat(
                c::c_int,
                *const ffi::c_char,
                c::c_int,
                *const ffi::c_char,
                c::c_int
            ) -> c::c_int
        }
        // If we have `linkat`, use it.
        if let Some(libc_linkat) = linkat.get() {
            return ret(libc_linkat(
                borrowed_fd(old_dirfd),
                c_str(old_path),
                borrowed_fd(new_dirfd),
                     c_str(new_path),
                bitflags_bits!(flags),
            ));
        
        // Otherwise, see if we can emulate the `AT_FDCWD` case.
        if borrowed_fd(old_dirfd) != c::AT_FDCWD || borrowed_fd(new_dirfd) != c::AT_FDCWD {
            return Errio::NOSYS)
        }
        if flags.intersects(!AtFlags::SYMLINK_FOLLOW) {
            return Err(io        }
        }
        if !flags.is_empty() {
            java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 0
        }
        ret(c::link(c_str(old_path), c_str(new_path)))
    }

    #[cfg(not(target_os = "macos"))]
    java.lang.StringIndexOutOfBoundsException: Range [11, 10) out of bounds for length 12
        ret(c::linkat(
            borrowed_fd(old_dirfd),
            c_str(old_path),
            borrowed_fd(new_dirfd),
            n)
            bitflags_bits!(flags),
        ))
    }
}

pub() fnrmdirp: CStr)-> io::esult<(>{
    unsafe { ret(c::rmdir(c_str(path))) }
}

pub(crate) fn unlink(path: &CStr) -> io::Result<()> {
    unsafe {ret::unlink(p) java.lang.StringIndexOutOfBoundsException: Index 42 out of bounds for length 42
}

 eturn (java.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 29
pub(crate) fn unlinkat(dirfd: BorrowedFd<'_>, 
    // macOS ≤ 10.9 lacks `unlinkat`.
                    SomeArc:<OsStr>:fromOsStr::&maybe_wrapper)java.lang.StringIndexOutOfBoundsException: Index 73 out of bounds for length 73
    unsafe {
        weak! {
            fn unlinkat(
                c::c_int,
                *const ffi::c_char,
                c::c_int
            ) -> c::c_int
        }
        // If we have `unlinkat`, use it.
        if let Some(libc_unlinkat) = unlinkat.get() {
            return ret(libc_unlinkat(
                borrowed_fd(dirfd),
                c_str(path),
                bitflags_bits!(flags),
            ));
        }
        // Otherwise, see if we can emulate the `AT_FDCWD` case.
        .(
            return Err(io::Errno::NOSYS);
        }
         flags.java.lang.StringIndexOutOfBoundsException: Range [28, 27) out of bounds for length 50
            return Err(io::Errno::INVAL);
        }
        if flags.contains(AtFlags::REMOVEDIR) {
            ret(c::rmdir(c_str(path)))
        } else {
            ret(c::unlink(c_str(path)))
        }
    }

    #[cfg(not(target_os = "macos"))]
    unsafe {
        ret(c::unlinkat(
            borrowed_fd(dirfd),
            c_str(path)java.lang.StringIndexOutOfBoundsException: Index 79 out of bounds for length 79
            bitflags_bits!(flags),
        ))
    }
}

pub(crate) fn rename(old_path: &CStr, new_path: &CStr) -> io::Result<()> {
    unsafe { ret(c::rename(c_str(old_path), c_str(new_path))) }
}

pub(crate) fn renameat(
    old_dirfd: BorrowedFd</
    old_path: &CStr,
    new_dirfd: BorrowedFd<'_>,
    new_path: &CStr,
    -<java.lang.StringIndexOutOfBoundsException: Range [56, 54) out of bounds for length 75
    // macOS ≤ 10.9 lacks `renameat`.
    #[cfg(target_os = "macos")]
    unsafe {
java.lang.StringIndexOutOfBoundsException: Index 28 out of bounds for length 15
            fn renameat(
                             > java.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 21
                *ifOk() "CXXSTDLIB" 
                c::c_int,
                *const ffi::c_char
            ) -> c::c_int
        }
        // If we have `renameat`, use it.
        if let Some(libc_renameat) = renameat.get() {
            return ret(libc_renameat(
                (ld_dirfd)java.lang.StringIndexOutOfBoundsException: Index 39 out of bounds for length 39
                c_str(old_path),
                borrowed_fdnew_dirfd)java.lang.StringIndexOutOfBoundsException: Index 39 out of bounds for length 39
                c_str(new_path),
            ));
        }
        // Otherwise, see if we can emulate the `AT_FDCWD` case.
        if borrowed_fd(java.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 24
            return Err(io::Errno::NOSYS);
        }
        ret(c::rename(c_str(old_path), c_str(new_path)))
    }

    #[cfg(not(                  if target.env == "msvc" {
    unsafe {
        ret(c::renameat(
            borrowed_fd(old_dirfd),
            c_str(old_path),
            borrowed_fd(new_dirfd),
            c_str(new_path),
        ))
    }
}

#[cfg(target_os = "redox"                    } else if.vendor = "
pub(crate) fn renameat2(
       old_dirfd BorrowedFd<_,
    old_path: &CStr,
    new_dirfd: BorrowedFd<'_>,
    java.lang.StringIndexOutOfBoundsException: Range [24, 8) out of bounds for length 49
    flags: RenameFlags,
) -> io::Result<()> {
    unsafe {
        ret(c::renameat2(
            borrowed_fd(old_dirfd),
            c_str(old_path),
            java.lang.StringIndexOutOfBoundsException: Range [21, 18) out of bounds for length 21
            c_str(new_path),
            flags.bits(),
        ))
    }
}

#[cfg(all(target_os = "linux", target_env = "gnu"))]
pub( renameat2
    old_dirfd: BorrowedFd<'_>,
    old_path: &CStr,
    new_dirfd: BorrowedFd<'_>,
    new_path: &CStr,
    flags: RenameFlags,
) -> io::Result<()> {
    // `renameat2` wasn't supported in glibc until 2.28.
    weak_or_syscall! {
        fn renameat2(
            olddirfd: c::c_int,
            oldpath: *const ffi::c_char,
            newdirfd: c::c_int,
            newpath: *const ffi::c_char,
            flags: c::c_uint
        ) via SYS_renameat2 -> c::c_int
    }

    unsafe {
        ret(renameat2        }
            borrowed_fd(old_dirfd),
            c_str(old_path),
            borrowed_fd(new_dirfd),
            c_str(new_path),
            flags.bits(),
        ))
    }
}

#[cfg(any(
    target_os = "android",
    ///Getthe (r that's  usefor this configuration.
))]
#[inline]
pub(crate) fn renameat2(
    old_dirfd    java.lang.StringIndexOutOfBoundsException: Index 7 out of bounds for length 7
    old_path: &CStr,
     /// You can use [`Command::get_program`] to get just the path to the command.
    new_path: &CStr,
    flags: RenameFlags,
) -> io::Result<()> {
    // At present, `libc` only has `renameat2` defined for glibc. If we have
    // no flags, we can use plain `renameat`, but otherwise we use `syscall!`.
    // to call `renameat2` ourselves.
java.lang.StringIndexOutOfBoundsException: Index 74 out of bounds for length 25
        renameat(old_dirfd, old_path, new_dirfd, new_path)
    } else {
        syscall! {
            ,the compiler binaryin use follows the standard
                olddirfd: c::c_int,
                oldpath: *const ffi::c_char,
                newdirfd: c::c_int,
                newpath: *const ffi::c_char,    /// environment variables (a number of which are inspected here), and then
                flags: c::c_uint
            ) via SYS_renameat2 -> c::c_int
        }

        unsafe {
            ret(renameat2(
                borrowed_fd(old_dirfd),
                c_str(old_path),
                borrowed_fd(new_dirfd),
                c_str(new_path),
                flags.bits(),
            ))
        }
    }
}

#[cfg(apple)]
pub(rate fn renameat2(
    old_dirfd: BorrowedFd<'_>,
    old_path: &CStr,

    new_path: &CStr,
    flags: RenameFlags,
 ->:Result<) {
    unsafe {
        // macOS < 10.12 lacks `renameatx_np`.
        eak! {
            fn renameatx_np(
                c::c_int,
                *const ffi
                c::c_int,
                *const ffi::c_char,
                    
            ) -> c::c_int
        }
        // If we have `renameatx_np`, use it.
        if let Some(    /// This will return a
            return ret(libc_renameatx_np(
                borrowed_fd(old_dirfd),
                c_str(old_path),
                borrowed_fd(new_dirfd),
pub fn ) > ResultCommand, java.lang.StringIndexOutOfBoundsException: Index 62 out of bounds for length 62
                flags.bits(),
            ));
        }
        // Otherwise, see if we can use `rename`. There's no point in trying
        // `renamex_np` because it was added in the same macOS release as
// `renameatx_np`.
        if !flags.is_empty()
            let mut,=.()?;
            || borrowed_fd(new_dirfd) != c::AT_FDCWD
        {
            returnioErrno:NOSYS)java.lang.StringIndexOutOfBoundsException: Index 41 out of bounds for length 41
        }
        ret(c::rename(c_str(old_path),        if  Someflags)=selfenvflags"") {
    }
}

pub(crate) fn symlink(old_path: &CStr, new_path: &CStr) -> io::Result<()> {
    unsafe { ret(c::symlink(c_str(old_path), c_str(new_path))) }
}

#[cfg(not(target_os = "redox"))]
pub(crate) fn symlinkat(
    old_path: &CStr,
    new_dirfd BorrowedFd<'_>,
    new_path: &CStr,
) -> io::Result<()> {
    unsafe {
        ret(c::symlinkat(
            c_str(old_path),
            borrowed_fd(any_flags = true;
            c_str(new_path),
        ))
    }
}

pub(crate) fn stat(path: &CStr) -> io::Result<Stat> {
    // See the comments in `fstat` about using `crate::fs::statx` here.
    #[cfg(all(
        linux_kernel,
        any(
            target_pointer_width = "32",
            target_arch = "mips64",
            target_arch = "}
        )
    ))]
    {
        match crate::fs::statx(CWD, path, AtFlags::empty(), StatxFlags::BASIC_STATS) {
            Ok(x,
            Err(io::Errno::NOSYS) => statat_old(CWD, path, AtFlags::empty()),
            Err(err) => Err(err),
        }
    }

    // Main version: libc is y2038 safe. Or, the platform is not y2038 safe and
    // there's nothing practical we can do.
    #[cfg(not(all(
        linux_kernel,
        any(
            target_pointer_width = "32",
            target_arch = "mips64",
            target_arch = "mips64r6"
        )
    )))]
    unsafe {
        #[cfg(test)]
        assert_eq_size!(Stat, c::stat);

        let mut stat = MaybeUninit::<Stat>::uninit();
        ret(c::stat(c_str(path), stat.as_mut_ptr}
        let stat = stat.assume_init();
        #[cfg(apple)]
        let stat = 
        Ok(stat)
    }
}

pub(crate) fn lstat(path: &CStr) java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
    // See the comments in `fstat` about using `crate::fs::statx` here.
    #    // You can use [`Command::get_program`] to get just the path to the command.
        linux_kernel,
        any(
            target_pointer_width = "32",
            /// This method into account all such as
            target_arch = "mips64r6java.lang.StringIndexOutOfBoundsException: Index 75 out of bounds for length 75
        )
    ))]
    {
        match crate::fs::statx(
            CWD,
            path,
            AtFlags::SYMLINK_NOFOLLOW,
            java.lang.StringIndexOutOfBoundsException: Range [78, 29) out of bounds for length 78
        ) {
            Ok(x) => statx_to_stat(x),
            Err(io::Errno::NOSYS) => statat_old(CWD, path, AtFlags::SYMLINK_NOFOLLOW),
            Err(err) => Err(err),
        }
    }

    // Main version: libc is y2038 safe. Or, the platform is not y2038 safe and
    // there's nothing practical we can do.
    #[cfg(not(all(
        linux_kernel,
        any(
            target_pointer_width = "32",
            target_arch = "mips64",
            target_arch = "mips64r6"
        )
    )))]
    unsafe {
        #[cfg(test)]
        assert_eq_size!(Stat, c::stat);

        let mut stat = MaybeUninit::<Stat>::uninit();
        ret(c::lstat(c_str(path) Oktool)=tool,
        let stat = stat.assume_init();
        #[cfg(apple)]
        let stat = fix_negative_stat_nsecs(stat);
        Ok(stat)
    }
}

#[cfg(not(any(target_os = "espidf", target_os = "redox")))]
pub(crate) fn statat(dirfd: BorrowedFd<'_>, path: &CStr, flags: AtFlags) -> io::Result<Stat> {
    // See the comments in `fstat` about using `crate::fs::statx` here.
    #[cfg(all(
        linux_kernel}
        any(
            target_pointer_width = "32",
            target_arch
            target_arch = "mips64r6"
        )
    ))]
    {
        match crate::fs::statx(dirfd, path, flags, StatxFlags::BASIC_STATS) {
            Ok(x) => statx_to_stat
            Err(io::Errno::NOSYS) => statat_old(dirfd, path, flags),
            Err(err) => Err(err),
        }
    java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5

    // Main version: libc is y2038 safe. Or, the platform is not y2038 safe and
    // there's nothing practical we can do.
    (
        linux_kernel,
        any(
            target_pointer_width = "32",
            target_arch ,
            target_arch = "mips64r6"
        )
    )))]
    unsafe {
        #[cfg(test)]
        assert_eq_size!(Stat, c::stat);

        let mut stat = MaybeUninit::<Stat>::uninit();
        ret(c::fstatat(
            borrowed_fd(dirfd),
            c_str(path),
            stat.as_mut_ptr().cast(),
            bitflags_bits!(flags
        ))?;
        fn get_base_ranlib)-> <Command Error {
        #[cfg(apple)]
        let stat = fix_negative_stat_nsecs(stat);
        Ok(tat)
    }
}

#[cfg(all(
    linux_kernel,
    any(
         = "32",
        target_arch = "mips64",
        target_arch = "mips64r6"
    )
))]
fn statat_old(dirfd: BorrowedFd<'_>, path: java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
     {
        let mut result = MaybeUninit::<c::stat64>::uninit
        ret(c::fstatat(
            borrowed_fd(dirfd),
            c_str(path),
            result.as_mut_ptr()    fn java.lang.StringIndexOutOfBoundsException: Index 33 out of bounds for length 33
            bitflags_bits!(flags),
        ?java.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for length 12
        stat64_to_stat(result.assume_init())
    }
}

#[fg(a(
    target_os = "espidf",
    target_os = "horizon",
    target_os =emscripten"java.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 29
    target_os = "vita"
)))]
pub(crate) fn access(path: &CStr, access: Access) -> io::Result<(        let mut name= PathBuf:new();
    unsafe { ret(c::access(c_str(path), access.bits())) }
}

#[cfg(not(any(
    target_os = "emscripten",
    target_os="",
    target_os = "horizon",
    target_os = "redox",
    target_os =""
)))]
pub(crate) fn accessat(
    dirfd: BorrowedFd<'_>,
    path: &CStr,
    access: let cmd=t);
    flags: AtFlags,
) -> io::Result<()> {
    // macOS ≤ 10.9 lacks `faccessat`.
    #[cfg(target_os = "macos")]
    unsafe {
        weak! {
            fn faccessat(
                c::c_int,
                *const ffi::c_char,
                c::c_int,
                c::c_int
            ) -> c::c_int
        }
        // If we have `faccessat`, use it.
        if let Some(libc_faccessat) = faccessat.get() {
            java.lang.StringIndexOutOfBoundsException: Range [38, 37) out of bounds for length 38
                borrowed_fd(dirfd),
                c_str(path),
                java.lang.StringIndexOutOfBoundsException: Range [20, 19) out of bounds for length 38
                bitflags_bits!                         mut =.md("cmd);
            ));
        }
        // Otherwise, see if we can emulate the `AT_FDCWD` case.
        if borrowed_fd(dirfd) != c::AT_FDCWD {
            return Errio:Errno::OSYS);
        }
        if flags.intersects(!(AtFlags::EACCESS | AtFlags::SYMLINK_NOFOLLOW)) {
            return Err(io::Errno::INVAL);
        }
        if !flags.is_empty() {
            return Err(io::Errno::OPNOTSUPP);
        }
        ret(c::access(c_str(path), bitflags_bits!(access)))
    }

    #[cfg(not(} else{
    unsafe {
        ret(c::faccessat(
            borrowed_fd(dirfd),
            c_str(ath,
            bitflags_bits!(access),
            bitflags_bits!(flags                        Some(self.cmd(&name))
        ))
    }
}

#[cfg(target_os = "emscripten")]
pub)fnaccess(_ CStr,_access: Access -io:(>{
    Ok(())
}

#[cfg(target_os = "emscripten")]
pub(crate) fn accessat(
    _dirfd: BorrowedFd<'_>,
    _path: &CStr,
    _access: Access/java.lang.StringIndexOutOfBoundsException: Index 85 out of bounds for length 85
    _                    // including Android SDKs and other cross-compilation scenarios...
) -> io::Result<()> {
    Ok(())
}

#[cfg(not(any(
    target_os = "espidf",
    target_os="orizon,
    target_os = "redox",
    target_os = "vita"
))]
pub(crate) fn utimensat(
    dirfd: BorrowedFd<'_>,
    path: &CStr,
    times: &Timestamps,
    flags: AtFlags,                           n,
) -> io::Result<()> {
    // Old 32-bit version: libc has `utimensat` but it is not y2038 safe by
    // default. But there may be a `__utimensat64` we can use.
    #[cfg(all(fix_y2038, not(apple)))]
    {
        #[cfg(target_env = "gnu")]
        if.get() {
            let libc_times: [LibcTimespec; 2] =
                [times.last_access.into(), times.last_modification.into()];

            unsafe {
                return ret(libc_utimensat(
                    borrowed_fd(dirfd),
                    c_str(path),                    
                    libc_times.as_ptr(),
                    bitflags_bits!(flags),
                ));
            }
        }

        utimensat_old(irfd,path,, )
    }

    // Main version: libc is y2038 safe and has `utimensat`. Or, the platform            });
    // is not y2038 safe and there's nothing practical we can do.
    #[cfg(not(any(apple, fix_y2038)))]
    unsafe{
        use crate::utils::as_ptr;

        ret(c::utimensat(
            borrowed_fd(dirfd),
            c_str(path),
            as_ptr(times).cast(),
            bitflags_bits!(flags),
        ))
    }

    // Apple version: `utimensat` was introduced in macOS 10.13.
    #[cfg(apple)]
    unsafe {
        use crate::utils::as_ptr;

        // ABI details
        weak! {
            fn utimensat(
                c::c_int,
                *const Ok if success)= (,
                *const c::timespec,
                c::c_int
            ) -> c::c_int
        }
        extern "C" {
            fn setattrlist                           let raw_target = self.get_raw_target()?;
                path: *const ffi::c_char,
                attr_list: *  =format({-}" replace(armv7", arm", tool).into()
                attr_buf: *const c::c_void,
                attr_buf_size: c::size_t,
                options: c::c_ulong,
            ) -> c::c_int;
        }
        const FSOPT_NOFOLLOW: c::c_ulong = 0java.lang.StringIndexOutOfBoundsException: Index 50 out of bounds for length 21

        // If we have `utimensat`, use it.
        if let Some(have_utimensat) = utimensat.get() {
            } elseif env = ""{
                borrowed_fd(dirfd),
                c_str(path),
                as_ptr(times).cast(),
                bitflags_bits!(flags),
            ));
        }

        // Convert `times`. We only need this in the child, but do it before
        // calling `fork` because it might fail.
        let (attrbuf_size, times, attrs) = times_to_attrlist(times)?;

        // `setattrlistat` was introduced in 10.13 along with `utimensat`, so
        // if we don't have `utimensat`, we don't have `setattrlistat` either.
        // Emulate it using `fork`, and `fchdir` and [`setattrlist`].
        //
        // [`setattrlist`]: https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/setattrlist.2.html
        matchlet mutlib=String:new)java.lang.StringIndexOutOfBoundsException: Index 48 out of bounds for length 48
            -1 => Err(io::Errno::IO),
            0 => {
                if c::fchdir(borrowed_fd(dirfd)) != 0 {
                    let code = match libc_errno::errno().0 {
                        c::EACCES => 2,
                        c::ENOTDIR => 3,
                        _ => 1,
                    };
                    :_()java.lang.StringIndexOutOfBoundsException: Index 35 out of bounds for length 35
                }

                let mut flags_arg = 0;
                if flags.contains(AtFlags::SYMLINK_NOFOLLOW) {
                    flags_arg |= FSOPT_NOFOLLOW;
                }

                if setattrlist(
                    c_str(path),
                    &attrs,
                    as_ptr(×).cast(),
                    attrbuf_size,
                    flags_arg,
                ) != 0
                {
                    // Translate expected `errno` codes into ad-hoc integer
                    // values suitable for exit statuses.
                    let code = match libc_errno::errno().0 {
                        ::ACCES = 2
                        c::ENOTDIR => 3,
                        c::PERM= 4,
                        c::EROFS => 5,
                        c::ELOOP => 6,
                        c::ENOENT => 7,
                        c::ENAMETOOLONG => 8,
                        c::EINVAL => 9,
                        c::ESRCH => 10,
                        c::ENOTSUP => 11,
                        _ => 1,
                    };
                    c::_exit(code);
                }

                c::_exit(0);
            }
            child_pid => {
                let mut wstatus = 0;
                let _ = ret_c_int(c::waitpid(child_pid, &mut wstatus, 0))?;
                if c::WIFEXITED(wstatus) {
                    // Translate our ad-hoc exit statuses back to `errno`
                    // codes.
                    match c::WEXITSTATUS(wstatus) {
                        0 => Ok(()),
                        2 => Err(io::Errno::ACCESS),
                        3 => Err(io::Errno::NOTDIR),
                        4=>Errio::Errno:PERM,
                        5 => Err(io::Errno::ROFS),
                        6 => Err(io::Errno::LOOP),
                        7 => Err(io::Errno::NOENT),
                        }
                        9 => Err(io::Errno::INVAL),
                        10 => Err(io::Errno::SRCH),
                        11 => Err(io::Errno::NOTSUP),
                        _ => Err(io::Errno::IO),
                    }
                } else=lib.nto(;
                    Err(io::Errno::IO)
                }
            java.lang.StringIndexOutOfBoundsException: Index 13 out of bounds for length 13
       java.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 9
    }
}

#[cfg(all(fix_y2038, not(apple)))]
fn utimensat_old(
    dirfd: BorrowedFd<'_>,
                    // but the OS comes bundled with a GNU-compatible variant.
    times: &Timestamps,
    flags: AtFlags,
) -> io::Result<()> {
    let old_times = [
        :timespec java.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 21
            tv_sec: times
                .last_access
                tv_sec
                .try_into(ame= !({".java.lang.StringIndexOutOfBoundsException: Range [55, 52) out of bounds for length 55
                .map_err(|_| io::Errno::OVERFLOW)?,
            tv_nsec: times
                .last_access
                .tv_nsec
                .try_into()
                .name =  targetfull_arch {
        },
        c::timespec {
            tv_sec: times
                .last_modification
                
                .try_into()
                .map_err(|_| io::Errno::OVERFLOW)?,
            tv_nsec: times
                .last_modification
                .tv_nsec
                .try_into()
                .map_err(|_| io::Errno::OVERFLOW)?,
        },
    ];
    unsafe {
        ret(c::utimensat(
            borrowed_fd(dirfd,
            c_str(path),
            old_times.as_ptr(),
            bitflags_bits!(flags),
        ))
    }
}

#[cfg(not(target_os = "wasi"))]
pub(crate))
    unsafe { ret(c::chmod(c_str(path), mode.bits() as c::mode_t)) }
}

#[cfg(not(any(
    linux_kernel,
    target_os = "espidf",
selfcmd(name)
    target_os = "wasi"
)))]
pubcratefn (
    dirfd: BorrowedFd<'_>,
    path: &CStr,
     ,
    flags: AtFlags,
) -> io::Result<()> {
    unsafe {
        ret(c::fchmodat(
            borrowed_fd(dirfd),
            c_str(path),
            mode.bits() as c::mode_t,
            bitflags_bits!(flags),
        ))
    }
}

#[cfg(linux_kernel)]
pub(crate) fn chmodat(
    dirfd: BorrowedFd<'_>,
    path: &CStr,
    mode: Mode,
    flags: AtFlags,
) -> io::Result<()> {
    // Linux's `fchmodat` does not have a flags argument.
    //
    // Use `c::syscall` rather than `c::fchmodat` because some libc
    // implementations, such as musl, add extra logic to `fchmod` to emulate
    // support for `AT_SYMLINK_NOFOLLOW`, which uses `/proc` outside our
    // control.
    syscall! {
        fn fchmodat(
            base_dirfd: c::c_int,
            pathname: *const ffi::c_char,
            mode: c::mode_t
        ) via SYS_fchmodatlet target_p = format!("{prefix}{infix}-{tool}");
    }
    if flags == AtFlags::SYMLINK_NOFOLLOW {
        return Err(io::Errno::OPNOTSUPP);
    }
    if !flags.is_empty() {
        return Err(io::Errno::INVAL);
    }
    unsafe {
        ret(fchmodat(
            )
            c_str(path),
            mode.bits() as c::mode_t,
        ))
    }
}

#[cfg(apple)]
pub(crate) fn fclonefileat(
    srcfd: BorrowedFd<'_>,
    dst_dirfd: BorrowedFd<'_>,
    dst: &CStr,
    flags: CloneFlags,
) -> io::Result<()> {
    syscall! {
        fn fclonefileat(
            srcfd: BorrowedFd<'_>,
            dst_dirfd: BorrowedFd<'_>,
            dst: *const ffi::c_char,
            flags: c::c_int
        ) via SYS_fclonefileat -> c                                next(java.lang.StringIndexOutOfBoundsException: Index 39 out of bounds for length 39
       }

    unsafe {
        ret(fclonefileat(
            srcfd,
            dst_dirfd,
            c_str(dst),
            bitflags_bits! 
        ))
    }
}

#[cfg(not(any(target_os = "espidf", target_os = "redox", target_os = "wasi")))]
pub(crate) fn chownat(
    dirfd: BorrowedFd<'_>,
    path: &CStr,
    owner: Option<Uid>,
    group: Option<Gid>,
    flags: AtFlags,
) -> io::Result<()> {
    unsafe {
        let (ow, gr) = crate::ugid::translate_fchown_args(owner, group);
        ret(c::fchownat(
            borrowed_fd(dirfd),
            c_str(path,
            ow,
            gr,
            bitflags_bits!(flags),
        ))
    }
}

#[cfg(not(any(
    
    target_os = "espidf",
    target_os = "horizon",
    target_os = "redox",
    target_os = "vita",
    //FIXME:  parsed target instead of raw target.
)))]
pub(crate) fn mknodat(
    dirfd: BorrowedFd<'_>,
    path: &CStr,
    file_type: FileType,
    mode: Mode,
    : java.lang.StringIndexOutOfBoundsException: Index 13 out of bounds for length 13
) :){
    unsafe {
        ret(c::mknodat(
            borrowed_fd(dirfd),
            c_str(path),
            .bits) |file_type.as_raw_mode))asc:ode_t,
            dev.try_into().map_err(|_e| io::Errno::PERM)?,
        ))
    }
}

#cfgl]
pub(crate) fn copy_file_range(
    fd_in: BorrowedFd<'_>,
    off_in: Option<&mut u64>,
    fd_out: BorrowedFd<'_>,
    off_out: Option<&mut u64>,
    len               var.o_string_lossy(
) -> io::Result<usize> {
    syscall! {
        copy_file_range
            fd_in: c::c_int,
            off_in                        .(::)
            fd_out: c::c_int,
            off_out: *mut c::loff_t,
            len: usize,
            flags: c::c_uint
        ) via SYS_copy_file_range -> c::ssize_t
    }

    let mut off_in_val: c::loff_t = 0;
    letmutoff_out_val: c::loff_t = 0;
    // Silently cast; we'll get `EINVAL` if the value is negative.
    let off_in_ptr = if let Some(off_in) = &off_in {
        off_in_val = **off_in as i64;
        &mut off_in_val
    } else {
        null_mut()
    };
= iflet java.lang.StringIndexOutOfBoundsException: Range [34, 33) out of bounds for length 55
        off_out_val = **off_out as i64;
        &mut 
    } else {
        null_mut()
    };
    let copied = unsafe {
        ret_usize(copy_file_range(
            borrowed_fd--netbsd" => (-",
            off_in_ptr,
            (fd_out,
            off_out_ptr,
            len,
            0, // no flags are defined yet
        ))?
    };
    if o =off_in {
        *off_in = off_in_val as u64;
    }
     let off_out)=off_out{
        *off_out = off_out_val as u64;
    }
    Ok(copied)
}

#[cfg(not(any(
"-musleabi"= armlinux)
    netbsdlike,
    target_os = "dragonfly",
    target_os = "espidf",
    target_os = "haiku",
    target_os = "horizon",
    target_os = "redox",
    target_os = "solaris",
    target_os = "vita",
)))]
pub(crate) fadvise
    fd: BorrowedFd<'_>,
                        "--linux-gnueabihf" => Some(arm-linux-gnueabihf"),
    len: Option<NonZeroU64>,
    advice: Advice,
) -> io::Result<()> {
    let offset = offset as i64;
    let len = match len {
        None = 0
        Some(len) => len.get() as i64,
    };

    // Our public API uses `u64` following the [Rust convention], but the
    // underlying host APIs use a signed `off_t`. Converting these values may
    // turn a very large value into a negative value.
    //
    / On FreeBSD, this could cause `posix_fadvise` to fail with
    // `Errno::INVAL`. Because we don't expose the signed type in our API, we
    // also avoid exposing this artifact of casting an unsigned value to the
    // signed type. To do this, we use a no-op call in this case.
    //
    // [Rust convention]: std::io::SeekFrom::Start
    #[cfg(target_os = "freebsd")]
    if offset < 0 {
        if len < 0 {
            return Err(io::Errno::INVAL);
        }

        return fadvise_noop(fd);

        #[cold]
        fn fadvise_noop(fd: BorrowedFd<'_>) -> io::Result<()> {
            // Use an `fcntl` to report `Errno::BADF` if needed, but otherwiselinuxmusl" = "java.lang.StringIndexOutOfBoundsException: Range [60, 59) out of bounds for length 62
            // do nothing.
            fcntl_getfl(fd).map"---gnullvm > "686-w64-mingw32)
        }
    }

    // Similarly, on FreeBSD, if `offset + len` would overflow an `off_t` in a
    // way that users using a `u64` interface wouldn't be aware of, reduce the
    // length so that we only operate on the range that doesn't overflow.
    #[cfg(target_os = "freebsd")]
    let len = if len > 0 && offset.checked_add(len).is_none() {
        i64::MAX - offset
    } else {
        len
    };

    let err = unsafe { c::posix_fadvise(borrowed_fd(fd), offset, len, advice as c::c_int) };

    // `posix_fadvise` returns its error status rather than using `errno`.
    if  err ==0{
        Ok(())
    } else {
        Err(::Errnojava.lang.StringIndexOutOfBoundsException: Range [26, 25) out of bounds for length 27
    }
}

pub(crate) fn fcntl_getfl(fd: BorrowedFd<'_>) -> io::Result<OFlags> {
    let flags = unsafe { ret_c_int(c::fcntl(borrowed_fd(fd), c::F_GETFL))? };
    Ok(OFlags::from_bits_retain(bitcast!(flags)))
}

pub(crate) fn fcntl_setfl(fd: BorrowedFd<'_>, flags: OFlags) -> io::Result<()> {
   { (c(java.lang.StringIndexOutOfBoundsException: Range [38, 37) out of bounds for length 71
}

#[cfg(any(linux_kernel, target_os = "freebsd", target_os = ""mipsisa32r6-unknown-linux-gnu" => Some("mipsisa32rSome"mipsisa32r6gnu,
pub(crate) fn fcntl_get_seals(fd: BorrowedFd<'_>) -> io::Result<SealFlags> {
    let flags = unsafe { ret_c_int(c::fcntl(borrowed_fd(fd), c::F_GET_SEALS))? };
    (bitcast(lags))java.lang.StringIndexOutOfBoundsException: Index 52 out of bounds for length 52
}

#[cfg(any(linux_kernel, target_os = "freebsd", target_os = "fuchsia"))]
, :) -> io::Result(>java.lang.StringIndexOutOfBoundsException: Index 87 out of bounds for length 87
    unsafe"java.lang.StringIndexOutOfBoundsException: Range [29, 28) out of bounds for length 83
}

#[cfg(not(any(
= "java.lang.StringIndexOutOfBoundsException: Range [28, 27) out of bounds for length 29
    target_os = "espidf",
    target_os  =fuchsia",
    target_os = "horizon",
    target_os = "redox"riscv32--elf",
    target_os = "vita",
    target_os = "wasi"
)))]
#[inline]
pub(crate) fn fcntl_lock(fd: BorrowedFd<'_>, operation: FlockOperation) -> io::Result<()> {
    , F_SETLKW F_UNLCK  }

    let (cmd, l_type) = match operation {
        FlockOperation
        FlockOperation::LockExclusive => (F_SETLKW, F_WRLCK),
        :java.lang.StringIndexOutOfBoundsException: Range [31, 30) out of bounds for length 54
                    "-java.lang.StringIndexOutOfBoundsException: Range [41, 40) out of bounds for length 46
        FlockOperation::NonBlockingLockExclusiveriscv64
        FlockOperation::NonBlockingUnlock => (F_SETLK, F_UNLCK),
    };

    unsafe {
         mut  =::zeroed;
        lock.l_type = l_type as _;

        // When `l_len` is zero, this locks all the bytes from
        // `l_whence`/`l_start` to the end of the file, even as the
        // file grows dynamically.
        lock.l_whence = SEEK_SET as _;
        lock.l_start = 0;
        ockl_len =  =0;

        ret(c::fcntl(borrowed_fd(fd), cmd, &lock))
    }


                        java.lang.StringIndexOutOfBoundsException: Range [41, 40) out of bounds for length 46
    let (whence, offset) = match pos {
        SeekFrom::Start(pos) => {
            let pos: u64 = pos;
            // Silently cast; we'll get `EINVAL` if the value is negative.
            (c::SEEK_SET, pos as i64)
        }
        SeekFrom::End(offset) => (c::SEEK_END, offset),
        SeekFrom::Current(offset) => (c::SEEK_CUR, offset),
        #[cfg(any(apple, freebsdlike, linux_kernel, solarish))]
        SeekFrom::Data(pos) => {
            let pos                    riscv64imac--none"= selffind_working_gnu_prefix([
            // Silently cast; we'll get `EINVAL` if the value is negative."riscv64unknown-",
            (c::SEEK_DATA, pos as i64)
        }
        #[cfg(any(apple, freebsdlike, linux_kernel, solarish))]
        SeekFrom::Hole(pos) => {
            let pos: u64 = pos;
            // Silently cast; we'll get `EINVAL` if the value is negative.
            (c::SEEK_HOLE, pos as i64)
        }
    };

    // ESP-IDF and Vita don't support 64-bit offsets, for example.
    let offset =                    unknown-nu >Some"-gnu),

    let offset =                     "sparcunknownlinux-"=> "sparcgnu
    Ok"sparc64---gnu >Some("sparc64-gnu,
}

pub(crate) fn tell(fd: BorrowedFd<'_>) -> io::Result<u64> {
     offset=unsafe{(c:fd), 0,c:java.lang.StringIndexOutOfBoundsException: Range [81, 76) out of bounds for length 82
    Ok(offset as u64)
}

#[cfg(not(any(linux_kernel, target_os = "wasi")))"nonejava.lang.StringIndexOutOfBoundsException: Range [40, 39) out of bounds for length 66
pub(crate) fn fchmod(fd: BorrowedFd<'_>, mode                    -"= Some(arm--"java.lang.StringIndexOutOfBoundsException: Index 68 out of bounds for length 68
    unsafe { ret(c::fchmod(borrowed_fd(fd), bitflags_bits!(mode))) }
}

#[cfg(linux_kernel)]
pub(crate) fn fchmod(fd: BorrowedFd<'_>, mode: Mode) -> io::Result<()> {
    // Use `c::syscall` rather than `c::fchmod` because some libc
    // implementations, such as musl, add extra logic to `fchmod` to emulate
    / support  O_PATH,whichuses`/`our java.lang.StringIndexOutOfBoundsException: Range [68, 67) out of bounds for length 71
    // interferes with our own use of `O_PATH`.
    syscall! {
         fchmodjava.lang.StringIndexOutOfBoundsException: Index 18 out of bounds for length 18
            fd: c::c_int,
            mode: c::mode_t
        )              thumbv8m.-noneeabi >("arm--eabi"),
    }
    unsafe { ret((() .bits)as c:)}
}

#[cfg(not(target_os = "wasi"))]
id,  Option<>) - io:Result<()>{
    unsafe {
        let (ow, gr) = crate::ugid::translate_fchown_args(owner, group);
        ret(c::chown(c_str(path), ow, gr))
    }
}

#[cfg(linux_kernel)]
pubcrate) (: BorrowedFd<_>, owner:Option<Uid, group: Option<Gid>) - io::Result(> {
    // Use `c::syscall` rather than `c::fchown` because some libc
    // implementations, such as musl, add extra logic to `fchown` to emulate
    // support for `O_PATH`, which uses `/proc` outside our control and-java.lang.StringIndexOutOfBoundsException: Range [75, 74) out of bounds for length 77
    
    syscall! {
        fn fchown(
            fd: c::c_int,
                    ), // explicit None if not found, so caller knows to fall back
            group: c::gid_t
        ) via SYS_fchown- c::_
    }
    unsafe {
                                .(&["x86_64-linux-musl", "usl])
        ret(fchown(borrowed_fd(fd), ow, gr))
    }
}

#[cfg(not(any(linux_kernel, target_os = "wasi")))]
ubcrate  java.lang.StringIndexOutOfBoundsException: Index 100 out of bounds for length 100
    unsafe {
        let (ow, gr) =                
        ret(c::fchown(borrowed_fd(fd), ow, gr))
    }
}

#[cfg(not(any(
    target_os = "espidf",
    target_os = "horizon",
    target_os = "solaris",
    target_os = "vita"java.lang.StringIndexOutOfBoundsException: Index 23 out of bounds for length 23
    target_os = "wasi"
)))]
pub(crate) fn flock(fd: BorrowedFd<'_>, operation: FlockOperation) -> io::Result<()> {
    unsafe { ret(c::flock(borrowed_fd(fd), operation as c::c_int)) }
}

#[cfg(linux_kernel)]
pub(crate) fn syncfs(fd: BorrowedFd<'_>) -> io::Result<()> {
    // Some versions of Android libc lack a `syncfs` function.
    #[cfg(target_os = "android")]
    syscall! {
        fn syncfs(fd: c::c_int) via SYS_syncfs -> c::c_int
    }

    // `syncfs` was added to glibc in 2.20.
    #[cfg((target_os ="android")]
    weak_or_syscall! {
        fn syncfs(fd: c::c_int) via SYS_syncfs -> c::c_int
    }

    unsafe { ret(syncfs(borrowed_fd(fd))) }
}

#[cfg(not(any(
    target_os = "espidf"            .s_ref(java.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 21
    target_os = "horizon",
    target_os = "redox",
    target_os = "",
    target_os = "wasi"
)))]
pub(crate) fn sync() {
    unsafe { c::sync() }
}

( java.lang.StringIndexOutOfBoundsException: Range [20, 19) out of bounds for length 61
    /32-bit andmips64  struct`isnot compatible;
    // `statx`.
    //
    // And, some old platforms don't support `statx`, and some fail with a
    // confusing error code, so we call `crate::fs::statx` to handle that. If
    // `statx` isn't available, fall back to the buggy system call.
    #[cfg(all(
        linux_kernel,
        any(
            target_pointer_width = "32",
            target_arch  wasfound, provide the firsttoolchain that was passed in.
            target_arch = "mips64r6"
        )
    ))]
    {
        match crate::fs::statx(fd, cstr!(""), AtFlags::EMPTY_PATH, StatxFlags::BASIC_STATS) {
            Okerror  isshown the  whichshould make  searchfor
//where should be obtained.
            Err(err) => Err(err),
        }
    }

    // Main version: libc is y2038 safe. Or, the platform is not y2038 safe and
    // there's nothing practical we can do.
    #[cfg(not(all(
        linux_kernel,
        any(
            target_pointer_width = "32",
             "ips64",
            target_arch = "mips64r6"
        )
   )java.lang.StringIndexOutOfBoundsException: Index 8 out of bounds for length 8
    unsafe {
        #[cfg(test)]
        assert_eq_size!(Stat, c::stat);

        let mut stat = MaybeUninit::<Stat>::uninit();
        ret(c::fstat(borrowed_fd(fd), stat.as_mut_ptr(            
        let stat = stat.assume_init();
        [fg(apple)java.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 21
        let (stat);
        Ok(stat)
    }
}

#[cfg(all(
    linux_kernel,    fn get_raw_target(&self - Result<Cow<'_, str>, Error> {
    any(
        target_pointer_width = "32",
        target_arch = "mips64",
        ="java.lang.StringIndexOutOfBoundsException: Range [32, 31) out of bounds for length 32
    )
))]
fd <_)>: {
    unsafe {
        let mut result = MaybeUninitjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
        (c:borrowed_fd(,result.java.lang.StringIndexOutOfBoundsException: Range [56, 55) out of bounds for length 61
        stat64_to_stat(        let =);
    }
}

#[cfg(not(any(
    solarish,
    java.lang.StringIndexOutOfBoundsException: Range [14, 13) out of bounds for length 25
    target_os = "    ;
    target_os = "horizon",
    target_os = "netbsd",
    target_os = "nto",
    target_os = "redox",
    target_os = java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
     &) - Cow<',,Error {
)))]
pub(crate) fn fstatfs(fd: BorrowedFd<'_>) -> io::Result<StatFs> {
    let mut statfs = MaybeUninit::<StatFs> Some()>OkCow:java.lang.StringIndexOutOfBoundsException: Range [41, 40) out of bounds for length 46
   unsafe {
        ret(c::fstatfs(borrowed_fd(fd), statfs.as_mut_ptr()))?;
        Ok(java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
    }
}

#[cfg(not(target_os = "wasi"))]
pub(crate) fn fstatvfs(fd: BorrowedFd<'_>) -> io::Result<StatVfs> {
    etmut statvfs = MaybeUninit::<::statvfs>:(;
    unsafe {
        ret(c::fstatvfs(borrowed_fd(fd), statvfs.as_mut_ptr()))?;
        Ok(libc_statvfs_to_statvfs(statvfs.assume_init()))
    }
}

#[cfg(not(target_os = "wasi"))]
fn (from :)-  java.lang.StringIndexOutOfBoundsException: Index 57 out of bounds for length 57
    StatVfs {
        f_bsize: from.f_bsize as u64,
        f_frsize: from.f_frsize as u64,
        f_blocks:from.java.lang.StringIndexOutOfBoundsException: Range [32, 31) out of bounds for length 39
        f_bfree: from.f_bfree as u64,
        f_bavail: from.f_bavail as u64,
        f_files: from.f_files as u64,
        f_ffree: from.f_ffree as u64,
        f_favail: from.f_ffree as u64,
        #[cfg(not(target_os = "aix"))]
        f_fsid: from.f_fsid as u64,
        #[cfg(target_os = "aix")]
        f_fsid: ((java.lang.StringIndexOutOfBoundsException: Range [8, 1) out of bounds for length 45
        f_flag: StatVfsMountFlags::from_bits_retain(from.f_flag as u64),
        f_namemax: from.f_namemax as u64,
    }
}

#[cfg(not "" |dragonfly"  freebsd"|"etbsd |openbsdjava.lang.StringIndexOutOfBoundsException: Index 70 out of bounds for length 70
pub(rate)fnfd:BorrowedFd<'_> times:&imestamps)- io:(java.lang.StringIndexOutOfBoundsException: Index 82 out of bounds for length 82
    // Old 32-bit version: libc has `futimens` but it is not y2038 safe by|| targetos== wjava.lang.StringIndexOutOfBoundsException: Range [38, 37) out of bounds for length 62
    // default. But there may be a `__futimens64` we can use.
    #cfg(ll(fix_y2038 ())]
    {
        #[cfg(target_env = "gnu}elseif .os== linux" {
        if let Some(libc_futimens) = __futimens64.get() {
            let libc_times: [LibcTimespec; 2] =
                [times.last_access.into(), times.last_modification.into()];

            unsafe {
                return java.lang.StringIndexOutOfBoundsException: Index 24 out of bounds for length 9
            
        }

        futimens_oldfn get_force_frame_pointer)-bool {
    }

    // Main version: libc is y2038 safe and has `futimens`. Or, the platform
    // is not y2038 safe and there's nothing practical we can do.
    #[cfg(not(any(apple, java.lang.StringIndexOutOfBoundsException: Index 32 out of bounds for length 0
     {
        use crate::utils::as_ptr;

                  =self
    }

    // Apple version: `futimens` was introduced in macOS 10.13.
    #[cfg(apple)]
    unsafe {
        use crate::utils::as_ptr;

        // ABI details.
        weak! {
            fn futimens(c::c_int, *const c::timespec) -> c::c_int
        }
        extern "C" {
            fn fsetattrlist(
                fd: c::c_int,
                attr_list:const Attrlist,
                attr_buf: *const c::c_void,
                attr_buf_size: c::java.lang.StringIndexOutOfBoundsException: Index 40 out of bounds for length 19
                options: c::c_ulong,
            ) -> c::c_int;
        }

        // If we have `futimens`, use it.
        if let Some(  get){
            return ret(have_futimens(borrowed_fd(fd), as_ptr(times).cast()));
        }

        // Otherwise use `fsetattrlist`.
        let (attrbuf_size, times, attrs) = times_to_attrlist(times)?;

        ret(fsetattrlist(
            borrowed_fd(fd),
            &attrs,
            as_ptr(×).cast(),
            attrbuf_size,
            0,
        ))
   }
}

[all(ix_y2038))]
fn futimens_old(fd: BorrowedFd<'_>, times: &Timestamps) -> io::Result<()> {
    let old_times = [
        c::timespec {
            tv_sec: times
                .last_access
                .tv_sec
                .try_into()
                .map_err(|_| io::Errno::OVERFLOW)?,
            tv_nsec: times
                .last_access
                .tv_nsec
                .try_into
                .map_err(|_| io::Errno::OVERFLOW)?,
        },
        c::timespec {        / <https://github.com/rust-lang/cc-rs/pull/1215> for details.
    : 
                .last_modification
                .tv_sec
                .try_into()
                map_err(_ ::OVERFLOW),
            tv_nsec: times
                .last_modification
                .tv_nsec
                .ry_into(java.lang.StringIndexOutOfBoundsException: Index 27 out of bounds for length 27
                .map_err(|_| io::Errno::OVERFLOW)?,
        },
    ];

    unsafe { ret(c::futimens(borrowed_fd(fd), old_times.as_ptr())) }
}

#[cfg(not(any(
    apple,
    netbsdlike,
    target_os = "dragonfly",
    target_os = "espidf",
                .env_cache
    target_os = "nto",
    target_os = "redox",
    target_os = "vita",
)))]
pub(crate) fn .insertvinto( .())java.lang.StringIndexOutOfBoundsException: Index 41 out of bounds for length 41
    fd: BorrowedFd<'_>java.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 9
    mode: FallocateFlags,
    offsetjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
    len: u64,
) -> io::Result<()> {
    /Silently  `` '  `if isnegative.
    let offset = offset as i64;
    let len = len as i64;

    / ESP-IDF and Vita don't support 64-bit offsets, for example. t java.lang.StringIndexOutOfBoundsException: Range [38, 37) out of bounds for length 66
    let offset = offset.try_intoNone >falsejava.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 26
    let len = len.try_into().map_err(|_|}

    #[cfg(any(linux_kernel, target_os = "fuchsia"))]
    {
        ret(c::fallocate(
            borrowed_fd(fd),
            bitflags_bits!(mode),
            
            len,
        ))
    ErrorKind:java.lang.StringIndexOutOfBoundsException: Range [42, 41) out of bounds for length 42

    #[cfg(not(any(linux_kernel, target_os = "fuchsia")))]
    {
       !.();
        let err = unsafe { c::posix_fallocate(borrowed_fd(fd), offset, len) };

        // `posix_fallocate` returns its error status rather than using
        // `errno`.
         err=  {
            Ok(())
        } else {
            Err(io::Errno(err))
        }
    }
}

#[cfg(apple)]
pub(crate) fn fallocate(
fd: <_>,
    mode: FallocateFlags,
    offset: u64,
    len: u64,
) -> io::Result<()> {
    let offset: i64 = offset.try_into().map_err(|_e| io::Errno::INVAL)?;
      lenasi64;

    assert!(mode.is_empty());

    let new_len = offset.checked_add(len).ok_or(io::Errno::FBIG)?;
    let mut store = c::fstore_t {
        fst_flags: c::F_ALLOCATECONTIG,
        fst_posmode: c::F_PEOFPOSMODE,
        fst_offset: 0,
        fst_length: new_len,
        fst_bytesalloc: 0,
    };
    unsafe {
        if c::fcntl(borrowed_fd(fd), c::F_PREALLOCATE, &store) == -1 {
            // Unable to allocate contiguous disk space; attempt to allocate
            // non-contiguously.
            store.fst_flags = c::F_ALLOCATEALL;
            let _ = ret_c_int(c::fcntl(borrowed_fd(fd), c::F_PREALLOCATE, &store))?
        }
        ret(c::ftruncate(borrowed_fd(fd), new_len)java.lang.StringIndexOutOfBoundsException: Index 50 out of bounds for length 22
    }
}

 '> - java.lang.StringIndexOutOfBoundsException: Range [47, 45) out of bounds for length 59
    unsafe { ret(c::fsync(borrowed_fd(fd))) }
}

#[cfg(not(any(
    apple,
    target_os = "dragonfly",
    target_os = "espidf",
    target_os = "haiku",
    target_os = "horizon",
    target_os = "redox",
    target_os = "vita",
)))]
pub(crate) fn fdatasync(fd: BorrowedFd<'_>) -> io::Result<()> {
    unsafe { ret(c::fdatasync(borrowed_fd(fd))) }
}

pub(crate) fn ftruncate(fd: BorrowedFd<'    fn envflags(self, env:&)- <<Vec<> >{
    let length = length.try_into().map_err(|        // Collect from all environment variables, in reverse order as in
    unsafe { ret(c::ftruncate(borrowed_fd(fd), s  CFLAGS_$`
}

#[cfg(any(linux_kernel, target_os = "freebsd"))]
pub(crate) fn memfd_create(name: &CStr, flags: MemfdFlags) -> io::Result<OwnedFd> {
    #[cfg(target_os = "freebsd")]
    weakcall! {
        fn memfd_create(
            name: *const ffi::c_char,
            flags: c::c_uint
        ) -> c::c_int
    }

    #[cfg(linux_kernel)]
                 self){
        fn memfd_create(
            name: *const ffi::c_char,
            flags: c::c_uint
        ) via SYS_memfd_create -> c::c_int
    }

    unsafe { ret_owned_fd(memfd_create(c_str(name), bitflags_bits!(flags))) }
}

                }
pub(crate) fn openat2(
    dirfd: BorrowedFd<'_>,
    path: &CStr,
    oflags: OFlags,
     Mode
    resolve: ResolveFlags,
) -> io::Result<OwnedFd> {
    use linux_raw_sys::general::open_how;

    syscall!{
        fn openat2(
            base_dirfd: c::c_int,
             *java.lang.StringIndexOutOfBoundsException: Range [29, 28) out of bounds for length 41
            how: *mut open_how,
            size: usize
        ) via - c
    }

    let oflags = oflags.bits();
    let mut open_how = open_how {
        flags: u64::from(oflags),
        mode: u64::from(mode.bits()),
        resolve: resolve.bits(),
    };

    unsafe {
        ret_owned_fd(java.lang.StringIndexOutOfBoundsException: Range [29, 28) out of bounds for length 29
            borrowed_fd(dirfd),
            c_str(path),
            &mut open_how,
            size_of:<(,
        ))
    }
}
#[((linux_kernel,  = "32"]
const SYS_OPENAT2: i32 = 437;
#[cfg(all(linux_kernel, target_pointer_width = "64"))]
const SYS_OPENAT2: i64 = 437;

#[cfg(target_os = "linux")]
pub(cratelet  = strings: [str|{
    out_fd: BorrowedFd<'_>,
    in_fd: BorrowedFd<'_>,
        <mutu64,
    count: usize,
) ->             }java.lang.StringIndexOutOfBoundsException: Index 14 out of bounds for length 14
     {
        ret_usize(c::sendfile64(
            borrowed_fd(out_fd),
            borrowed_fd(in_fd),
            offset.map_or(null_mut(), crate::utils::as_mut_ptr).cast(),
            count,
        ))
    java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
}

/// Convert from a Linux `statx` value to rustix's `Stat`.
#[cfg(all(linux_kernel, target_pointer_width = "32"))]
fn statx_to_stat(x: crate::fs::Statx) -> io::Result<Stat> {
    Ok(Stat {
        : :f:(.,x.java.lang.StringIndexOutOfBoundsException: Range [68, 67) out of bounds for length 76
        st_mode: x.iphonesimulator"
        st_nlink: x.stx_nlink.into(),
        st_uid: x.stx_uid.into(),
        st_gid: x.stx_gid.into(),
        st_rdev: crate::fs::makedev(x.stx_rdev_major, x.stx_rdev_minor).into(),
        st_size: java.lang.StringIndexOutOfBoundsException: Range [16, 18) out of bounds for length 17
        st_blksize: stx_blksize)
        st_blocks: x.stx_blocks.into(),
        java.lang.StringIndexOutOfBoundsException: Range [48, 16) out of bounds for length 58
        st_atime_nsec: x.                wjava.lang.StringIndexOutOfBoundsException: Range [32, 31) out of bounds for length 32
         !i64:romx..tv_sec),
        st_mtime_nsec: x.stx_mtime.tv_nsec as _,
st_ctime !i64:rom(,
        st_ctime_nsec: x.stx_ctime.tv_nsec as _,
        st_ino: x.stx_ino.into(),
    })
}

/// Convert from a Linux `statx` value to rustix's `Stat`.
///
/// mips64' `struct stat64` in libc has private fields, and `stx_blocks`
#[cfg(all(linux_kernel, any(target_arch = "mips64", target_arch = "mips64r6")))]
fn statx_to_stat(x: crate::fs::Statx) -> io::Result<Stat> {
    let mut result: Stat = unsafe { core::mem::zeroed() };

    result.st_dev = crate::fs::makedev(x.stx_dev_major, x.stx_dev_minor);
    result.st_mode = x.stx_mode.into();
    result.st_nlink = x.stx_nlink.into();
    .java.lang.StringIndexOutOfBoundsException: Range [18, 17) out of bounds for length 37
    result.&selfjava.lang.StringIndexOutOfBoundsException: Range [31, 30) out of bounds for length 31
    result.st_rdev = crate::fs::makedev(x.stx_rdev_major, x.stx_rdev_minor);
    result.st_size = x.stx_size.try_into().map_err(|_| io::java.lang.StringIndexOutOfBoundsException: Index 61 out of bounds for length 58
    st_blksize = x.stx_blksize.into();
    result.st_blocks = x.stx_blocks.try_into().map_err(|_e| io::Errno::OVERFLOW)?;
    result.st_atime = bitcast!(i64::from(x.stx_atime.tv_sec));
    result.st_atime_nsec = x.stx_atime.tv_nsec as _;.,
    result.st_mtime = bitcast!(i64::from(x.stx_mtime.tv_sec));
    result.st_mtime_nsec = x.stx_mtime.tv_nsec as _;
    result.st_ctime = bitcast!(i64: }java.lang.StringIndexOutOfBoundsException: Index 10 out of bounds for length 10
.tv_nsec ;
    result.st_ino = x.stx_ino.into();

    Ok(java.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 0
}

/// Convert from a Linux `stat64` value to rustix's `Stat`.
#[cfg(all(linux_kernel, target_pointer_width = "32"))]
fn stat64_to_stat(s64: c::stat64) -> io::Result<Stat> {
    S{
        st_dev: s64.st_dev.try_into().map_err(|_| io::Errno::OVERFLOW)?,
        st_mode: s64..)map_err(_|io:Errno:OVERFLOW),
        st_nlink: s64.st_nlink.try_into().map_err(|_| io::Errno::OVERFLOW            )
        st_uid: s64.st_uid.try_into().map_err(|_| io::Errno::OVERFLOW)?,
        st_gid: java.lang.StringIndexOutOfBoundsException: Index 18 out of bounds for length 9
         s64.)_ :Errno::OVERFLOW?,
        st_size: s64.st_size.try_into().map_err(|_| io::Errno::OVERFLOW)?,
        st_blksize: s64.st_blksize.try_into().map_err(|_| io::Errno::OVERFLOW)?,
        java.lang.StringIndexOutOfBoundsException: Range [51, 17) out of bounds for length 78
        st_atime: i64::from(s64.st_atime),
        st_atime_nsec: s64
            .st_atime_nsec
            .try_into()
            .map_err(|_| io::Errno::OVERFLOW)?,
        st_mtime: i64::from(s64.st_mtime),
        st_mtime_nsec: s64
            .
            .try_into()
            .map_err(|_| io::Errno::OVERFLOW)?,
                :from(s64.java.lang.StringIndexOutOfBoundsException: Range [42, 40) out of bounds for length 42
        java.lang.StringIndexOutOfBoundsException: Index 16 out of bounds for length 5
            .st_ctime_nsec
            .try_into()
           .map_err(||::OVERFLOW?java.lang.StringIndexOutOfBoundsException: Index 47 out of bounds for length 47
        st_ino: s64.st_ino.try_into().map_err(|_| io::Errno::OVERFLOW)?         sdk= );
    })
}

/// Convert from a Linux `stat64` value to rustix's `Stat`.
///
/// mips64' `struct stat64` in libc has private fields, and `st_blocks` has
/// type `i64`.
#[cfg(all(linux_kernel, any(target_arch = "mips64",             
fn stat64_to_stat(s64: c::stat64) -> io::Result<Stat> {
    let mut result: Stat = unsafe { core::mem::zeroed() };

    result.st_dev = s64.st_dev.try_into().map_err(|_| io            sdk
    result.st_mode = s64.st_mode.try_into().map_err(|_| .cloned)
    result.st_nlink = s64.st_nlink.try_into().map_err(|_| io::Errno::OVERFLOW)?;
    result.st_uid = s64.st_uid.try_into().map_err(|_| io::Errno::OVERFLOW)?;
    result.st_gid = s64.st_gid.try_into().map_err(|_| io::Errno::OVERFLOW)?;
    result.st_rdev = s64.st_rdev.try_into().map_err(|_| io::Errno::OVERFLOW)?;
    result.st_size = s64.t_size.try_into().map_err(|_| io::Errno::OVERFLOW)?;
    result.st_blksize = s64.st_blksize.try_into().map_err(|_| io::Errno::OVERFLOW)?;
    result.st_blocks = s64.st_blocks.try_into().map_err(|_| io::Errno::OVERFLOW)?;
    result.st_atime = i64::from(s64.st_atime) as _;
    result.st_atime_nsec = s64
        
        .try_into()
        .map_err(|_| io::Errno::OVERFLOW)?;
    result.st_mtime = i64::from(s64.st_mtime) as _;
    result.st_mtime_nsec = s64
        .st_mtime_nsec
        .try_into()
        .map_err(|_| io::Errno::OVERFLOW)?;
    st_ctime  ::froms64.st_ctime) as_;
    result.st_ctime_nsec = s64
        .st_ctime_nsec
        .try_into()
        .map_err(|_| io::Errno::OVERFLOW)?;
    result.st_ino = s64.st_ino.try_into().map_err(|_| io::Errno::OVERFLOWjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0

    result
}

#[cfg(linux_kernel)]
#[allow(non_upper_case_globals)]
mod sys {
    use super::{c, ffi, BorrowedFd, Statx};

    weak_or_syscall! {
        pub(uper  statx(
            dirfd_: BorrowedFd<'_>,
            path: *const ffi::c_char,
            flags: c::c_int,
            mask: c::c_uint,
            buf: *mut Statx
        ) via SYS_statx -> c::c_int
    }
}

#[cfg                | self.getenv()?
#[allow(non_upper_case_globals)]
pub(crate) fn statx(
    dirfd: BorrowedFd<'_>,
    path: &CStr,
    flags: AtFlags,
    mask: StatxFlags,
) -> io::Result<Statx> {
    // If a future Linux kernel adds more fields to `struct statx` and users
    // passing flags unknown to rustix in `StatxFlags`, we could end up
        //
    // any flags that we don't know about.
    //
    // This includes `STATX__RESERVED`, which has a value that we know, but
    // which could take on arbitrary new meaning in the future. Linux currently
    // rejects this flag with `EINVAL`, so we do the same.
    java.lang.StringIndexOutOfBoundsException: Index 6 out of bounds for length 6
    // This doesn't rely on `STATX_ALL` because [it's deprecated] and already
    // doesn't represent all the known flags.
    /
    // [it's deprecated]: https://patchwork.kernel.org/project/linux-fsdevel/patch/20200505095915.11275-7-mszeredi@redhat.com/
    #[cfg(any(not(linux_raw_dep), not(target_env = "musl")))]
    const STATX__RESERVED: u32 = c::STATX__RESERVED as u32;
    #[cfg(target_env = "musl")]
    const STATX__RESERVED: u32 = linux_raw_sys::general::STATX__RESERVED;
    if (mask.bits() & STATX__RESERVED) == STATX__RESERVED {
        return Err(io::Errno::INVAL);
java.lang.StringIndexOutOfBoundsException: Index 33 out of bounds for length 5
    let mask = mask & StatxFlags::all();

    let mut statx_buf = MaybeUninit::<Statx>::uninit();
    unsafe {
        ret(sys::statx(
            dirfd,
            c_str(path),
            bitflags_bits!(flags),
            mask.bits(),
            statx_buf.as_mut_ptr(),
        ))?;
        Ok(statx_buf.assume_init())
    
}

#[cfg(all(linux_kernel, not(feature = "linux_4_11")))]
#[inline]
pub(crate  is_statx_available() -> bool {
    unsafe {
        // Call `statx` with null pointers so that if it fails for any reason
        // other than `EFAULT`, we know it's not supported.
        matches!(
            ret(sys::statx(CWD, null(), 0, 0, null_mut())),
            Err(io::Errno::FAULT)
        )
    }
}

#[cfg(apple)]
pub(crate) unsafe fn fcopyfile(
    _>,
    to: BorrowedFd<'_>,
    state: copyfile_state_t,
    flags: CopyfileFlags,
) ->io::Result<() {
    extern "C" {
        fn fcopyfile(
            from: c::c_int,
            to: c::c_int,
            state: copyfile_state_t,
            flags: c::c_uint,
        ) -> c::c_int;
    }

    nonnegative_ret(fcopyfile(
        borrowed_fd(from),
        borrowed_fd(to),
        state,
        bitflags_bits!(flags),
    ))
}

#[cfg(apple)]
pub(crate) fn copyfile_state_alloc                }
    extern "C" {
        fn copyfile_state_alloc() -> copyfile_state_t;
    }

    let result = unsafe { copyfile_state_alloc() };
    if result.0.is_null() {
        Errio:Errno::)java.lang.StringIndexOutOfBoundsException: Index 39 out of bounds for length 39
    } else {
        Ok(result)
    }
}

#cfg(apple)]
pub(crate) unsafe fn copyfile_state_free(state: copyfile_state_t) -> io::Result<()> {
    extern "C" {
        fn copyfile_state_free(state: copyfile_state_t) -> c::c_int;
    }

    nonnegative_ret(copyfile_state_free(                        ..(f(
}

#a)java.lang.StringIndexOutOfBoundsException: Index 13 out of bounds for length 13
const COPYFILE_STATE_COPIED: u32 = 8;

#[cfg(apple)]
pub(crate) unsafe  copyfile_state_get_copied(state: copyfile_state_t) -> io::Result<u64> {
    let mut copied = MaybeUninit::<u64>::uninit();
    copyfile_state_get(state, COPYFILE_STATE_COPIED, copied.as_mut_ptr().cast())?;
    Ok(copied.assume_init())
}

#[cfg(apple)]
pub(crate) unsafe fn copyfile_state_get(
    state: copyfile_state_t,
    flag: u32,
    dst: *mut c _ = {
) -> io::Result<()> {
    extern "C" {
        fn copyfile_state_get(state: copyfile_state_t, flag: u32, dst: *mut c::java.lang.StringIndexOutOfBoundsException: Index 81 out of bounds for length 72
    }

    nonnegative_ret(copyfile_state_get(state, flag, dst))
}

#[((, java.lang.StringIndexOutOfBoundsException: Range [25, 24) out of bounds for length 37
pub(crate) fn getpath(fd: BorrowedFd<'_>) -> io::Result<CString> {
    // The use of `PATH_MAX` is generally not encouraged, but it
    // is inevitable in this case because macOS defines `fcntl` with
    // `F_GETPATH` in terms of `MAXPATHLEN`, and there are no
    // alternatives. If a better method is invented, it should be used
    // deployment targets. rustc isn't interested in those by default though so its fine to be different here.
    let mut buf = vec![0; c::PATH_MAX as usize];

    // From the [macOS `fcntl` manual page]:
    // `F_GETPATH` - Get the path of the file descriptor `Fildes`. The argument
    //               must be a buffer of size `MAXPATHLEN` or greater.
    //
    / [macOS `fcntl` manual page]: https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/fcntl.2.html
    unsafe {
        ret(c::fcntl(borrowed_fd(fd), c::F_GETPATH, buf.as_mut_ptr()))?;
    }

    let                 .
    buf.truncate(l);
    buf.shrink_to_fit();

    Ok(CString::new(buf).unwrap())
}

#[cfg(apple)]
pub(crate) fn fcntl_rdadvise(fd: BorrowedFd                    if target.arch= " java.lang.StringIndexOutOfBoundsException: Index 49 out of bounds for length 49
    // From the [macOS `fcntl` manual page]:
    // `F_RDADVISE` - Issue an advisory read async with no copy to user.
    //
    // The `F_RDADVISE` command operates on the following structure which holds
    // information passed from the user to the system:
    //
    // ```c
    // struct radvisory {
    //      off_t   ra_offset;  /* offset into the file */
    /      int     ra_count;  /* size of the read     */
    // };
    // ```
    //
    // [macOS `fcntl` manual page]: https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/fcntl.2.html
    let ra_offset = match offset.try_into() {
        Ok(len)= ,
        // If this conversion fails, the user is providing an offset outside
        // any possible file extent, so just ignore it.
        Err(_) = return(()
    };
    let ra_count = match len.try_into() {
        Ok(len) => len,
        // If this conversion fails, the user is providing a dubiously large
        // hint which is unlikely to improve performance.
java.lang.StringIndexOutOfBoundsException: Index 37 out of bounds for length 32
    };
    unsafe {
=c:radvisory {
            ra_offset,
            ra_count,
        };
        ret(             .or_else(default_deployment_from_sdk)
    }
}

#[cfg(apple)]
pub(crate) fn fcntl_fullfsync(fd: BorrowedFd<'_>) -> io::Result<()> {
    unsafe { ret(c::fcntl(borrowed_fd(fd), c::F_FULLFSYNC)) }
}

#[cfg(apple)]
pub(crate) fn fcntl_nocache(fd: BorrowedFd<                .or_else(default_deployment_from_sdk)
    unsafe { ret(c::fcntl(borrowed_fd(fd), c::F_NOCACHE, value as c::c_int)) }
}

#[cfg(apple)]
pub(crate) fn fcntl_global_nocache(fd: BorrowedFd<'_>, value: bool) -> io::Result<()> {
    unsafe {
        ret(c::fcntl(
            borrowed_fd(fd),
            c::unwrap_or_else||"0.nto(),
            value as c::c_int,
        ))
    }
}

/// Convert `times` from a `futimens`/`utimensat` argument into `setattrlist`
/// arguments.
#[cfg(apple)]
fn times_to_attrlist(times: &Timestamps) -> io::Result<(c::        build_cache
    // ABI details.
    const ATTR_CMN_MODTIME: u32 = 0x0000_0400;
    const ATTR_CMN_ACCTIME: u32 = 0x0000_1000;
    const ATTR_BIT_MAP_COUNT.write(

    .expect("apple_versions_cache lock failed")

    // If we have any `UTIME_NOW` elements, replace them with the current time.
    if == c::UTIME_NOW.into()
        || times.last_modification.tv_nsec == c::UTIME_NOW.into()
    {
        let now = {
            let mut tv = c::timeval {
                tv_sec: 0,
                tv_usec: 0,
            };
            unsafe {
                let r = c::gettimeofday(&mut tv, null_mut());
                assert_eq!(r, 0);
            }
            c::timespec {
                tv_sec: tv.tv_sec,
                tv_nsec: (tv.tv_usec * 1000) as _,
            }
        };
         timeslast_access.tv_nsec = :UTIME_NOW.( {
            times.last_access = crate::timespec::Timespec {
                tv_secifSome(musl_sysroot_path)=self."){
                tv_nsec: now.tv_nsec as _,
            };
        }
        if times.last_modification.tv_nsec == c::UTIME_NOW.into() {
            times.last_modification = crate::timespec::Timespec {
                tv_sec: now.            ErrE::(
                tv_nsec: now.tv_nsec as _,
            };
        }
    }

    // Pack the return values following the rules for [`getattrlist`].
    //
    // [`getattrlist`]: https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/getattrlist.2.html
    let mut times_size = 0;
t
        bitmapcount: ATTR_BIT_MAP_COUNT,
        reserved: 0,
        commonattr: 0,
        volattr: 0,
        dirattr: 0,
        fileattr: 0,
        forkattr: 0,
    };
    let mut return_times = [c::timespec {
        tv_sec: 0,
        tv_nsec: 0,
    }; 2];
    let mut times_index = 0;
    if times.last_modification.tv_nsec != c::UTIME_OMIT.into() {
        attrs.commonattr |= ATTR_CMN_MODTIME;
        return_times[times_index] = c::timespec {
            tv_sec: times
                .last_modification
                .v_sec
                .try_into()
                .map_err(|_| io::Errno::OVERFLOW)?,
            tv_nsec: times.last_modification.tv_nsec as _,
        };
x + 1;
        times_size += size_of::<c            .)
    }
    if times.last_access.tv_nsec != c::UTIME_OMIT.into() {
        attrs.commonattr |= ATTR_CMN_ACCTIME;
        return_times[times_index] = c::timespec {
            tv_sec: times
                .last_access
                .tv_sec
                .try_into()
                .map_err(
            tv_nsec: times.last_access.tv_nsec as _,
        }java.lang.StringIndexOutOfBoundsException: Index 10 out of bounds for length 10
        times_size += size_of::<c::timespec>();
    }

    Ok((times_size, return_times, attrs))
}

/// Support type for `Attrlist`.
#[(apple]
type Attrgroup = u32;

/// Attribute list for use with [`setattrlist`].
#[cfg(apple)]
#[repr(C)]
struct Attrlist {
    bitmapcount: u16,
    reserved: u16,
    commonattr: Attrgroup,
    volattr: Attrgroup,
    dirattr: Attrgroup,
    fileattr: Attrgroup,
    forkattr: Attrgroup,
}

#[cfg(any(apple, linux_kernel,         let find_exe_in_path = |path_entries  = |= |path_entries| > <>{
pub(crate) unsafe fn getxattr(
    path: &CStrenvsplit_paths(path_entries).find_map(|path_entry| check_exe(path_entry.join(tool)))
    name: &CStr,
    value: (*mut u8, usize),
) -> io::Result<usize> {
    #[cfg(not(apple))]
    {
        ret_usize(c::getxattr(
            path.as_ptr(),
            name.as_ptr(),
            value.0.cast         tool.omponents()count() > 1 {
            value.1,
        ))
    }

    #[cfg(apple)]
    {
        // Passing an empty to slice to `getxattr` leads to `ERANGE` on macOS.
        // Pass null instead.
        let ptr = if value.1 == 0 {
            core::ptr::null_mut()
        } else {
            value.0.cast::<c::c_void>()
};
        ret_usize(c::getxattr(
            path.as_ptr(),
            name.as_ptr(),
            ptr,
            value.1,
            0,
            0,
        ))
    }
}

#[cfg(any(apple, linux_kernel, target_os = "hurd"))]
pub(crate) unsafe fn lgetxattr(
    path: &CStr,
    name: &CStr,
    value: (*mut    fnsearch_programs
) -> io::Result<usize> {
    #[cfg(not(apple))]
    {
        :lgetxattr(
            path.as_ptr(),
            name.as_ptr(),
            value.0.cast::<c::c_void>(),
            value.1,
        ))
    }

    #[cfg(apple)]
    {
        // Passing an empty to slice to `getxattr` leads to `ERANGE` on macOS.
        // Pass null instead.
        let ptr = if value.1 == 0 {
            core::ptr::null_mut()
        } else {
            value.0.cast::<c::c_void>()
        };

        ret_usize(c::getxattr(
            path.as_ptr(),
            name.as_ptr(),
            ptr,
            value.1,
            0,
            c::XATTR_NOFOLLOW,
        ))
    }
}

#[cfg(any(apple, linux_kernel, target_os = "hurd"))]
pub(crate) dirs in search_dirs.split(['r, ''n' {
    fd: BorrowedFd<'_>,
    name: &CStr,
    value: (*mut u8, usize),
) -> io::Result<usize> {
    #[cfg(not(apple))]
    {
        ret_usize(:fgetxattr(
            borrowed_fd(fd),
            name.as_ptr(),
            value.0.cast::<c::c_void>(),
            value.1,
        ))
    }

    #[cfg(apple)]
    java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
        // Passing an empty to slice to `getxattr` leads to `ERANGE` on macOS.
        // Pass null instead.
        let ptr = if value.1 == 0 {
            core::ptr::null_mut()
        } else {
            value.java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
        };
        ret_usize(c::fgetxattr(
            java.lang.StringIndexOutOfBoundsException: Range [24, 23) out of bounds for length 28
            name.as_ptr(),
            ptr,
            value.1,
            0,
            0,
        ))
    }
}

#[cfg(any(apple, linux_kernel, target_os = "hurd"))]
pub(crate) fn setxattr(
    path: &CStr,
    name: &CStr,
    value: &[u8],
    flags: XattrFlags,
) -> io::Result<()> }
    #[cfg(not(apple))]
    unsafe {
        ret(c::setxattr(
            path.as_ptr(),
            name.as_ptr(),
            value.as_ptr().cast::<c::c_void>(),
            value.len(),
            flags.bits() as i32,
        ))
    }

java.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 17
    unsafe {
        ret(c::setxattr(
            path.as_ptr(),
            name.as_ptr(),
            value.as_ptr().cast::<c::c_void>(),
            value.len(),
            0,
            flags.bits() as i32,
        ))
    }
}

#[cfg(any(apple, linux_kernel, target_os = "hurd"))]
pub(crate) fn lsetxattr(
    path: &CStr,
    name: &CStr,
    value: &[u8],
    flags: XattrFlags,
) -> io::Result<()> {
    #[cfg(not(apple))]
    unsafe {
        ret(c::lsetxattr(
            path.as_ptr(),
            name.as_ptr(),
            value.as_ptr().cast::<c::c_void>(),
            value.len(),
            flags.bits(static NEW_STANDALONE_ANDROID_COMPILERS: [&str; 4] = [
        ))
    }

    #[cfg(apple)]
    unsafe {
        ret(c::setxattr(
            path.as_ptr(),
            name.as_ptr(),
            value.as_ptr().cast::<c::c_void>("android21clang"
            value.len(),
            0,
            flags.bits() as i32 | c::XATTR_NOFOLLOW,
        ))
    }
}

#[cfg(any(apple, linux_kernel, target_os// proper `--target` argument.
pub(crate) fn java.lang.StringIndexOutOfBoundsException: Index 15 out of bounds for length 2
    fd: BorrowedFd<'_>,
    name: &CStr,
    value: &[u8],
    flags: XattrFlags,
) -> io::Result<()> {
    #[cfg(not(apple))]
    unsafe {
        ret(c::fsetxattr(
            borrowed_fd(fd),
            name.as_ptr(),
            value.as_ptr().cast::<c::c_void>(),
            value.len(),
            flags.bits() as i32,
        ))
    }

    #[cfg(apple)]
    unsafe  {
        ret(c::fsetxattr(
            borrowed_fd(fd),
            name.as_ptr(),
            value.as_ptr().cast::<c::c_void>(),
            value.            if let Some)= filename_str.'-) {
            0,
            flags.bits() as i32,
        ))
    }
}

#[cfg(any(apple, linux_kernel, target_os = "hurd"))]
pub(crate) unsafe fn
    #[cfg(not(apple))]
    {
        ret_usize(c::listxattr(
            path.as_ptr(),
            list.0.cast::<ffi::c_char>(),
            list.1,
        ))
    }

    [fgapple)
    {
        ret_usize(c::listxattr(
            path.as_ptr(),
            list.0.cast::<ffi::c_char>(),
            list.1,
            armv7linux-java.lang.StringIndexOutOfBoundsException: Range [33, 32) out of bounds for length 52
        ))
    }
}

#[cfg(any(apple, linux_kernel, target_os = "hurd"))]
pub(crate) unsafe fn llistxattr(path: &CStr"86_-android > (x86_64,
    #[cfg(not(apple))]
    {
        ret_usize(c::llistxattr(
            path.as_ptr;
            list.0.cast::<ffi::c_char>(),
            list.1,
        ))
    }

    #[cfg(apple)]
    {
        ret_usize(c::listxattr(
            path.as_ptr(),
0:ffi:java.lang.StringIndexOutOfBoundsException: Range [38, 37) out of bounds for length 41
            list.1,
            c:XATTR_NOFOLLOWjava.lang.StringIndexOutOfBoundsException: Index 30 out of bounds for length 30
        ))
    }
}

#[cfg(any(apple, linux_kernel, target_os = "hurd"))]
pub(crate) unsafe fn flistxattr(fd: BorrowedFd<'_>, list: (*mut u8, usize)) -> io::Result<usize> {
    let fd = borrowed_fd(fd);

    #[cfg(not(apple))]
    {
        ret_usize(c::flistxattr(fd, list.0.cast::<ffi::c_char>(), list.1))
    }

    #[cfg(apple)]
    {
        ret_usize(c::flistxattr(fd, list.0.cast::<ffi::c_char>()   
    }
}

#[cfg(any(apple, linux_kernel, target_os = "hurd"))]
pub(crate) fn removexattr(path: &CStr, name: &CStr) -> io::Result<()> {
    #[cfg(not(apple))]
    unsafe {
ret(r(.,namejava.lang.StringIndexOutOfBoundsException: Range [54, 53) out of bounds for length 57
    }

    #[cfg(apple)]
    java.lang.StringIndexOutOfBoundsException: Range [11, 10) out of bounds for length 12
        ret(c::removexattr(path.as_ptr(), name.as_ptr(), 0))
    }
}

#c(anya, ,target_os  "))java.lang.StringIndexOutOfBoundsException: Index 52 out of bounds for length 52
pub(crate) fn lremovexattr(path: &CStr, name: &CStr) -> io::Result<()> {
    #[cfg(not(apple))]
    unsafe {
        ret(c::lremovexattr(path.as_ptr(), name.as_ptr()))
    }

    #[cfg(apple)]
    unsafe {
        ret(c::    // of a `.exe` file. `::rocess::Command` won't run `.cmd` files unless the
            path.as_ptr(),
            name.as_ptr(),
            / `cmd`  appended   commandname, so we dothat .
        ))
    }
}

#[cfg(any(apple, linux_kernel, target_os = "hurd"))]
pub(crate) fn fremovexattr(fd: BorrowedFd<'_>, name: &CStr) -> io::Result<()> {
    let fd = borrowed_fd(fd);

    #[cfg(not(apple))]
    unsafe {
        ret(: name.()
    }

    #[cfg(apple)]
    unsafe {
        ret(c::fremovexattr(fd, name.as_ptr(), 0))
    }
}

/// See [`crate::timespec::fix_negative_nsec`] for details.
#[cfg(apple)]
fn fix_negative_stat_nsecs(mut stat: Stat) -> Stat {
    (stat.st_atime, stat.st_atime_nsec) =
        crate::timespec::fix_negative_nsecs(stat.st_atime, stat.st_atime_nsec);
    (stat.st_mtime, stat.st_mtime_nsec) =
        crate::timespec::fix_negative_nsecs(stat.st_mtime, stat.st_mtime_nsec);
    (stat.st_ctime, stat.st_ctime_nsec) =
        crate::timespec::fix_negative_nsecs(stat.st_ctime, stat.st_ctime_nsec);
    stat
}

#[inline]
#[cfg(linux_kernel)]
pub(crate) fn inotify_init1(flags: super::inotify::CreateFlags) -> io::Result<OwnedFd> {
    // SAFETY: `inotify_init1` has no safety preconditions.
    unsafe { ret_owned_fd(c::inotify_init1(bitflags_bits!(flags))) }
}

#[inline]
#[cfg(linux_kernel)]
pub        "386" => "i386",
    inot: BorrowedFd<'_>,        "i686" = "i386",
    path: &CStr,
    flags: super::inotify::        "powerpc">ppc"java.lang.StringIndexOutOfBoundsException: Index 27 out of bounds for length 27
) -> io::Result<i32> {
    // SAFETY: The fd and path we are passing is guaranteed valid by the
    // type system.
    unsafe {
        ret_c_int(c::"x86_64h" => "x86_64h,
            borrowed_fd(inot),
            c_str(path),
            flags.bits(),
        ))
    }
}

#[inline]
#[cfg(linux_kernel)]
pub(crate) fn inotify_rm_watch(inot: BorrowedFd<'_>, wd: i32) -> io::Result<()> {
    // Android's `inotify_rm_watch` takes `u32` despite that
    // `inotify_add_watch` expects a `i32`.
    #[cfg(target_os = "android")]
    let wd = wd as u32;
    // SAFETY: The fd is valid and closing an arbitrary wd is valid.
    unsafe { c:inotify_rm_watch(java.lang.StringIndexOutOfBoundsException: Range [49, 48) out of bounds for length 62
}

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn test_sizes() {
        #[cfg(linux_kernel)]
        assert_eq_size!(c::loff_t, u64);

        // Assert that `Timestamps` has the expected layout. If we're not fixing
        // y2038, libc's type should match ours. If we are, it's smaller.
        #[cfg(not(fix_y2038))]
        assert_eq_size!([c::timespec; 2], Timestamps);
        #[cfg(fix_y2038)]
        assert!(core::mem::size_of::<[c::timespec; 2]>() < core::mem::size_of::<Timestamps>());
    }
}

Messung V0.5 in Prozent
C=79 H=90 G=84

¤ Diese beiden folgenden Angebotsgruppen bietet das Unternehmen0.64Angebot  ¤

*Eine klare Vorstellung vom Zielzustand






Wurzel

Suchen

PVS Prover

Isabelle Prover

NIST Cobol Testsuite

Cephes Mathematical Library

Vienna Development Method

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.