Verified Commit 842744c3 authored by Jeremy Soller's avatar Jeremy Soller
parents 2e32481d ec072bb7
Pipeline #4108 passed with stages
in 2 minutes and 27 seconds
......@@ -30,7 +30,7 @@ doc = false
redox_syscall = "0.1"
uuid = { version = "0.5", features = ["v4"] }
[target.'cfg(unix)'.dependencies]
[target.'cfg(not(target_os = "redox"))'.dependencies]
fuse = "0.3"
libc = "0.2"
time = "0.1"
#![cfg_attr(unix, feature(libc))]
#![cfg_attr(not(target_os = "redox"), feature(libc))]
#[cfg(unix)]
#[cfg(not(target_os = "redox"))]
extern crate libc;
#[cfg(target_os = "redox")]
......@@ -12,7 +12,7 @@ extern crate uuid;
use std::env;
use std::fs::File;
use std::io::{Read, Write};
use std::os::unix::io::FromRawFd;
use std::os::unix::io::{FromRawFd, RawFd};
use std::process;
use redoxfs::{DiskCache, DiskFile, mount};
......@@ -40,18 +40,18 @@ fn setsig() {
sigaction(SIGTERM, Some(&sig_action), None).unwrap();
}
#[cfg(unix)]
#[cfg(not(target_os = "redox"))]
// on linux, this is implemented properly, so no need for this unscrupulous nonsense!
fn setsig() {
()
}
#[cfg(unix)]
#[cfg(not(target_os = "redox"))]
fn fork() -> isize {
unsafe { libc::fork() as isize }
}
#[cfg(unix)]
#[cfg(not(target_os = "redox"))]
fn pipe(pipes: &mut [i32; 2]) -> isize {
unsafe { libc::pipe(pipes.as_mut_ptr()) as isize }
}
......@@ -253,8 +253,8 @@ fn main() {
let mut pipes = [0; 2];
if pipe(&mut pipes) == 0 {
let mut read = unsafe { File::from_raw_fd(pipes[0]) };
let write = unsafe { File::from_raw_fd(pipes[1]) };
let mut read = unsafe { File::from_raw_fd(pipes[0] as RawFd) };
let write = unsafe { File::from_raw_fd(pipes[1] as RawFd) };
let pid = fork();
if pid == 0 {
......
......@@ -4,13 +4,13 @@ use std::path::Path;
use disk::Disk;
use filesystem::FileSystem;
#[cfg(unix)]
#[cfg(not(target_os = "redox"))]
mod fuse;
#[cfg(target_os = "redox")]
mod redox;
#[cfg(all(unix, target_os = "macos"))]
#[cfg(target_os = "macos")]
pub fn mount<D: Disk, P: AsRef<Path>, F: FnMut()>(filesystem: FileSystem<D>, mountpoint: &P, callback: F) -> io::Result<()> {
use std::ffi::OsStr;
......@@ -24,7 +24,7 @@ pub fn mount<D: Disk, P: AsRef<Path>, F: FnMut()>(filesystem: FileSystem<D>, mou
])
}
#[cfg(all(unix, not(target_os = "macos")))]
#[cfg(all(not(target_os = "macos"), not(target_os = "redox")))]
pub fn mount<D: Disk, P: AsRef<Path>, F: FnMut()>(filesystem: FileSystem<D>, mountpoint: &P, callback: F) -> io::Result<()> {
fuse::mount(filesystem, mountpoint, callback, &[])
}
......
......@@ -494,6 +494,16 @@ impl<D: Disk> Scheme for FileScheme<D> {
}
}
fn fevent(&self, id: usize, flags: usize) -> Result<usize> {
let files = self.files.borrow_mut();
if let Some(file) = files.get(&id) {
// EPERM is returned for files that are always readable or writable
Err(Error::new(EPERM))
} else {
Err(Error::new(EBADF))
}
}
fn fpath(&self, id: usize, buf: &mut [u8]) -> Result<usize> {
// println!("Fpath {}, {:X} {}", id, buf.as_ptr() as usize, buf.len());
let files = self.files.borrow_mut();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment