diff --git a/src/header/netdb/linux.rs b/src/header/netdb/linux.rs index 0d481d53e05d68c0069b0b9ca1b3bc6cf364606c..41d673034d0c58247bf2dc54eed9f117458d2e2d 100644 --- a/src/header/netdb/linux.rs +++ b/src/header/netdb/linux.rs @@ -1,11 +1,16 @@ use alloc::string::String; use c_str::CString; +use header::fcntl; use platform::rawfile::RawFile; use platform::rlb::RawLineBuffer; use platform::Line; pub fn get_dns_server() -> String { - let fd = match RawFile::open(&CString::new("/etc/resolv.conf").unwrap(), 0, 0) { + let fd = match RawFile::open( + &CString::new("/etc/resolv.conf").unwrap(), + fcntl::O_RDONLY, + 0, + ) { Ok(fd) => fd, Err(_) => return String::new(), // TODO: better error handling }; diff --git a/src/platform/rawfile.rs b/src/platform/rawfile.rs index 3e78c5e616416dc5f0dff856034d4b3a4c2985df..13014a7167d477e72b873d5422c3b6016fc0b4a3 100644 --- a/src/platform/rawfile.rs +++ b/src/platform/rawfile.rs @@ -3,6 +3,7 @@ use core::ops::Deref; use super::{types::*, Pal, Sys}; use c_str::CStr; +use header::fcntl; pub struct RawFile(c_int); @@ -49,7 +50,7 @@ impl Deref for RawFile { } pub fn file_read_all(path: &CStr) -> Result<Vec<u8>, ()> { - let file = RawFile::open(path, 0, 0o644)?; + let file = RawFile::open(path, fcntl::O_RDONLY, 0)?; let mut buf = Vec::new(); let mut len = 0; diff --git a/src/platform/redox/mod.rs b/src/platform/redox/mod.rs index ef927dcad368c36b2478205c8d01b170ea3b97a1..6b6c8942fc92ab0310ad469b986b415515d2d8fd 100644 --- a/src/platform/redox/mod.rs +++ b/src/platform/redox/mod.rs @@ -12,6 +12,7 @@ use syscall::{self, Result}; use c_str::{CStr, CString}; use header::dirent::dirent; use header::errno::{EINVAL, ENOSYS}; +use header::fcntl; const MAP_ANON: c_int = 1; //use header::sys_mman::MAP_ANON; //use header::sys_resource::rusage; @@ -54,7 +55,7 @@ pub struct Sys; impl Pal for Sys { fn access(path: &CStr, mode: c_int) -> c_int { - let fd = match RawFile::open(path, 0, 0) { + let fd = match RawFile::open(path, fcntl::O_PATH, 0) { Ok(fd) => fd, Err(_) => return -1, }; @@ -167,7 +168,7 @@ impl Pal for Sys { ) -> c_int { use alloc::Vec; - let fd = match RawFile::open(path, O_RDONLY as c_int, 0) { + let fd = match RawFile::open(path, fcntl::O_RDONLY, 0) { Ok(fd) => fd, Err(_) => return -1, }; @@ -205,7 +206,7 @@ impl Pal for Sys { Ok(path) => path, Err(_) => return -1, }; - match RawFile::open(&path, O_RDONLY as c_int, 0) { + match RawFile::open(&path, fcntl::O_RDONLY, 0) { Ok(file) => { interpreter_fd = *file; _interpreter_path = Some(path); @@ -634,7 +635,7 @@ impl Pal for Sys { } let event_path = unsafe { CStr::from_bytes_with_nul_unchecked(b"event:\0") }; - let event_file = match RawFile::open(event_path, 0, 0) { + let event_file = match RawFile::open(event_path, fcntl::O_RDWR, 0) { Ok(file) => file, Err(_) => return -1, }; @@ -682,7 +683,7 @@ impl Pal for Sys { format!("time:{}\0", syscall::CLOCK_MONOTONIC).into_bytes(), ) }; - let timeout_file = match RawFile::open(&timeout_path, 0, 0) { + let timeout_file = match RawFile::open(&timeout_path, fcntl::O_RDWR, 0) { Ok(file) => file, Err(_) => return -1, };