Skip to content

Commit

Permalink
freebsd: add sockcred/SOCKCREDSIZE
Browse files Browse the repository at this point in the history
Like on NetBSD, but without a pid field in the struct.
  • Loading branch information
valpackett committed Apr 15, 2020
1 parent e687a59 commit d8764e8
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/unix/bsd/freebsdlike/freebsd/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,15 @@ s! {
pub msg_hdr: ::msghdr,
pub msg_len: ::ssize_t,
}

pub struct sockcred {
pub sc_uid: ::uid_t,
pub sc_euid: ::uid_t,
pub sc_gid: ::gid_t,
pub sc_egid: ::gid_t,
pub sc_ngroups: ::c_int,
pub sc_groups: [::gid_t; 1],
}
}

s_no_extra_traits! {
Expand Down Expand Up @@ -1136,6 +1145,15 @@ f! {
as ::c_uint
}

pub fn SOCKCREDSIZE(ngrps: usize) -> usize {
let ngrps = if ngrps > 0 {
ngrps - 1
} else {
0
};
::mem::size_of::<sockcred>() + ::mem::size_of::<::gid_t>() * ngrps
}

pub fn uname(buf: *mut ::utsname) -> ::c_int {
__xuname(256, buf as *mut ::c_void)
}
Expand Down

0 comments on commit d8764e8

Please sign in to comment.