Auto merge of #1196 - asomers:uname_freebsd, r=alexcrichton

Fix uname on FreeBSD

On FreeBSD, uname is an inline function.  The uname that is present in
libc.so is for FreeBSD 1.0 compatibility.  It expects a buffer of a
different size.

Fixes #1190
Reported-by: Alex Zepeda
This commit is contained in:
bors 2019-01-03 20:30:55 +00:00
commit 22b08f8eed
11 changed files with 16 additions and 1 deletions

View File

@ -2659,6 +2659,7 @@ extern {
fd: ::c_int,
newfd: ::c_int,
) -> ::c_int;
pub fn uname(buf: *mut ::utsname) -> ::c_int;
}
cfg_if! {

View File

@ -801,4 +801,5 @@ extern {
pub fn statfs(path: *const ::c_char, buf: *mut statfs) -> ::c_int;
pub fn fstatfs(fd: ::c_int, buf: *mut statfs) -> ::c_int;
pub fn uname(buf: *mut ::utsname) -> ::c_int;
}

View File

@ -949,6 +949,12 @@ pub const UF_READONLY: ::c_ulong = 0x00001000;
pub const UF_HIDDEN: ::c_ulong = 0x00008000;
pub const SF_SNAPSHOT: ::c_ulong = 0x00200000;
f! {
pub fn uname(buf: *mut ::utsname) -> ::c_int {
__xuname(256, buf as *mut ::c_void)
}
}
extern {
pub fn __error() -> *mut ::c_int;
@ -1135,6 +1141,7 @@ extern {
pub fn fstatfs(fd: ::c_int, buf: *mut statfs) -> ::c_int;
pub fn dup3(src: ::c_int, dst: ::c_int, flags: ::c_int) -> ::c_int;
pub fn __xuname(nmln: ::c_int, buf: *mut ::c_void) -> ::c_int;
}
#[link(name = "util")]

View File

@ -676,6 +676,7 @@ extern {
-> ::c_int;
pub fn getdomainname(name: *mut ::c_char, len: ::size_t) -> ::c_int;
pub fn setdomainname(name: *const ::c_char, len: ::size_t) -> ::c_int;
pub fn uname(buf: *mut ::utsname) -> ::c_int;
}
cfg_if! {

View File

@ -1242,6 +1242,7 @@ extern {
termp: *mut termios,
winp: *mut ::winsize) -> ::pid_t;
pub fn sethostname(name: *const ::c_char, len: ::size_t) -> ::c_int;
pub fn uname(buf: *mut ::utsname) -> ::c_int;
}
cfg_if! {

View File

@ -727,6 +727,7 @@ extern {
-> ::c_int;
pub fn setgroups(ngroups: ::c_int, grouplist: *const ::gid_t) -> ::c_int;
pub fn uname(buf: *mut ::utsname) -> ::c_int;
}
cfg_if! {

View File

@ -972,7 +972,6 @@ extern {
#[cfg_attr(target_os = "freebsd", link_name = "mknod@FBSD_1.0")]
pub fn mknod(pathname: *const ::c_char, mode: ::mode_t,
dev: ::dev_t) -> ::c_int;
pub fn uname(buf: *mut ::utsname) -> ::c_int;
pub fn gethostname(name: *mut ::c_char, len: ::size_t) -> ::c_int;
pub fn getservbyname(name: *const ::c_char,
proto: *const ::c_char) -> *mut servent;

View File

@ -728,6 +728,7 @@ extern {
link_name = "popen$UNIX2003")]
pub fn popen(command: *const c_char,
mode: *const c_char) -> *mut ::FILE;
pub fn uname(buf: *mut ::utsname) -> ::c_int;
}
cfg_if! {

View File

@ -1242,6 +1242,7 @@ extern {
flags: ::c_int) -> ::ssize_t;
pub fn recvmsg(fd: ::c_int, msg: *mut ::msghdr, flags: ::c_int)
-> ::ssize_t;
pub fn uname(buf: *mut ::utsname) -> ::c_int;
}
cfg_if! {

View File

@ -1466,4 +1466,5 @@ extern {
mode: *const c_char) -> *mut ::FILE;
pub fn dup3(src: ::c_int, dst: ::c_int, flags: ::c_int) -> ::c_int;
pub fn uname(buf: *mut ::utsname) -> ::c_int;
}

View File

@ -1953,6 +1953,7 @@ extern {
link_name = "popen$UNIX2003")]
pub fn popen(command: *const c_char,
mode: *const c_char) -> *mut ::FILE;
pub fn uname(buf: *mut ::utsname) -> ::c_int;
}
cfg_if! {