Skip to content

Commit d8764e8

Browse files
committed
freebsd: add sockcred/SOCKCREDSIZE
Like on NetBSD, but without a pid field in the struct.
1 parent e687a59 commit d8764e8

File tree

1 file changed

+18
-0
lines changed
  • src/unix/bsd/freebsdlike/freebsd

1 file changed

+18
-0
lines changed

src/unix/bsd/freebsdlike/freebsd/mod.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,15 @@ s! {
107107
pub msg_hdr: ::msghdr,
108108
pub msg_len: ::ssize_t,
109109
}
110+
111+
pub struct sockcred {
112+
pub sc_uid: ::uid_t,
113+
pub sc_euid: ::uid_t,
114+
pub sc_gid: ::gid_t,
115+
pub sc_egid: ::gid_t,
116+
pub sc_ngroups: ::c_int,
117+
pub sc_groups: [::gid_t; 1],
118+
}
110119
}
111120

112121
s_no_extra_traits! {
@@ -1136,6 +1145,15 @@ f! {
11361145
as ::c_uint
11371146
}
11381147

1148+
pub fn SOCKCREDSIZE(ngrps: usize) -> usize {
1149+
let ngrps = if ngrps > 0 {
1150+
ngrps - 1
1151+
} else {
1152+
0
1153+
};
1154+
::mem::size_of::<sockcred>() + ::mem::size_of::<::gid_t>() * ngrps
1155+
}
1156+
11391157
pub fn uname(buf: *mut ::utsname) -> ::c_int {
11401158
__xuname(256, buf as *mut ::c_void)
11411159
}

0 commit comments

Comments
 (0)