...
 
Commits (1)
...@@ -19,6 +19,3 @@ libc = "0.2" ...@@ -19,6 +19,3 @@ libc = "0.2"
[target.'cfg(windows)'.dependencies] [target.'cfg(windows)'.dependencies]
winapi = "0.2" winapi = "0.2"
kernel32-sys = "0.2" kernel32-sys = "0.2"
[target.'cfg(target_os = "redox")'.dependencies]
redox_syscall = "0.1"
#[cfg(any(unix, target_os = "redox"))] #[cfg(unix)]
mod unix; mod unix;
#[cfg(any(unix, target_os = "redox"))] #[cfg(unix)]
pub use self::unix::*; pub use self::unix::*;
#[cfg(windows)] #[cfg(windows)]
......
#[cfg(not(target_os = "redox"))]
use libc::{rename, link, unlink, c_char, c_int, O_EXCL, O_RDWR, O_CREAT, O_CLOEXEC}; use libc::{rename, link, unlink, c_char, c_int, O_EXCL, O_RDWR, O_CREAT, O_CLOEXEC};
use std::os::unix::ffi::OsStrExt; use std::os::unix::ffi::OsStrExt;
use std::ffi::CString; use std::ffi::CString;
...@@ -11,13 +10,9 @@ use util; ...@@ -11,13 +10,9 @@ use util;
#[cfg(all(lfs_support, target_os = "linux"))] #[cfg(all(lfs_support, target_os = "linux"))]
use libc::{open64 as open, fstat64 as fstat, stat64 as stat_t}; use libc::{open64 as open, fstat64 as fstat, stat64 as stat_t};
#[cfg(not(any(all(lfs_support, target_os = "linux"), target_os = "redox")))] #[cfg(not(all(lfs_support, target_os = "linux")))]
use libc::{open, fstat, stat as stat_t}; use libc::{open, fstat, stat as stat_t};
#[cfg(target_os = "redox")]
use syscall::{self, open, fstat, Stat as stat_t, O_EXCL, O_RDWR, O_CREAT, O_CLOEXEC};
#[cfg(not(target_os = "redox"))]
#[inline(always)] #[inline(always)]
pub fn cvt_err(result: c_int) -> io::Result<c_int> { pub fn cvt_err(result: c_int) -> io::Result<c_int> {
if result == -1 { if result == -1 {
...@@ -27,12 +22,6 @@ pub fn cvt_err(result: c_int) -> io::Result<c_int> { ...@@ -27,12 +22,6 @@ pub fn cvt_err(result: c_int) -> io::Result<c_int> {
} }
} }
#[cfg(target_os = "redox")]
#[inline(always)]
pub fn cvt_err(result: Result<usize, syscall::Error>) -> io::Result<usize> {
result.map_err(|err| io::Error::from_raw_os_error(err.errno))
}
// Stolen from std. // Stolen from std.
pub fn cstr(path: &Path) -> io::Result<CString> { pub fn cstr(path: &Path) -> io::Result<CString> {
// TODO: Use OsStr::to_cstring (convert) // TODO: Use OsStr::to_cstring (convert)
...@@ -40,7 +29,6 @@ pub fn cstr(path: &Path) -> io::Result<CString> { ...@@ -40,7 +29,6 @@ pub fn cstr(path: &Path) -> io::Result<CString> {
.map_err(|_| io::Error::new(io::ErrorKind::InvalidInput, "path contained a null")) .map_err(|_| io::Error::new(io::ErrorKind::InvalidInput, "path contained a null"))
} }
#[cfg(not(target_os = "redox"))]
pub fn create_named(path: &Path) -> io::Result<File> { pub fn create_named(path: &Path) -> io::Result<File> {
unsafe { unsafe {
let path = try!(cstr(path)); let path = try!(cstr(path));
...@@ -51,15 +39,6 @@ pub fn create_named(path: &Path) -> io::Result<File> { ...@@ -51,15 +39,6 @@ pub fn create_named(path: &Path) -> io::Result<File> {
} }
} }
#[cfg(target_os = "redox")]
pub fn create_named(path: &Path) -> io::Result<File> {
unsafe {
let fd = try!(cvt_err(open(path.as_os_str().as_bytes(),
O_CLOEXEC | O_EXCL | O_RDWR | O_CREAT | 0o600)));
Ok(FromRawFd::from_raw_fd(fd))
}
}
#[cfg(target_os = "linux")] #[cfg(target_os = "linux")]
pub fn create(dir: &Path) -> io::Result<File> { pub fn create(dir: &Path) -> io::Result<File> {
const O_TMPFILE: c_int = 0o20200000; const O_TMPFILE: c_int = 0o20200000;
...@@ -116,7 +95,6 @@ pub fn reopen(file: &File, path: &Path) -> io::Result<File> { ...@@ -116,7 +95,6 @@ pub fn reopen(file: &File, path: &Path) -> io::Result<File> {
} }
} }
#[cfg(not(target_os = "redox"))]
pub fn persist(old_path: &Path, new_path: &Path, overwrite: bool) -> io::Result<()> { pub fn persist(old_path: &Path, new_path: &Path, overwrite: bool) -> io::Result<()> {
unsafe { unsafe {
let old_path = try!(cstr(old_path)); let old_path = try!(cstr(old_path));
...@@ -134,9 +112,3 @@ pub fn persist(old_path: &Path, new_path: &Path, overwrite: bool) -> io::Result< ...@@ -134,9 +112,3 @@ pub fn persist(old_path: &Path, new_path: &Path, overwrite: bool) -> io::Result<
Ok(()) Ok(())
} }
} }
#[cfg(target_os = "redox")]
pub fn persist(old_path: &Path, new_path: &Path, overwrite: bool) -> io::Result<()> {
// XXX implement when possible
Err(io::Error::from_raw_os_error(syscall::ENOSYS))
}
...@@ -42,9 +42,6 @@ extern crate winapi; ...@@ -42,9 +42,6 @@ extern crate winapi;
#[cfg(windows)] #[cfg(windows)]
extern crate kernel32; extern crate kernel32;
#[cfg(target_os = "redox")]
extern crate syscall;
const NUM_RETRIES: u32 = 1 << 31; const NUM_RETRIES: u32 = 1 << 31;
const NUM_RAND_CHARS: usize = 6; const NUM_RAND_CHARS: usize = 6;
......