Skip to content

Commit 22b08f8

Browse files
committed
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
2 parents a9e3cc6 + 36baf93 commit 22b08f8

File tree

11 files changed

+16
-1
lines changed

11 files changed

+16
-1
lines changed

src/unix/bsd/apple/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2659,6 +2659,7 @@ extern {
26592659
fd: ::c_int,
26602660
newfd: ::c_int,
26612661
) -> ::c_int;
2662+
pub fn uname(buf: *mut ::utsname) -> ::c_int;
26622663
}
26632664

26642665
cfg_if! {

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -801,4 +801,5 @@ extern {
801801

802802
pub fn statfs(path: *const ::c_char, buf: *mut statfs) -> ::c_int;
803803
pub fn fstatfs(fd: ::c_int, buf: *mut statfs) -> ::c_int;
804+
pub fn uname(buf: *mut ::utsname) -> ::c_int;
804805
}

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -949,6 +949,12 @@ pub const UF_READONLY: ::c_ulong = 0x00001000;
949949
pub const UF_HIDDEN: ::c_ulong = 0x00008000;
950950
pub const SF_SNAPSHOT: ::c_ulong = 0x00200000;
951951

952+
f! {
953+
pub fn uname(buf: *mut ::utsname) -> ::c_int {
954+
__xuname(256, buf as *mut ::c_void)
955+
}
956+
}
957+
952958
extern {
953959
pub fn __error() -> *mut ::c_int;
954960

@@ -1135,6 +1141,7 @@ extern {
11351141
pub fn fstatfs(fd: ::c_int, buf: *mut statfs) -> ::c_int;
11361142

11371143
pub fn dup3(src: ::c_int, dst: ::c_int, flags: ::c_int) -> ::c_int;
1144+
pub fn __xuname(nmln: ::c_int, buf: *mut ::c_void) -> ::c_int;
11381145
}
11391146

11401147
#[link(name = "util")]

src/unix/bsd/netbsdlike/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -676,6 +676,7 @@ extern {
676676
-> ::c_int;
677677
pub fn getdomainname(name: *mut ::c_char, len: ::size_t) -> ::c_int;
678678
pub fn setdomainname(name: *const ::c_char, len: ::size_t) -> ::c_int;
679+
pub fn uname(buf: *mut ::utsname) -> ::c_int;
679680
}
680681

681682
cfg_if! {

src/unix/haiku/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1242,6 +1242,7 @@ extern {
12421242
termp: *mut termios,
12431243
winp: *mut ::winsize) -> ::pid_t;
12441244
pub fn sethostname(name: *const ::c_char, len: ::size_t) -> ::c_int;
1245+
pub fn uname(buf: *mut ::utsname) -> ::c_int;
12451246
}
12461247

12471248
cfg_if! {

src/unix/hermit/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -727,6 +727,7 @@ extern {
727727
-> ::c_int;
728728

729729
pub fn setgroups(ngroups: ::c_int, grouplist: *const ::gid_t) -> ::c_int;
730+
pub fn uname(buf: *mut ::utsname) -> ::c_int;
730731
}
731732

732733
cfg_if! {

src/unix/mod.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -972,7 +972,6 @@ extern {
972972
#[cfg_attr(target_os = "freebsd", link_name = "mknod@FBSD_1.0")]
973973
pub fn mknod(pathname: *const ::c_char, mode: ::mode_t,
974974
dev: ::dev_t) -> ::c_int;
975-
pub fn uname(buf: *mut ::utsname) -> ::c_int;
976975
pub fn gethostname(name: *mut ::c_char, len: ::size_t) -> ::c_int;
977976
pub fn getservbyname(name: *const ::c_char,
978977
proto: *const ::c_char) -> *mut servent;

src/unix/newlib/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -728,6 +728,7 @@ extern {
728728
link_name = "popen$UNIX2003")]
729729
pub fn popen(command: *const c_char,
730730
mode: *const c_char) -> *mut ::FILE;
731+
pub fn uname(buf: *mut ::utsname) -> ::c_int;
731732
}
732733

733734
cfg_if! {

src/unix/notbsd/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1242,6 +1242,7 @@ extern {
12421242
flags: ::c_int) -> ::ssize_t;
12431243
pub fn recvmsg(fd: ::c_int, msg: *mut ::msghdr, flags: ::c_int)
12441244
-> ::ssize_t;
1245+
pub fn uname(buf: *mut ::utsname) -> ::c_int;
12451246
}
12461247

12471248
cfg_if! {

src/unix/solaris/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1466,4 +1466,5 @@ extern {
14661466
mode: *const c_char) -> *mut ::FILE;
14671467

14681468
pub fn dup3(src: ::c_int, dst: ::c_int, flags: ::c_int) -> ::c_int;
1469+
pub fn uname(buf: *mut ::utsname) -> ::c_int;
14691470
}

src/unix/uclibc/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1953,6 +1953,7 @@ extern {
19531953
link_name = "popen$UNIX2003")]
19541954
pub fn popen(command: *const c_char,
19551955
mode: *const c_char) -> *mut ::FILE;
1956+
pub fn uname(buf: *mut ::utsname) -> ::c_int;
19561957
}
19571958

19581959
cfg_if! {

0 commit comments

Comments
 (0)