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///
8/// # References
9///  - [Linux]
10///
11/// [Linux]: https://man7.org/linux/man-pages/man2/openat2.2.html
12#[inline]
13pub fn openat2<Fd: AsFd, P: path::Arg>(
14    dirfd: Fd,
15    path: P,
16    oflags: OFlags,
17    mode: Mode,
18    resolve: ResolveFlags,
19) -> io::Result<OwnedFd> {
20    path.into_with_c_str(|path| {
21        backend::fs::syscalls::openat2(dirfd.as_fd(), path, oflags, mode, resolve)
22    })
23}