MCPcopy Index your code
hub / github.com/RustPython/RustPython / getgroups_impl

Function getgroups_impl

crates/vm/src/stdlib/posix.rs:439–456  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

437
438 #[cfg(any(target_os = "macos", target_os = "ios"))]
439 fn getgroups_impl() -> nix::Result<Vec<Gid>> {
440 use core::ptr;
441 use libc::{c_int, gid_t};
442
443 let ret = unsafe { libc::getgroups(0, ptr::null_mut()) };
444 let mut groups = Vec::<Gid>::with_capacity(Errno::result(ret)? as usize);
445 let ret = unsafe {
446 libc::getgroups(
447 groups.capacity() as c_int,
448 groups.as_mut_ptr() as *mut gid_t,
449 )
450 };
451
452 Errno::result(ret).map(|s| {
453 unsafe { groups.set_len(s as usize) };
454 groups
455 })
456 }
457
458 #[cfg(not(any(target_os = "macos", target_os = "ios", target_os = "redox")))]
459 use nix::unistd::getgroups as getgroups_impl;

Callers 2

get_right_permissionFunction · 0.85
getgroupsFunction · 0.85

Calls 6

getgroupsFunction · 0.85
as_mut_ptrMethod · 0.80
set_lenMethod · 0.80
ErrClass · 0.50
capacityMethod · 0.45
mapMethod · 0.45

Tested by

no test coverage detected