rustix/fs/
openat2.rs

1use crate::fd::OwnedFd;
2use crate::{backend, io, path};
3use backend::fd::AsFd;
4use backend::fs::types::{Mode, OFlags, ResolveFlags};
5
6/// `openat2(dirfd, path, OpenHow { oflags, mode, resolve }, sizeof(OpenHow))`—
7/// Opens a file with more options.
8///
9/// # References
10///  - [Linux]
11///
12/// [Linux]: https://man7.org/linux/man-pages/man2/openat2.2.html
13#[inline]
14pub fn openat2<Fd: AsFd, P: path::Arg>(
15    dirfd: Fd,
16    path: P,
17    oflags: OFlags,
18    mode: Mode,
19    resolve: ResolveFlags,
20) -> io::Result<OwnedFd> {
21    path.into_with_c_str(|path| {
22        backend::fs::syscalls::openat2(dirfd.as_fd(), path, oflags, mode, resolve)
23    })
24}