Cleanup fuse backend, send signal at correct time
This commit is contained in:
+14
-3
@@ -2,6 +2,8 @@ extern crate fuse;
|
||||
extern crate time;
|
||||
|
||||
use std::ffi::OsStr;
|
||||
use std::fs::File;
|
||||
use std::io::{self, Write};
|
||||
use std::os::unix::ffi::OsStrExt;
|
||||
use std::path::Path;
|
||||
use std::time::{SystemTime, UNIX_EPOCH};
|
||||
@@ -10,15 +12,24 @@ use disk::Disk;
|
||||
use filesystem;
|
||||
use node::Node;
|
||||
|
||||
use self::fuse::{FileType, FileAttr, Filesystem, Request, ReplyData, ReplyEntry, ReplyAttr, ReplyCreate, ReplyDirectory, ReplyEmpty, ReplyStatfs, ReplyWrite};
|
||||
use self::fuse::{FileType, FileAttr, Filesystem, Request, ReplyData, ReplyEntry, ReplyAttr, ReplyCreate, ReplyDirectory, ReplyEmpty, ReplyStatfs, ReplyWrite, Session};
|
||||
use self::time::Timespec;
|
||||
|
||||
pub use self::fuse::mount;
|
||||
|
||||
const TTL: Timespec = Timespec { sec: 1, nsec: 0 }; // 1 second
|
||||
|
||||
const NULL_TIME: Timespec = Timespec { sec: 0, nsec: 0 };
|
||||
|
||||
pub fn mount<D: Disk, P: AsRef<Path>>(filesystem: filesystem::FileSystem<D>, mountpoint: &P, mut write: File, options: &[&OsStr]) -> io::Result<()> {
|
||||
let mut session = Session::new(Fuse {
|
||||
fs: filesystem
|
||||
}, mountpoint.as_ref(), options)?;
|
||||
|
||||
let _ = write.write(&[0]);
|
||||
drop(write);
|
||||
|
||||
session.run()
|
||||
}
|
||||
|
||||
pub struct Fuse<D: Disk> {
|
||||
pub fs: filesystem::FileSystem<D>,
|
||||
}
|
||||
|
||||
+4
-17
@@ -12,16 +12,10 @@ mod fuse;
|
||||
mod redox;
|
||||
|
||||
#[cfg(all(unix, target_os = "macos"))]
|
||||
pub fn mount<D: Disk, P: AsRef<Path>>(filesystem: FileSystem<D>, mountpoint: &P, mut write: File) -> io::Result<()> {
|
||||
pub fn mount<D: Disk, P: AsRef<Path>>(filesystem: FileSystem<D>, mountpoint: &P, write: File) -> io::Result<()> {
|
||||
use std::ffi::OsStr;
|
||||
use std::io::Write;
|
||||
|
||||
let _ = write.write(&[0]);
|
||||
drop(write);
|
||||
|
||||
fuse::mount(fuse::Fuse {
|
||||
fs: filesystem
|
||||
}, mountpoint, &[
|
||||
fuse::mount(filesystem, mountpoint, write, &[
|
||||
// One of the uses of this redoxfs fuse wrapper is to populate a filesystem
|
||||
// while building the Redox OS kernel. This means that we need to write on
|
||||
// a filesystem that belongs to `root`, which in turn means that we need to
|
||||
@@ -32,15 +26,8 @@ pub fn mount<D: Disk, P: AsRef<Path>>(filesystem: FileSystem<D>, mountpoint: &P,
|
||||
}
|
||||
|
||||
#[cfg(all(unix, not(target_os = "macos")))]
|
||||
pub fn mount<D: Disk, P: AsRef<Path>>(filesystem: FileSystem<D>, mountpoint: &P, mut write: File) -> io::Result<()> {
|
||||
use std::io::Write;
|
||||
|
||||
let _ = write.write(&[0]);
|
||||
drop(write);
|
||||
|
||||
fuse::mount(fuse::Fuse {
|
||||
fs: filesystem
|
||||
}, mountpoint, &[])
|
||||
pub fn mount<D: Disk, P: AsRef<Path>>(filesystem: FileSystem<D>, mountpoint: &P, write: File) -> io::Result<()> {
|
||||
fuse::mount(filesystem, mountpoint, write, &[])
|
||||
}
|
||||
|
||||
#[cfg(target_os = "redox")]
|
||||
|
||||
@@ -5,12 +5,14 @@ use std::fs::File;
|
||||
use std::io::{self, Read, Write};
|
||||
use std::path::Path;
|
||||
|
||||
use disk::Disk;
|
||||
|
||||
use self::scheme::FileScheme;
|
||||
|
||||
pub mod resource;
|
||||
pub mod scheme;
|
||||
|
||||
pub fn mount<P: AsRef<Path>>(filesystem: filesystem::FileSystem, mountpoint: &P, mut write: File) -> io::Result<()> {
|
||||
pub fn mount<D: Disk, P: AsRef<Path>>(filesystem: filesystem::FileSystem<D>, mountpoint: &P, mut write: File) -> io::Result<()> {
|
||||
let mountpoint = mountpoint.as_ref();
|
||||
let mut socket = File::create(format!(":{}", mountpoint.display()))?;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user