Skip to content
Snippets Groups Projects
Verified Commit 87ecce9e authored by Jeremy Soller's avatar Jeremy Soller
Browse files

Cleanup and use unmount flag inside of Redox scheme processing function

parent 3e1fc9da
No related branches found
No related tags found
No related merge requests found
...@@ -10,7 +10,6 @@ use redoxfs::{FileSystem, DiskFile}; ...@@ -10,7 +10,6 @@ use redoxfs::{FileSystem, DiskFile};
use uuid::Uuid; use uuid::Uuid;
fn main() { fn main() {
println!("HI");
let mut args = env::args().skip(1); let mut args = env::args().skip(1);
let disk_path = if let Some(path) = args.next() { let disk_path = if let Some(path) = args.next() {
......
...@@ -10,26 +10,34 @@ extern crate syscall; ...@@ -10,26 +10,34 @@ extern crate syscall;
extern crate redoxfs; extern crate redoxfs;
extern crate uuid; extern crate uuid;
use redoxfs::{DiskCache, DiskFile, mount};
use std::env; use std::env;
use std::fs::File; use std::fs::File;
use std::io::{Read, Write}; use std::io::{Read, Write};
use std::os::unix::io::FromRawFd; use std::os::unix::io::FromRawFd;
use std::process; use std::process;
use redoxfs::FileSystem; use std::sync::atomic::Ordering;
use std::sync::atomic::{AtomicUsize, Ordering};
use redoxfs::{DiskCache, DiskFile, mount,Disk};
use uuid::Uuid; use uuid::Uuid;
#[cfg(target_os = "redox")] #[cfg(target_os = "redox")]
use syscall::{sigaction,sigreturn,SigAction,SIGKILL}; use syscall::{sigaction, SigAction, SIGKILL};
use redoxfs::IS_UMT; use redoxfs::IS_UMT;
#[cfg(target_os = "redox")]
extern "C" fn unmount_handler(_s: usize) {
IS_UMT.store(1, Ordering::SeqCst);
}
#[cfg(target_os = "redox")] #[cfg(target_os = "redox")]
//set up a signal handler on redox, this implements unmounting. I have no idea what sa_flags is //set up a signal handler on redox, this implements unmounting. I have no idea what sa_flags is
//for, so I put 2. I don't think 0,0 is a valid sa_mask. I don't know what i'm doing here. When u //for, so I put 2. I don't think 0,0 is a valid sa_mask. I don't know what i'm doing here. When u
//send it a sigkill, it shuts off the filesystem //send it a sigkill, it shuts off the filesystem
fn setsig() { fn setsig() {
sigaction(SIGKILL,Some(&SigAction{sa_handler:hi,sa_mask:[0,0],sa_flags:2}),None).unwrap(); sigaction(SIGKILL,Some(&SigAction{
sa_handler: unmount_handler,
sa_mask: [0,0],
sa_flags: 0,
}),None).unwrap();
} }
#[cfg(unix)] #[cfg(unix)]
...@@ -37,6 +45,7 @@ fn setsig() { ...@@ -37,6 +45,7 @@ fn setsig() {
fn setsig() { fn setsig() {
() ()
} }
#[cfg(unix)] #[cfg(unix)]
fn fork() -> isize { fn fork() -> isize {
unsafe { libc::fork() as isize } unsafe { libc::fork() as isize }
...@@ -109,6 +118,8 @@ fn disk_paths(paths: &mut Vec<String>) { ...@@ -109,6 +118,8 @@ fn disk_paths(paths: &mut Vec<String>) {
} }
fn daemon(disk_id: &DiskId, mountpoint: &str, mut write: File) -> ! { fn daemon(disk_id: &DiskId, mountpoint: &str, mut write: File) -> ! {
setsig();
let mut paths = vec![]; let mut paths = vec![];
let mut uuid_opt = None; let mut uuid_opt = None;
...@@ -142,7 +153,6 @@ fn daemon(disk_id: &DiskId, mountpoint: &str, mut write: File) -> ! { ...@@ -142,7 +153,6 @@ fn daemon(disk_id: &DiskId, mountpoint: &str, mut write: File) -> ! {
true true
}; };
setsig();
if matches { if matches {
match mount(filesystem, &mountpoint, || { match mount(filesystem, &mountpoint, || {
println!("redoxfs: mounted filesystem on {} to {}", path, mountpoint); println!("redoxfs: mounted filesystem on {} to {}", path, mountpoint);
...@@ -177,7 +187,6 @@ fn daemon(disk_id: &DiskId, mountpoint: &str, mut write: File) -> ! { ...@@ -177,7 +187,6 @@ fn daemon(disk_id: &DiskId, mountpoint: &str, mut write: File) -> ! {
} }
fn main() { fn main() {
println!("It just works");
let mut args = env::args().skip(1); let mut args = env::args().skip(1);
let disk_id = match args.next() { let disk_id = match args.next() {
...@@ -226,6 +235,7 @@ fn main() { ...@@ -226,6 +235,7 @@ fn main() {
let pid = fork(); let pid = fork();
if pid == 0 { if pid == 0 {
drop(read); drop(read);
daemon(&disk_id, &mountpoint, write); daemon(&disk_id, &mountpoint, write);
} else if pid > 0 { } else if pid > 0 {
drop(write); drop(write);
...@@ -241,9 +251,3 @@ fn main() { ...@@ -241,9 +251,3 @@ fn main() {
panic!("redoxfs: failed to create pipe"); panic!("redoxfs: failed to create pipe");
} }
} }
#[cfg(target_os = "redox")]
extern "C" fn hi(s:usize) {
println!("{}",s);
IS_UMT.store(1, Ordering::Relaxed);
sigreturn().unwrap();
}
...@@ -19,7 +19,7 @@ impl<D: Disk> FileSystem<D> { ...@@ -19,7 +19,7 @@ impl<D: Disk> FileSystem<D> {
disk.read_at(block + header.0, &mut header.1)?; disk.read_at(block + header.0, &mut header.1)?;
if header.1.valid() { if header.1.valid() {
header.1.dirty=true; header.1.dirty = true;
disk.write_at(header.0, &header.1)?; disk.write_at(header.0, &header.1)?;
let mut root = (header.1.root, Node::default()); let mut root = (header.1.root, Node::default());
disk.read_at(block + root.0, &mut root.1)?; disk.read_at(block + root.0, &mut root.1)?;
...@@ -37,8 +37,9 @@ impl<D: Disk> FileSystem<D> { ...@@ -37,8 +37,9 @@ impl<D: Disk> FileSystem<D> {
Err(Error::new(ENOENT)) Err(Error::new(ENOENT))
} }
pub fn close(&mut self) -> Result<()> { pub fn close(&mut self) -> Result<()> {
self.header.1.dirty=false; self.header.1.dirty = false;
self.disk.write_at(self.header.0, &self.header.1)?; self.disk.write_at(self.header.0, &self.header.1)?;
Ok(()) Ok(())
} }
......
...@@ -20,6 +20,7 @@ pub struct Header { ...@@ -20,6 +20,7 @@ pub struct Header {
pub root: u64, pub root: u64,
/// Block of free space node /// Block of free space node
pub free: u64, pub free: u64,
/// True if the filesystem is currently mounted
pub dirty: bool, pub dirty: bool,
/// Padding /// Padding
pub padding: [u8; BLOCK_SIZE as usize - 57] pub padding: [u8; BLOCK_SIZE as usize - 57]
......
...@@ -6,6 +6,8 @@ ...@@ -6,6 +6,8 @@
extern crate syscall; extern crate syscall;
extern crate uuid; extern crate uuid;
use std::sync::atomic::AtomicUsize;
pub const BLOCK_SIZE: u64 = 4096; pub const BLOCK_SIZE: u64 = 4096;
pub const SIGNATURE: &'static [u8; 8] = b"RedoxFS\0"; pub const SIGNATURE: &'static [u8; 8] = b"RedoxFS\0";
pub const VERSION: u64 = 3; pub const VERSION: u64 = 3;
...@@ -18,7 +20,7 @@ pub use self::filesystem::FileSystem; ...@@ -18,7 +20,7 @@ pub use self::filesystem::FileSystem;
pub use self::header::Header; pub use self::header::Header;
pub use self::mount::mount; pub use self::mount::mount;
pub use self::node::Node; pub use self::node::Node;
use std::sync::atomic::AtomicUsize;
mod disk; mod disk;
mod ex_node; mod ex_node;
mod extent; mod extent;
......
...@@ -4,10 +4,10 @@ extern crate time; ...@@ -4,10 +4,10 @@ extern crate time;
use std::cmp; use std::cmp;
use std::ffi::OsStr; use std::ffi::OsStr;
use std::io; use std::io;
use std::io::{ErrorKind, Error};
use std::os::unix::ffi::OsStrExt; use std::os::unix::ffi::OsStrExt;
use std::path::Path; use std::path::Path;
use std::time::{SystemTime, UNIX_EPOCH}; use std::time::{SystemTime, UNIX_EPOCH};
use std::io::{ErrorKind,Error};
use BLOCK_SIZE; use BLOCK_SIZE;
use disk::Disk; use disk::Disk;
...@@ -29,8 +29,9 @@ pub fn mount<D: Disk, P: AsRef<Path>, F: FnMut()>(filesystem: filesystem::FileSy ...@@ -29,8 +29,9 @@ pub fn mount<D: Disk, P: AsRef<Path>, F: FnMut()>(filesystem: filesystem::FileSy
callback(); callback();
session.run()?; session.run()?;
session.filesystem.fs.close().map_err(|e| Error::new(ErrorKind::Interrupted,format!("{}",e))) session.filesystem.fs.close().map_err(|e| Error::new(ErrorKind::Interrupted,format!("{}",e)))
} }
pub struct Fuse<D: Disk> { pub struct Fuse<D: Disk> {
......
...@@ -3,9 +3,11 @@ extern crate spin; ...@@ -3,9 +3,11 @@ extern crate spin;
use syscall; use syscall;
use syscall::{Packet, Scheme}; use syscall::{Packet, Scheme};
use std::fs::File; use std::fs::File;
use std::io::{self, Read, Write}; use std::io::{Error, ErrorKind, Read, Result, Write};
use std::path::Path; use std::path::Path;
use std::sync::atomic::Ordering;
use IS_UMT;
use disk::Disk; use disk::Disk;
use filesystem::FileSystem; use filesystem::FileSystem;
...@@ -14,7 +16,7 @@ use self::scheme::FileScheme; ...@@ -14,7 +16,7 @@ use self::scheme::FileScheme;
pub mod resource; pub mod resource;
pub mod scheme; pub mod scheme;
pub fn mount<D: Disk, P: AsRef<Path>, F: FnMut()>(filesystem: FileSystem<D>, mountpoint: &P, mut callback: F) -> io::Result<()> { pub fn mount<D: Disk, P: AsRef<Path>, F: FnMut()>(filesystem: FileSystem<D>, mountpoint: &P, mut callback: F) -> Result<()> {
let mountpoint = mountpoint.as_ref(); let mountpoint = mountpoint.as_ref();
let mut socket = File::create(format!(":{}", mountpoint.display()))?; let mut socket = File::create(format!(":{}", mountpoint.display()))?;
...@@ -23,10 +25,35 @@ pub fn mount<D: Disk, P: AsRef<Path>, F: FnMut()>(filesystem: FileSystem<D>, mou ...@@ -23,10 +25,35 @@ pub fn mount<D: Disk, P: AsRef<Path>, F: FnMut()>(filesystem: FileSystem<D>, mou
syscall::setrens(0, 0).expect("redoxfs: failed to enter null namespace"); syscall::setrens(0, 0).expect("redoxfs: failed to enter null namespace");
let scheme = FileScheme::new(format!("{}", mountpoint.display()), filesystem); let scheme = FileScheme::new(format!("{}", mountpoint.display()), filesystem);
loop { let res = loop {
if IS_UMT.load(Ordering::SeqCst) > 0 {
break Ok(());
}
let mut packet = Packet::default(); let mut packet = Packet::default();
socket.read(&mut packet).unwrap(); match socket.read(&mut packet) {
Ok(_ok) => (),
Err(err) => if err.kind() == ErrorKind::Interrupted {
continue;
} else {
break Err(err);
}
}
scheme.handle(&mut packet); scheme.handle(&mut packet);
socket.write(&packet).unwrap();
match socket.write(&packet) {
Ok(_ok) => (),
Err(err) => {
break Err(err);
}
}
};
{
let mut fs = scheme.fs.borrow_mut();
fs.close().map_err(|e| Error::new(ErrorKind::Interrupted,format!("{}",e)))?;
} }
res
} }
...@@ -2,19 +2,18 @@ use std::cell::RefCell; ...@@ -2,19 +2,18 @@ use std::cell::RefCell;
use std::collections::BTreeMap; use std::collections::BTreeMap;
use std::result::Result as StdResult; use std::result::Result as StdResult;
use std::str; use std::str;
use std::sync::atomic::{AtomicUsize, Ordering};
use std::time::{SystemTime, UNIX_EPOCH}; use std::time::{SystemTime, UNIX_EPOCH};
use syscall::data::{Stat, StatVfs, TimeSpec}; use syscall::data::{Stat, StatVfs, TimeSpec};
use syscall::error::{Error, Result, EACCES, EEXIST, EISDIR, ENOTDIR, ENOTEMPTY, EPERM, ENOENT, EBADF, ELOOP, EINVAL}; use syscall::error::{Error, Result, EACCES, EEXIST, EISDIR, ENOTDIR, ENOTEMPTY, EPERM, ENOENT, EBADF, ELOOP, EINVAL};
use syscall::flag::{O_APPEND, O_CREAT, O_DIRECTORY, O_STAT, O_EXCL, O_TRUNC, O_ACCMODE, O_RDONLY, O_WRONLY, O_RDWR, MODE_PERM, O_SYMLINK, O_NOFOLLOW}; use syscall::flag::{O_APPEND, O_CREAT, O_DIRECTORY, O_STAT, O_EXCL, O_TRUNC, O_ACCMODE, O_RDONLY, O_WRONLY, O_RDWR, MODE_PERM, O_SYMLINK, O_NOFOLLOW};
use syscall::scheme::Scheme; use syscall::scheme::Scheme;
use std::sync::atomic::{AtomicUsize, Ordering};
use syscall::EINTR;
use BLOCK_SIZE; use BLOCK_SIZE;
use disk::Disk; use disk::Disk;
use filesystem::FileSystem; use filesystem::FileSystem;
use node::Node; use node::Node;
use IS_UMT;
use super::resource::{Resource, DirResource, FileResource}; use super::resource::{Resource, DirResource, FileResource};
use super::spin::Mutex; use super::spin::Mutex;
...@@ -90,7 +89,7 @@ impl Fmaps { ...@@ -90,7 +89,7 @@ impl Fmaps {
pub struct FileScheme<D: Disk> { pub struct FileScheme<D: Disk> {
name: String, name: String,
fs: RefCell<FileSystem<D>>, pub(crate) fs: RefCell<FileSystem<D>>,
next_id: AtomicUsize, next_id: AtomicUsize,
files: Mutex<BTreeMap<usize, Box<Resource<D>>>>, files: Mutex<BTreeMap<usize, Box<Resource<D>>>>,
fmaps: Mutex<Fmaps> fmaps: Mutex<Fmaps>
...@@ -252,8 +251,8 @@ pub fn canonicalize(current: &[u8], path: &[u8]) -> Vec<u8> { ...@@ -252,8 +251,8 @@ pub fn canonicalize(current: &[u8], path: &[u8]) -> Vec<u8> {
impl<D: Disk> Scheme for FileScheme<D> { impl<D: Disk> Scheme for FileScheme<D> {
fn open(&self, url: &[u8], flags: usize, uid: u32, gid: u32) -> Result<usize> { fn open(&self, url: &[u8], flags: usize, uid: u32, gid: u32) -> Result<usize> {
//WE ARE NOT GOING TO BLOCK THE OPEN CALL AT ALL
let path = str::from_utf8(url).unwrap_or("").trim_matches('/'); let path = str::from_utf8(url).unwrap_or("").trim_matches('/');
// println!("Open '{}' {:X}", path, flags); // println!("Open '{}' {:X}", path, flags);
let mut fs = self.fs.borrow_mut(); let mut fs = self.fs.borrow_mut();
...@@ -388,10 +387,6 @@ impl<D: Disk> Scheme for FileScheme<D> { ...@@ -388,10 +387,6 @@ impl<D: Disk> Scheme for FileScheme<D> {
} }
fn chmod(&self, url: &[u8], mode: u16, uid: u32, gid: u32) -> Result<usize> { fn chmod(&self, url: &[u8], mode: u16, uid: u32, gid: u32) -> Result<usize> {
//block
if 1 == IS_UMT.load(Ordering::Relaxed) {
return Err(Error::new(EINTR));
}
let path = str::from_utf8(url).unwrap_or("").trim_matches('/'); let path = str::from_utf8(url).unwrap_or("").trim_matches('/');
// println!("Chmod '{}'", path); // println!("Chmod '{}'", path);
...@@ -413,10 +408,6 @@ impl<D: Disk> Scheme for FileScheme<D> { ...@@ -413,10 +408,6 @@ impl<D: Disk> Scheme for FileScheme<D> {
} }
fn rmdir(&self, url: &[u8], uid: u32, gid: u32) -> Result<usize> { fn rmdir(&self, url: &[u8], uid: u32, gid: u32) -> Result<usize> {
//block
if 1 == IS_UMT.load(Ordering::Relaxed) {
return Err(Error::new(EINTR));
}
let path = str::from_utf8(url).unwrap_or("").trim_matches('/'); let path = str::from_utf8(url).unwrap_or("").trim_matches('/');
// println!("Rmdir '{}'", path); // println!("Rmdir '{}'", path);
...@@ -454,11 +445,6 @@ impl<D: Disk> Scheme for FileScheme<D> { ...@@ -454,11 +445,6 @@ impl<D: Disk> Scheme for FileScheme<D> {
} }
fn unlink(&self, url: &[u8], uid: u32, gid: u32) -> Result<usize> { fn unlink(&self, url: &[u8], uid: u32, gid: u32) -> Result<usize> {
//block
//block
if 1 == IS_UMT.load(Ordering::Relaxed) {
return Err(Error::new(EINTR));
}
let path = str::from_utf8(url).unwrap_or("").trim_matches('/'); let path = str::from_utf8(url).unwrap_or("").trim_matches('/');
// println!("Unlink '{}'", path); // println!("Unlink '{}'", path);
...@@ -502,10 +488,6 @@ impl<D: Disk> Scheme for FileScheme<D> { ...@@ -502,10 +488,6 @@ impl<D: Disk> Scheme for FileScheme<D> {
/* Resource operations */ /* Resource operations */
#[allow(unused_variables)] #[allow(unused_variables)]
fn dup(&self, old_id: usize, buf: &[u8]) -> Result<usize> { fn dup(&self, old_id: usize, buf: &[u8]) -> Result<usize> {
//block
if 1 == IS_UMT.load(Ordering::Relaxed) {
return Err(Error::new(EINTR));
}
// println!("Dup {}", old_id); // println!("Dup {}", old_id);
if ! buf.is_empty() { if ! buf.is_empty() {
...@@ -527,13 +509,6 @@ impl<D: Disk> Scheme for FileScheme<D> { ...@@ -527,13 +509,6 @@ impl<D: Disk> Scheme for FileScheme<D> {
#[allow(unused_variables)] #[allow(unused_variables)]
fn read(&self, id: usize, buf: &mut [u8]) -> Result<usize> { fn read(&self, id: usize, buf: &mut [u8]) -> Result<usize> {
//block
if 1 == IS_UMT.load(Ordering::Relaxed) {
return Err(Error::new(EINTR));
}
if 1 == IS_UMT.load(Ordering::Relaxed) {
return Err(Error::new(EINTR));
}
// println!("Read {}, {:X} {}", id, buf.as_ptr() as usize, buf.len()); // println!("Read {}, {:X} {}", id, buf.as_ptr() as usize, buf.len());
let mut files = self.files.lock(); let mut files = self.files.lock();
if let Some(file) = files.get_mut(&id) { if let Some(file) = files.get_mut(&id) {
...@@ -544,15 +519,6 @@ impl<D: Disk> Scheme for FileScheme<D> { ...@@ -544,15 +519,6 @@ impl<D: Disk> Scheme for FileScheme<D> {
} }
fn write(&self, id: usize, buf: &[u8]) -> Result<usize> { fn write(&self, id: usize, buf: &[u8]) -> Result<usize> {
//block
if 1 == IS_UMT.load(Ordering::Relaxed) {
return Err(Error::new(EINTR));
}
if 1 == IS_UMT.load(Ordering::Relaxed) {
return Err(Error::new(EINTR));
}
//block
// println!("Write {}, {:X} {}", id, buf.as_ptr() as usize, buf.len()); // println!("Write {}, {:X} {}", id, buf.as_ptr() as usize, buf.len());
let mut files = self.files.lock(); let mut files = self.files.lock();
if let Some(file) = files.get_mut(&id) { if let Some(file) = files.get_mut(&id) {
...@@ -563,13 +529,6 @@ impl<D: Disk> Scheme for FileScheme<D> { ...@@ -563,13 +529,6 @@ impl<D: Disk> Scheme for FileScheme<D> {
} }
fn seek(&self, id: usize, pos: usize, whence: usize) -> Result<usize> { fn seek(&self, id: usize, pos: usize, whence: usize) -> Result<usize> {
//block
if 1 == IS_UMT.load(Ordering::Relaxed) {
return Err(Error::new(EINTR));
}
if 1 == IS_UMT.load(Ordering::Relaxed) {
return Err(Error::new(EINTR));
}
// println!("Seek {}, {} {}", id, pos, whence); // println!("Seek {}, {} {}", id, pos, whence);
let mut files = self.files.lock(); let mut files = self.files.lock();
if let Some(file) = files.get_mut(&id) { if let Some(file) = files.get_mut(&id) {
...@@ -580,10 +539,6 @@ impl<D: Disk> Scheme for FileScheme<D> { ...@@ -580,10 +539,6 @@ impl<D: Disk> Scheme for FileScheme<D> {
} }
fn fchmod(&self, id: usize, mode: u16) -> Result<usize> { fn fchmod(&self, id: usize, mode: u16) -> Result<usize> {
if 1 == IS_UMT.load(Ordering::Relaxed) {
return Err(Error::new(EINTR));
}
//block
let mut files = self.files.lock(); let mut files = self.files.lock();
if let Some(file) = files.get_mut(&id) { if let Some(file) = files.get_mut(&id) {
file.fchmod(mode, &mut self.fs.borrow_mut()) file.fchmod(mode, &mut self.fs.borrow_mut())
...@@ -593,10 +548,6 @@ impl<D: Disk> Scheme for FileScheme<D> { ...@@ -593,10 +548,6 @@ impl<D: Disk> Scheme for FileScheme<D> {
} }
fn fchown(&self, id: usize, uid: u32, gid: u32) -> Result<usize> { fn fchown(&self, id: usize, uid: u32, gid: u32) -> Result<usize> {
if 1 == IS_UMT.load(Ordering::Relaxed) {
return Err(Error::new(EINTR));
}
//block
let mut files = self.files.lock(); let mut files = self.files.lock();
if let Some(file) = files.get_mut(&id) { if let Some(file) = files.get_mut(&id) {
file.fchown(uid, gid, &mut self.fs.borrow_mut()) file.fchown(uid, gid, &mut self.fs.borrow_mut())
...@@ -606,10 +557,6 @@ impl<D: Disk> Scheme for FileScheme<D> { ...@@ -606,10 +557,6 @@ impl<D: Disk> Scheme for FileScheme<D> {
} }
fn fcntl(&self, id: usize, cmd: usize, arg: usize) -> Result<usize> { fn fcntl(&self, id: usize, cmd: usize, arg: usize) -> Result<usize> {
//block
if 1 == IS_UMT.load(Ordering::Relaxed) {
return Err(Error::new(EINTR));
}
let mut files = self.files.lock(); let mut files = self.files.lock();
if let Some(file) = files.get_mut(&id) { if let Some(file) = files.get_mut(&id) {
file.fcntl(cmd, arg) file.fcntl(cmd, arg)
...@@ -619,10 +566,6 @@ impl<D: Disk> Scheme for FileScheme<D> { ...@@ -619,10 +566,6 @@ impl<D: Disk> Scheme for FileScheme<D> {
} }
fn fpath(&self, id: usize, buf: &mut [u8]) -> Result<usize> { fn fpath(&self, id: usize, buf: &mut [u8]) -> Result<usize> {
//block
if 1 == IS_UMT.load(Ordering::Relaxed) {
return Err(Error::new(EINTR));
}
// println!("Fpath {}, {:X} {}", id, buf.as_ptr() as usize, buf.len()); // println!("Fpath {}, {:X} {}", id, buf.as_ptr() as usize, buf.len());
let files = self.files.lock(); let files = self.files.lock();
if let Some(file) = files.get(&id) { if let Some(file) = files.get(&id) {
...@@ -649,10 +592,6 @@ impl<D: Disk> Scheme for FileScheme<D> { ...@@ -649,10 +592,6 @@ impl<D: Disk> Scheme for FileScheme<D> {
} }
fn frename(&self, id: usize, url: &[u8], uid: u32, gid: u32) -> Result<usize> { fn frename(&self, id: usize, url: &[u8], uid: u32, gid: u32) -> Result<usize> {
//block
if 1 == IS_UMT.load(Ordering::Relaxed) {
return Err(Error::new(EINTR));
}
let path = str::from_utf8(url).unwrap_or("").trim_matches('/'); let path = str::from_utf8(url).unwrap_or("").trim_matches('/');
// println!("Frename {}, {} from {}, {}", id, path, uid, gid); // println!("Frename {}, {} from {}, {}", id, path, uid, gid);
...@@ -781,10 +720,6 @@ impl<D: Disk> Scheme for FileScheme<D> { ...@@ -781,10 +720,6 @@ impl<D: Disk> Scheme for FileScheme<D> {
} }
fn fsync(&self, id: usize) -> Result<usize> { fn fsync(&self, id: usize) -> Result<usize> {
//block
if 1 == IS_UMT.load(Ordering::Relaxed) {
return Err(Error::new(EINTR));
}
// println!("Fsync {}", id); // println!("Fsync {}", id);
let mut files = self.files.lock(); let mut files = self.files.lock();
if let Some(file) = files.get_mut(&id) { if let Some(file) = files.get_mut(&id) {
...@@ -795,10 +730,6 @@ impl<D: Disk> Scheme for FileScheme<D> { ...@@ -795,10 +730,6 @@ impl<D: Disk> Scheme for FileScheme<D> {
} }
fn ftruncate(&self, id: usize, len: usize) -> Result<usize> { fn ftruncate(&self, id: usize, len: usize) -> Result<usize> {
//block
if 1 == IS_UMT.load(Ordering::Relaxed) {
return Err(Error::new(EINTR));
}
// println!("Ftruncate {}, {}", id, len); // println!("Ftruncate {}, {}", id, len);
let mut files = self.files.lock(); let mut files = self.files.lock();
if let Some(file) = files.get_mut(&id) { if let Some(file) = files.get_mut(&id) {
...@@ -809,10 +740,6 @@ impl<D: Disk> Scheme for FileScheme<D> { ...@@ -809,10 +740,6 @@ impl<D: Disk> Scheme for FileScheme<D> {
} }
fn futimens(&self, id: usize, times: &[TimeSpec]) -> Result<usize> { fn futimens(&self, id: usize, times: &[TimeSpec]) -> Result<usize> {
//block
if 1 == IS_UMT.load(Ordering::Relaxed) {
return Err(Error::new(EINTR));
}
// println!("Futimens {}, {}", id, times.len()); // println!("Futimens {}, {}", id, times.len());
let mut files = self.files.lock(); let mut files = self.files.lock();
if let Some(file) = files.get_mut(&id) { if let Some(file) = files.get_mut(&id) {
...@@ -823,10 +750,6 @@ impl<D: Disk> Scheme for FileScheme<D> { ...@@ -823,10 +750,6 @@ impl<D: Disk> Scheme for FileScheme<D> {
} }
fn fmap(&self, id: usize, offset: usize, size: usize) -> Result<usize> { fn fmap(&self, id: usize, offset: usize, size: usize) -> Result<usize> {
//block
if 1 == IS_UMT.load(Ordering::Relaxed) {
return Err(Error::new(EINTR));
}
// println!("Fmap {}, {}, {}", id, offset, size); // println!("Fmap {}, {}, {}", id, offset, size);
let mut files = self.files.lock(); let mut files = self.files.lock();
if let Some(file) = files.get_mut(&id) { if let Some(file) = files.get_mut(&id) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment