1b8a62b91Sopenharmony_ci//! The Linux `userfaultfd` API.
2b8a62b91Sopenharmony_ci//!
3b8a62b91Sopenharmony_ci//! # Safety
4b8a62b91Sopenharmony_ci//!
5b8a62b91Sopenharmony_ci//! Calling `userfaultfd` is safe, but the returned file descriptor lets users
6b8a62b91Sopenharmony_ci//! observe and manipulate process memory in magical ways.
7b8a62b91Sopenharmony_ci#![allow(unsafe_code)]
8b8a62b91Sopenharmony_ci
9b8a62b91Sopenharmony_ciuse crate::fd::OwnedFd;
10b8a62b91Sopenharmony_ciuse crate::{backend, io};
11b8a62b91Sopenharmony_ci
12b8a62b91Sopenharmony_cipub use backend::mm::types::UserfaultfdFlags;
13b8a62b91Sopenharmony_ci
14b8a62b91Sopenharmony_ci/// `userfaultfd(flags)`
15b8a62b91Sopenharmony_ci///
16b8a62b91Sopenharmony_ci/// # Safety
17b8a62b91Sopenharmony_ci///
18b8a62b91Sopenharmony_ci/// The call itself is safe, but the returned file descriptor lets users
19b8a62b91Sopenharmony_ci/// observe and manipulate process memory in magical ways.
20b8a62b91Sopenharmony_ci///
21b8a62b91Sopenharmony_ci/// # References
22b8a62b91Sopenharmony_ci///  - [Linux]
23b8a62b91Sopenharmony_ci///  - [Linux userfaultfd]
24b8a62b91Sopenharmony_ci///
25b8a62b91Sopenharmony_ci/// [Linux]: https://man7.org/linux/man-pages/man2/userfaultfd.2.html
26b8a62b91Sopenharmony_ci/// [Linux userfaultfd]: https://www.kernel.org/doc/Documentation/vm/userfaultfd.txt
27b8a62b91Sopenharmony_ci#[inline]
28b8a62b91Sopenharmony_cipub unsafe fn userfaultfd(flags: UserfaultfdFlags) -> io::Result<OwnedFd> {
29b8a62b91Sopenharmony_ci    backend::mm::syscalls::userfaultfd(flags)
30b8a62b91Sopenharmony_ci}
31