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 | /// 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 ] |
14 | pub 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: &CStr| { |
22 | backend::fs::syscalls::openat2(dirfd.as_fd(), path, flags:oflags, mode, resolve) |
23 | }) |
24 | } |
25 | |