Add missing open flags
This commit is contained in:
@@ -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
|
||||
};
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user