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