Struct userfaultfd::UffdBuilder [−][src]
pub struct UffdBuilder { /* fields omitted */ }
Expand description
A builder for initializing Uffd
objects.
use userfaultfd::UffdBuilder;
let uffd = UffdBuilder::new()
.close_on_exec(true)
.non_blocking(true)
.user_mode_only(true)
.create();
assert!(uffd.is_ok());
Implementations
Create a new builder with no required features or ioctls, close_on_exec
and
non_blocking
both set to false
, and user_mode_only
set to true
.
Enable the close-on-exec flag for the new userfaultfd object (see the description of
O_CLOEXEC
in open(2)
).
Enable non-blocking operation for the userfaultfd object.
If this is set to false
, Uffd::read_event()
will block until an event is available to
read. Otherwise, it will immediately return None
if no event is available.
Enable user-mode only flag for the userfaultfd object.
If set to false
, the process must have the CAP_SYS_PTRACE
capability starting with Linux 5.11
or object creation will fail with EPERM. When set to true
, userfaultfd can’t be used
to handle kernel-mode page faults such as when kernel tries copying data to userspace.
When used with kernels older than 5.11, this has no effect; the process doesn’t need
CAP_SYS_PTRACE
and can handle kernel-mode page faults.
Add a requirement that a particular feature or set of features is available.
If a required feature is unavailable, UffdBuilder.create()
will return an error.
Add a requirement that a particular ioctl or set of ioctls is available.
If a required ioctl is unavailable, UffdBuilder.create()
will return an error.