Function safe_openat2

Source
fn safe_openat2<D: AsRawDescriptor>(
    dir: &D,
    name: &CStr,
    flags: c_int,
    mode: Option<mode_t>,
    resolve: u64,
) -> Result<File>
Expand description

A safe wrapper around openat2 with a fallback to openat64 for backward compatibility.

It attempts to use openat2 to leverage secure path resolution flags (like RESOLVE_IN_ROOT). If openat2 is not supported by the kernel (returns ENOSYS, e.g. on kernels older than 5.6), it falls back to standard path resolution using openat64 to allow operation on older platforms.