Replace gethostname syscall with uname

This commit is contained in:
Jeremy Soller
2018-12-01 19:11:46 -07:00
committed by Jeremy Soller
parent 52fd4d7e83
commit 3075b8b69f
4 changed files with 61 additions and 61 deletions
+1 -28
View File
@@ -1,4 +1,4 @@
use core::{mem, ptr};
use core::ptr;
use core_io::Write;
use super::types::*;
@@ -193,33 +193,6 @@ impl Pal for Sys {
e(unsafe { syscall!(GETGID) }) as gid_t
}
fn gethostname(mut name: *mut c_char, mut len: size_t) -> c_int {
unsafe {
let mut uts = mem::uninitialized();
let err = Sys::uname(&mut uts);
if err < 0 {
mem::forget(uts);
return err;
}
for c in uts.nodename.iter() {
if len == 0 {
break;
}
len -= 1;
*name = *c;
if *name == 0 {
// We do want to copy the zero also, so we check this after the copying.
break;
}
name = name.offset(1);
}
0
}
}
fn getpgid(pid: pid_t) -> pid_t {
e(unsafe { syscall!(GETPGID, pid) }) as pid_t
}