Skip to content

Commit

Permalink
Auto merge of #2589 - devnexen:sockcred2_fbsd_fix_proposal, r=Amanieu
Browse files Browse the repository at this point in the history
freebsd proposal to move sockcred2 usage in the root mod while ignori…

…ng it for FreeBSD 12.
  • Loading branch information
bors committed Dec 12, 2021
2 parents f42fe9a + da089ce commit 18bfd17
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 44 deletions.
6 changes: 6 additions & 0 deletions libc-test/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2196,6 +2196,9 @@ fn test_freebsd(target: &str) {
// `ptrace_coredump` introduced in FreeBSD 14.
"ptrace_coredump" if Some(14) > freebsd_ver => true,

// `sockcred2` is not available in FreeBSD 12.
"sockcred2" if Some(13) > freebsd_ver => true,

_ => false,
}
});
Expand Down Expand Up @@ -2233,6 +2236,9 @@ fn test_freebsd(target: &str) {
true
}

// This is not available in FreeBSD 12.
"SOCKCRED2SIZE" if Some(13) > freebsd_ver => true,

_ => false,
}
});
Expand Down
22 changes: 0 additions & 22 deletions src/unix/bsd/freebsdlike/freebsd/freebsd13/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,6 @@ s! {
pub ext: [u64; 4],
}

pub struct sockcred2 {
pub sc_version: ::c_int,
pub sc_pid: ::pid_t,
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],
}

pub struct kvm_page {
pub kp_version: ::u_int,
pub kp_paddr: ::kpaddr_t,
Expand Down Expand Up @@ -479,17 +468,6 @@ pub const DOMAINSET_POLICY_INTERLEAVE: ::c_int = 4;

pub const MINCORE_SUPER: ::c_int = 0x20;

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

extern "C" {
pub fn aio_readv(aiocbp: *mut ::aiocb) -> ::c_int;
pub fn aio_writev(aiocbp: *mut ::aiocb) -> ::c_int;
Expand Down
22 changes: 0 additions & 22 deletions src/unix/bsd/freebsdlike/freebsd/freebsd14/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,6 @@ s! {
pub ext: [u64; 4],
}

pub struct sockcred2 {
pub sc_version: ::c_int,
pub sc_pid: ::pid_t,
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],
}

pub struct kvm_page {
pub kp_version: ::u_int,
pub kp_paddr: ::kpaddr_t,
Expand Down Expand Up @@ -479,17 +468,6 @@ pub const DOMAINSET_POLICY_INTERLEAVE: ::c_int = 4;

pub const MINCORE_SUPER: ::c_int = 0x60;

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

extern "C" {
pub fn aio_readv(aiocbp: *mut ::aiocb) -> ::c_int;
pub fn aio_writev(aiocbp: *mut ::aiocb) -> ::c_int;
Expand Down
20 changes: 20 additions & 0 deletions src/unix/bsd/freebsdlike/freebsd/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -945,6 +945,17 @@ s! {
pub generation: ::c_long,
pub numdevs: ::c_int,
}

pub struct sockcred2 {
pub sc_version: ::c_int,
pub sc_pid: ::pid_t,
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 @@ -3701,6 +3712,15 @@ f! {
let (idx, offset) = (cpu / bitset_bits, cpu % bitset_bits);
0 != cpuset.__bits[idx] & (1 << offset)
}

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

safe_f! {
Expand Down

0 comments on commit 18bfd17

Please sign in to comment.