diff --git a/src/dox.rs b/src/dox.rs index 6a1b6883df15edcb5f3079983e0dc89173e11406..5c095b9c76ad8c13e645903333f64563a7d4b1e8 100644 --- a/src/dox.rs +++ b/src/dox.rs @@ -146,5 +146,6 @@ mod imp { pub mod mem { pub fn size_of_val<T>(_: &T) -> usize { 4 } + pub fn size_of<T>(_: &T) -> usize { 4 } } } diff --git a/src/unix/bsd/freebsdlike/mod.rs b/src/unix/bsd/freebsdlike/mod.rs index 54f3345e5dd2a8b6f6b352b41c62b2ac13c2375a..b9a421eade8b506f59d9836f363a8f768229b138 100644 --- a/src/unix/bsd/freebsdlike/mod.rs +++ b/src/unix/bsd/freebsdlike/mod.rs @@ -175,6 +175,15 @@ s! { pub sdl_slen: ::c_uchar, pub sdl_data: [::c_char; 46] } + + pub struct cmsgcred { + pub cmcred_pid: ::pid_t, + pub cmcred_uid: ::uid_t, + pub cmcred_euid: ::uid_t, + pub cmcred_gid: ::gid_t, + pub cmcred_ngroups: ::c_short, + pub cmcred_groups: [::gid_t; CMGROUP_MAX] + } } pub const AIO_LISTIO_MAX: ::c_int = 16; @@ -950,6 +959,8 @@ pub const OCRNL: ::tcflag_t = 0x10; pub const ONOCR: ::tcflag_t = 0x20; pub const ONLRET: ::tcflag_t = 0x40; +pub const CMGROUP_MAX: usize = 16; + f! { pub fn WIFCONTINUED(status: ::c_int) -> bool { status == 0x13 diff --git a/src/unix/bsd/netbsdlike/netbsd/mod.rs b/src/unix/bsd/netbsdlike/netbsd/mod.rs index b56fea533b3e11371423a9cef14fd29a4f958e7e..45b728209b13c4e3a83c02ab83b0deecec17435c 100644 --- a/src/unix/bsd/netbsdlike/netbsd/mod.rs +++ b/src/unix/bsd/netbsdlike/netbsd/mod.rs @@ -1,3 +1,5 @@ +use dox::mem; + pub type clock_t = ::c_uint; pub type suseconds_t = ::c_int; pub type dev_t = u64; @@ -281,6 +283,16 @@ s! { pub ifm_index: ::c_ushort, pub ifm_data: if_data, } + + pub struct sockcred { + 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 const AT_FDCWD: ::c_int = -100; @@ -910,12 +922,21 @@ pub const SOCK_NONBLOCK: ::c_int = 0x20000000; // http://cvsweb.netbsd.org/bsdweb.cgi/src/include/dirent.h?rev=1.36 f! { pub fn dirfd(dirp: *mut ::DIR) -> ::c_int { - unsafe { *(dirp as *const ::c_int) } + *(dirp as *const ::c_int) } pub fn WIFCONTINUED(status: ::c_int) -> bool { status == 0xffff } + + 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 + } } extern { diff --git a/src/unix/notbsd/linux/mod.rs b/src/unix/notbsd/linux/mod.rs index 46cf538f17d0e0443207798dc270d8e0cbbb508e..2b90cff306404d3739392e1c0dca0a489f327c7f 100644 --- a/src/unix/notbsd/linux/mod.rs +++ b/src/unix/notbsd/linux/mod.rs @@ -448,6 +448,12 @@ s! { pub p_memsz: Elf64_Xword, pub p_align: Elf64_Xword, } + + pub struct ucred { + pub pid: ::pid_t, + pub uid: ::uid_t, + pub gid: ::gid_t, + } } pub const ABDAY_1: ::nl_item = 0x20000; diff --git a/src/unix/notbsd/linux/musl/mod.rs b/src/unix/notbsd/linux/musl/mod.rs index 30e8e51d9f116630e96db4167a6b51fb6f53c282..7513aaed6724224fbc4b7a5fccae8ead3e5c8460 100644 --- a/src/unix/notbsd/linux/musl/mod.rs +++ b/src/unix/notbsd/linux/musl/mod.rs @@ -75,12 +75,6 @@ s! { pub mem_unit: ::c_uint, pub __reserved: [::c_char; 256], } - - pub struct ucred { - pub pid: ::pid_t, - pub uid: ::uid_t, - pub gid: ::gid_t, - } } pub const SFD_CLOEXEC: ::c_int = 0x080000; diff --git a/src/unix/notbsd/linux/other/mod.rs b/src/unix/notbsd/linux/other/mod.rs index ad54ecf571bb2776bb494f6d992cbe12e475f22c..c256d5f498fb35194424f61276e47e8dd9db35a4 100644 --- a/src/unix/notbsd/linux/other/mod.rs +++ b/src/unix/notbsd/linux/other/mod.rs @@ -104,12 +104,6 @@ s! { __unused5: *mut ::c_void, } - pub struct ucred { - pub pid: ::pid_t, - pub uid: ::uid_t, - pub gid: ::gid_t, - } - pub struct statfs { pub f_type: __fsword_t, pub f_bsize: __fsword_t, diff --git a/src/unix/notbsd/linux/s390x.rs b/src/unix/notbsd/linux/s390x.rs index aef8825994f8d363a4585aa9e29ab9007e2e9421..d7ed38368c9762a8549c4d1926c755088c45b3b1 100644 --- a/src/unix/notbsd/linux/s390x.rs +++ b/src/unix/notbsd/linux/s390x.rs @@ -221,12 +221,6 @@ s! { __unused5: *mut ::c_void, } - pub struct ucred { - pub pid: ::pid_t, - pub uid: ::uid_t, - pub gid: ::gid_t, - } - pub struct flock { pub l_type: ::c_short, pub l_whence: ::c_short,