Commit f96d3309 authored by Liam Naddell's avatar Liam Naddell

wip implementation of unmounting and dirty bits for redoxfs

parent 6126bfee
[[package]]
name = "bitflags"
version = "1.0.1"
version = "1.0.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "cfg-if"
version = "0.1.2"
version = "0.1.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "fuchsia-zircon"
version = "0.3.2"
version = "0.3.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"bitflags 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
"fuchsia-zircon-sys 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
"bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
"fuchsia-zircon-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "fuchsia-zircon-sys"
version = "0.3.2"
version = "0.3.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
......@@ -27,25 +27,16 @@ name = "fuse"
version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"libc 0.2.34 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)",
"pkg-config 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)",
"pkg-config 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)",
"thread-scoped 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
"time 0.1.38 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "kernel32-sys"
version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
"winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
"time 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "libc"
version = "0.2.34"
version = "0.2.43"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
......@@ -53,34 +44,45 @@ name = "log"
version = "0.3.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"log 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "log"
version = "0.4.0"
version = "0.4.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"cfg-if 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "pkg-config"
version = "0.3.9"
version = "0.3.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "rand"
version = "0.3.22"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)",
"rand 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "rand"
version = "0.3.19"
version = "0.4.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"fuchsia-zircon 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.34 (registry+https://github.com/rust-lang/crates.io-index)",
"fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)",
"winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "redox_syscall"
version = "0.1.33"
version = "0.1.42"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
......@@ -88,16 +90,16 @@ name = "redoxfs"
version = "0.3.2"
dependencies = [
"fuse 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.34 (registry+https://github.com/rust-lang/crates.io-index)",
"redox_syscall 0.1.33 (registry+https://github.com/rust-lang/crates.io-index)",
"spin 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
"time 0.1.38 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)",
"redox_syscall 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)",
"spin 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)",
"time 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)",
"uuid 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "spin"
version = "0.4.6"
version = "0.4.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
......@@ -107,13 +109,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "time"
version = "0.1.38"
version = "0.1.40"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.34 (registry+https://github.com/rust-lang/crates.io-index)",
"redox_syscall 0.1.33 (registry+https://github.com/rust-lang/crates.io-index)",
"winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)",
"redox_syscall 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)",
"winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
......@@ -121,35 +122,45 @@ name = "uuid"
version = "0.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"rand 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)",
"rand 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "winapi"
version = "0.2.8"
version = "0.3.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "winapi-i686-pc-windows-gnu"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "winapi-build"
version = "0.1.1"
name = "winapi-x86_64-pc-windows-gnu"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
[metadata]
"checksum bitflags 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b3c30d3802dfb7281680d6285f2ccdaa8c2d8fee41f93805dba5c4cf50dc23cf"
"checksum cfg-if 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "d4c819a1287eb618df47cc647173c5c4c66ba19d888a6e50d605672aed3140de"
"checksum fuchsia-zircon 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "bd510087c325af53ba24f3be8f1c081b0982319adcb8b03cad764512923ccc19"
"checksum fuchsia-zircon-sys 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "08b3a6f13ad6b96572b53ce7af74543132f1a7055ccceb6d073dd36c54481859"
"checksum bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "228047a76f468627ca71776ecdebd732a3423081fcf5125585bcd7c49886ce12"
"checksum cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "082bb9b28e00d3c9d39cc03e64ce4cea0f1bb9b3fde493f0cbc008472d22bdf4"
"checksum fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2e9763c69ebaae630ba35f74888db465e49e259ba1bc0eda7d06f4a067615d82"
"checksum fuchsia-zircon-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7"
"checksum fuse 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "80e57070510966bfef93662a81cb8aa2b1c7db0964354fa9921434f04b9e8660"
"checksum kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d"
"checksum libc 0.2.34 (registry+https://github.com/rust-lang/crates.io-index)" = "36fbc8a8929c632868295d0178dd8f63fc423fd7537ad0738372bd010b3ac9b0"
"checksum libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)" = "76e3a3ef172f1a0b9a9ff0dd1491ae5e6c948b94479a3021819ba7d860c8645d"
"checksum log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "e19e8d5c34a3e0e2223db8e060f9e8264aeeb5c5fc64a4ee9965c062211c024b"
"checksum log 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b3a89a0c46ba789b8a247d4c567aed4d7c68e624672d238b45cc3ec20dc9f940"
"checksum pkg-config 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "3a8b4c6b8165cd1a1cd4b9b120978131389f64bdaf456435caa41e630edba903"
"checksum rand 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)" = "9e7944d95d25ace8f377da3ac7068ce517e4c646754c43a1b1849177bbf72e59"
"checksum redox_syscall 0.1.33 (registry+https://github.com/rust-lang/crates.io-index)" = "07b8f011e3254d5a9b318fde596d409a0001c9ae4c6e7907520c2eaa4d988c99"
"checksum spin 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "7e4deb3c2455c73779e6d3eebceae9599fc70957e54c69fe88f93aa48e62f432"
"checksum log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c84ec4b527950aa83a329754b01dbe3f58361d1c5efacd1f6d68c494d08a17c6"
"checksum pkg-config 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)" = "676e8eb2b1b4c9043511a9b7bea0915320d7e502b0a079fb03f9635a5252b18c"
"checksum rand 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)" = "15a732abf9d20f0ad8eeb6f909bf6868722d9a06e1e50802b6a70351f40b4eb1"
"checksum rand 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "8356f47b32624fef5b3301c1be97e5944ecdd595409cc5da11d05f211db6cfbd"
"checksum redox_syscall 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)" = "cf8fb82a4d1c9b28f1c26c574a5b541f5ffb4315f6c9a791fa47b6a04438fe93"
"checksum spin 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)" = "ceac490aa12c567115b40b7b7fceca03a6c9d53d5defea066123debc83c5dc1f"
"checksum thread-scoped 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "bcbb6aa301e5d3b0b5ef639c9a9c7e2f1c944f177b460c04dc24c69b1fa2bd99"
"checksum time 0.1.38 (registry+https://github.com/rust-lang/crates.io-index)" = "d5d788d3aa77bc0ef3e9621256885555368b47bd495c13dd2e7413c89f845520"
"checksum time 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)" = "d825be0eb33fda1a7e68012d51e9c7f451dc1a69391e7fdc197060bb8c56667b"
"checksum uuid 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "bcc7e3b898aa6f6c08e5295b6c89258d1331e9ac578cc992fb818759951bdc22"
"checksum winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a"
"checksum winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2d315eee3b34aca4797b2da6b13ed88266e6d612562a0c46390af8299fc699bc"
"checksum winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "92c1eb33641e276cfa214a0522acad57be5c56b10cb348b3c5117db75f3ac4b0"
"checksum winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
"checksum winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
......@@ -10,6 +10,7 @@ use redoxfs::{FileSystem, DiskFile};
use uuid::Uuid;
fn main() {
println!("HI");
let mut args = env::args().skip(1);
let disk_path = if let Some(path) = args.next() {
......
#![deny(warnings)]
//#![deny(warnings)]
#![cfg_attr(unix, feature(libc))]
#[cfg(unix)]
......@@ -15,10 +15,28 @@ use std::fs::File;
use std::io::{Read, Write};
use std::os::unix::io::FromRawFd;
use std::process;
use redoxfs::FileSystem;
use redoxfs::{DiskCache, DiskFile, mount};
use std::sync::atomic::{AtomicUsize, Ordering};
use redoxfs::{DiskCache, DiskFile, mount,Disk};
use uuid::Uuid;
#[cfg(target_os = "redox")]
use syscall::{sigaction,sigreturn,SigAction,SIGKILL};
use redoxfs::IS_UMT;
#[cfg(target_os = "redox")]
//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
//send it a sigkill, it shuts off the filesystem
fn setsig() {
sigaction(SIGKILL,Some(&SigAction{sa_handler:hi,sa_mask:[0,0],sa_flags:2}),None).unwrap();
}
#[cfg(unix)]
// on linux, this is implemented properly, so no need for this unscrupulous nonsense!
fn setsig() {
()
}
#[cfg(unix)]
fn fork() -> isize {
unsafe { libc::fork() as isize }
......@@ -124,6 +142,7 @@ fn daemon(disk_id: &DiskId, mountpoint: &str, mut write: File) -> ! {
true
};
setsig();
if matches {
match mount(filesystem, &mountpoint, || {
println!("redoxfs: mounted filesystem on {} to {}", path, mountpoint);
......@@ -158,6 +177,7 @@ fn daemon(disk_id: &DiskId, mountpoint: &str, mut write: File) -> ! {
}
fn main() {
println!("It just works");
let mut args = env::args().skip(1);
let disk_id = match args.next() {
......@@ -206,7 +226,6 @@ fn main() {
let pid = fork();
if pid == 0 {
drop(read);
daemon(&disk_id, &mountpoint, write);
} else if pid > 0 {
drop(write);
......@@ -222,3 +241,9 @@ fn main() {
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,6 +19,8 @@ impl<D: Disk> FileSystem<D> {
disk.read_at(block + header.0, &mut header.1)?;
if header.1.valid() {
header.1.dirty=true;
disk.write_at(header.0, &header.1)?;
let mut root = (header.1.root, Node::default());
disk.read_at(block + root.0, &mut root.1)?;
......@@ -35,6 +37,11 @@ impl<D: Disk> FileSystem<D> {
Err(Error::new(ENOENT))
}
pub fn close(&mut self) -> Result<()> {
self.header.1.dirty=false;
self.disk.write_at(self.header.0, &self.header.1)?;
Ok(())
}
/// Create a file system on a disk
pub fn create(disk: D, ctime: u64, ctime_nsec: u32) -> Result<Self> {
......
......@@ -20,8 +20,9 @@ pub struct Header {
pub root: u64,
/// Block of free space node
pub free: u64,
pub dirty: bool,
/// Padding
pub padding: [u8; BLOCK_SIZE as usize - 56]
pub padding: [u8; BLOCK_SIZE as usize - 57]
}
impl Header {
......@@ -33,7 +34,8 @@ impl Header {
size: 0,
root: 0,
free: 0,
padding: [0; BLOCK_SIZE as usize - 56]
dirty:false,
padding: [0; BLOCK_SIZE as usize - 57]
}
}
......@@ -46,7 +48,8 @@ impl Header {
size: size,
root: root,
free: free,
padding: [0; BLOCK_SIZE as usize - 56]
dirty:false,
padding: [0; BLOCK_SIZE as usize - 57]
}
}
......
......@@ -9,6 +9,7 @@ extern crate uuid;
pub const BLOCK_SIZE: u64 = 4096;
pub const SIGNATURE: &'static [u8; 8] = b"RedoxFS\0";
pub const VERSION: u64 = 3;
pub static IS_UMT: AtomicUsize = AtomicUsize::new(0);
pub use self::disk::{Disk, DiskCache, DiskFile};
pub use self::ex_node::ExNode;
......@@ -17,7 +18,7 @@ pub use self::filesystem::FileSystem;
pub use self::header::Header;
pub use self::mount::mount;
pub use self::node::Node;
use std::sync::atomic::AtomicUsize;
mod disk;
mod ex_node;
mod extent;
......
......@@ -7,6 +7,7 @@ use std::io;
use std::os::unix::ffi::OsStrExt;
use std::path::Path;
use std::time::{SystemTime, UNIX_EPOCH};
use std::io::{ErrorKind,Error};
use BLOCK_SIZE;
use disk::Disk;
......@@ -27,7 +28,9 @@ pub fn mount<D: Disk, P: AsRef<Path>, F: FnMut()>(filesystem: filesystem::FileSy
callback();
session.run()
session.run()?;
session.filesystem.fs.close().map_err(|e| Error::new(ErrorKind::Interrupted,format!("{}",e)))
}
pub struct Fuse<D: Disk> {
......
......@@ -2,18 +2,19 @@ use std::cell::RefCell;
use std::collections::BTreeMap;
use std::result::Result as StdResult;
use std::str;
use std::sync::atomic::{AtomicUsize, Ordering};
use std::time::{SystemTime, UNIX_EPOCH};
use syscall::data::{Stat, StatVfs, TimeSpec};
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::scheme::Scheme;
use std::sync::atomic::{AtomicUsize, Ordering};
use syscall::EINTR;
use BLOCK_SIZE;
use disk::Disk;
use filesystem::FileSystem;
use node::Node;
use IS_UMT;
use super::resource::{Resource, DirResource, FileResource};
use super::spin::Mutex;
......@@ -251,8 +252,8 @@ pub fn canonicalize(current: &[u8], path: &[u8]) -> Vec<u8> {
impl<D: Disk> Scheme for FileScheme<D> {
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('/');
// println!("Open '{}' {:X}", path, flags);
let mut fs = self.fs.borrow_mut();
......@@ -387,6 +388,10 @@ impl<D: Disk> Scheme for FileScheme<D> {
}
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('/');
// println!("Chmod '{}'", path);
......@@ -408,6 +413,10 @@ impl<D: Disk> Scheme for FileScheme<D> {
}
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('/');
// println!("Rmdir '{}'", path);
......@@ -445,6 +454,11 @@ impl<D: Disk> Scheme for FileScheme<D> {
}
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('/');
// println!("Unlink '{}'", path);
......@@ -488,6 +502,10 @@ impl<D: Disk> Scheme for FileScheme<D> {
/* Resource operations */
#[allow(unused_variables)]
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);
if ! buf.is_empty() {
......@@ -509,6 +527,13 @@ impl<D: Disk> Scheme for FileScheme<D> {
#[allow(unused_variables)]
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());
let mut files = self.files.lock();
if let Some(file) = files.get_mut(&id) {
......@@ -519,6 +544,15 @@ impl<D: Disk> Scheme for FileScheme<D> {
}
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());
let mut files = self.files.lock();
if let Some(file) = files.get_mut(&id) {
......@@ -529,6 +563,13 @@ impl<D: Disk> Scheme for FileScheme<D> {
}
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);
let mut files = self.files.lock();
if let Some(file) = files.get_mut(&id) {
......@@ -539,6 +580,10 @@ impl<D: Disk> Scheme for FileScheme<D> {
}
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();
if let Some(file) = files.get_mut(&id) {
file.fchmod(mode, &mut self.fs.borrow_mut())
......@@ -548,6 +593,10 @@ impl<D: Disk> Scheme for FileScheme<D> {
}
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();
if let Some(file) = files.get_mut(&id) {
file.fchown(uid, gid, &mut self.fs.borrow_mut())
......@@ -557,6 +606,10 @@ impl<D: Disk> Scheme for FileScheme<D> {
}
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();
if let Some(file) = files.get_mut(&id) {
file.fcntl(cmd, arg)
......@@ -566,6 +619,10 @@ impl<D: Disk> Scheme for FileScheme<D> {
}
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());
let files = self.files.lock();
if let Some(file) = files.get(&id) {
......@@ -592,6 +649,10 @@ impl<D: Disk> Scheme for FileScheme<D> {
}
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('/');
// println!("Frename {}, {} from {}, {}", id, path, uid, gid);
......@@ -720,6 +781,10 @@ impl<D: Disk> Scheme for FileScheme<D> {
}
fn fsync(&self, id: usize) -> Result<usize> {
//block
if 1 == IS_UMT.load(Ordering::Relaxed) {
return Err(Error::new(EINTR));
}
// println!("Fsync {}", id);
let mut files = self.files.lock();
if let Some(file) = files.get_mut(&id) {
......@@ -730,6 +795,10 @@ impl<D: Disk> Scheme for FileScheme<D> {
}
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);
let mut files = self.files.lock();
if let Some(file) = files.get_mut(&id) {
......@@ -740,6 +809,10 @@ impl<D: Disk> Scheme for FileScheme<D> {
}
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());
let mut files = self.files.lock();
if let Some(file) = files.get_mut(&id) {
......@@ -750,6 +823,10 @@ impl<D: Disk> Scheme for FileScheme<D> {
}
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);
let mut files = self.files.lock();
if let Some(file) = files.get_mut(&id) {
......
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