MCPcopy Create free account
hub / github.com/bytecodealliance/rustix / configure_capability_in_ambient_set

Function configure_capability_in_ambient_set

src/thread/prctl.rs:739–763  ·  view source on GitHub ↗
(
    capability: impl CompatCapability,
    enable: bool,
)

Source from the content-addressed store, hash-verified

737/// [`prctl(PR_CAP_AMBIENT,…)`]: https://man7.org/linux/man-pages/man2/prctl.2.html
738#[inline]
739pub fn configure_capability_in_ambient_set(
740 capability: impl CompatCapability,
741 enable: bool,
742) -> io::Result<()> {
743 let sub_operation = if enable {
744 PR_CAP_AMBIENT_RAISE
745 } else {
746 PR_CAP_AMBIENT_LOWER
747 };
748 let capset = capability.as_capability_set(private::Token).bits();
749 if capset.count_ones() != 1 {
750 return Err(Errno::INVAL);
751 }
752 let cap = capset.trailing_zeros();
753
754 unsafe {
755 prctl_3args(
756 PR_CAP_AMBIENT,
757 sub_operation as *mut _,
758 // as *mut _ should be ptr::without_provenance_mut but our MSRV does not allow it.
759 cap as usize as *mut _,
760 )
761 }
762 .map(|_r| ())
763}
764
765//
766// PR_SVE_GET_VL/PR_SVE_SET_VL

Callers

nothing calls this directly

Calls 2

prctl_3argsFunction · 0.85
as_capability_setMethod · 0.80

Tested by

no test coverage detected