Rustify Sys::open and some fs:: error handling.
This commit is contained in:
@@ -3,6 +3,7 @@ use core::{mem, ptr};
|
||||
|
||||
use crate::{
|
||||
c_str::CString,
|
||||
error::ResultExt,
|
||||
header::{
|
||||
arpa_inet::inet_aton, fcntl::O_RDONLY, netinet_in::in_addr, sys_socket::constants::AF_INET,
|
||||
unistd::SEEK_SET,
|
||||
@@ -45,7 +46,7 @@ pub unsafe extern "C" fn endhostent() {
|
||||
pub unsafe extern "C" fn sethostent(stayopen: c_int) {
|
||||
HOST_STAYOPEN = stayopen;
|
||||
if HOSTDB < 0 {
|
||||
HOSTDB = Sys::open(c_str!("/etc/hosts"), O_RDONLY, 0)
|
||||
HOSTDB = Sys::open(c_str!("/etc/hosts"), O_RDONLY, 0).or_minus_one_errno()
|
||||
} else {
|
||||
Sys::lseek(HOSTDB, 0, SEEK_SET);
|
||||
}
|
||||
@@ -55,7 +56,7 @@ pub unsafe extern "C" fn sethostent(stayopen: c_int) {
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn gethostent() -> *mut hostent {
|
||||
if HOSTDB < 0 {
|
||||
HOSTDB = Sys::open(c_str!("/etc/hosts"), O_RDONLY, 0);
|
||||
HOSTDB = Sys::open(c_str!("/etc/hosts"), O_RDONLY, 0).or_minus_one_errno();
|
||||
}
|
||||
let mut rlb = RawLineBuffer::new(HOSTDB);
|
||||
rlb.seek(H_POS);
|
||||
|
||||
Reference in New Issue
Block a user