1 | use crate::fd::OwnedFd; |
2 | use crate::{backend, io, path}; |
3 | use backend::fd::AsFd; |
4 | use 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 ] |
13 | pub 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: &CStr| { |
21 | backend::fs::syscalls::openat2(dirfd:dirfd.as_fd(), pathname:path, flags:oflags, mode, resolve) |
22 | }) |
23 | } |
24 | |