Verified Commit 3ae32d99 authored by Jeremy Soller's avatar Jeremy Soller
Browse files

Reduce diff - remove dirty flag as it could be added in a separate change

parent d53fc6af
//#![deny(warnings)] #![deny(warnings)]
#![cfg_attr(unix, feature(libc))] #![cfg_attr(unix, feature(libc))]
#[cfg(unix)] #[cfg(unix)]
...@@ -10,22 +10,19 @@ extern crate syscall; ...@@ -10,22 +10,19 @@ 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 std::sync::atomic::Ordering;
use uuid::Uuid;
#[cfg(target_os = "redox")] use redoxfs::{DiskCache, DiskFile, mount};
use syscall::{sigaction, SigAction, SIGTERM}; use uuid::Uuid;
use redoxfs::IS_UMT;
#[cfg(target_os = "redox")] #[cfg(target_os = "redox")]
extern "C" fn unmount_handler(_s: usize) { extern "C" fn unmount_handler(_s: usize) {
IS_UMT.store(1, Ordering::SeqCst); use std::sync::atomic::Ordering;
redoxfs::IS_UMT.store(1, Ordering::SeqCst);
} }
#[cfg(target_os = "redox")] #[cfg(target_os = "redox")]
...@@ -33,6 +30,8 @@ extern "C" fn unmount_handler(_s: usize) { ...@@ -33,6 +30,8 @@ extern "C" fn unmount_handler(_s: usize) {
//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() {
use syscall::{sigaction, SigAction, SIGTERM};
let sig_action = SigAction { let sig_action = SigAction {
sa_handler: unmount_handler, sa_handler: unmount_handler,
sa_mask: [0,0], sa_mask: [0,0],
......
...@@ -19,8 +19,6 @@ impl<D: Disk> FileSystem<D> { ...@@ -19,8 +19,6 @@ 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;
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)?;
...@@ -38,12 +36,6 @@ impl<D: Disk> FileSystem<D> { ...@@ -38,12 +36,6 @@ impl<D: Disk> FileSystem<D> {
Err(Error::new(ENOENT)) 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 /// Create a file system on a disk
pub fn create(disk: D, ctime: u64, ctime_nsec: u32) -> Result<Self> { pub fn create(disk: D, ctime: u64, ctime_nsec: u32) -> Result<Self> {
Self::create_reserved(disk, &[], ctime, ctime_nsec) Self::create_reserved(disk, &[], ctime, ctime_nsec)
......
...@@ -20,10 +20,8 @@ pub struct Header { ...@@ -20,10 +20,8 @@ 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,
/// Padding /// Padding
pub padding: [u8; BLOCK_SIZE as usize - 57] pub padding: [u8; BLOCK_SIZE as usize - 56]
} }
impl Header { impl Header {
...@@ -35,8 +33,7 @@ impl Header { ...@@ -35,8 +33,7 @@ impl Header {
size: 0, size: 0,
root: 0, root: 0,
free: 0, free: 0,
dirty:false, padding: [0; BLOCK_SIZE as usize - 56]
padding: [0; BLOCK_SIZE as usize - 57]
} }
} }
...@@ -49,8 +46,7 @@ impl Header { ...@@ -49,8 +46,7 @@ impl Header {
size: size, size: size,
root: root, root: root,
free: free, free: free,
dirty:false, padding: [0; BLOCK_SIZE as usize - 56]
padding: [0; BLOCK_SIZE as usize - 57]
} }
} }
......
...@@ -4,7 +4,6 @@ extern crate time; ...@@ -4,7 +4,6 @@ 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};
...@@ -28,10 +27,7 @@ pub fn mount<D: Disk, P: AsRef<Path>, F: FnMut()>(filesystem: filesystem::FileSy ...@@ -28,10 +27,7 @@ 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)))
} }
pub struct Fuse<D: Disk> { pub struct Fuse<D: Disk> {
......
...@@ -3,7 +3,7 @@ extern crate spin; ...@@ -3,7 +3,7 @@ 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::{Error, ErrorKind, Read, Result, Write}; use std::io::{self, Read, Write};
use std::path::Path; use std::path::Path;
use std::sync::atomic::Ordering; use std::sync::atomic::Ordering;
...@@ -16,7 +16,7 @@ use self::scheme::FileScheme; ...@@ -16,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) -> Result<()> { pub fn mount<D: Disk, P: AsRef<Path>, F: FnMut()>(filesystem: FileSystem<D>, mountpoint: &P, mut callback: F) -> io::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()))?;
...@@ -25,7 +25,7 @@ pub fn mount<D: Disk, P: AsRef<Path>, F: FnMut()>(filesystem: FileSystem<D>, mou ...@@ -25,7 +25,7 @@ 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);
let res = loop { loop {
if IS_UMT.load(Ordering::SeqCst) > 0 { if IS_UMT.load(Ordering::SeqCst) > 0 {
break Ok(()); break Ok(());
} }
...@@ -33,7 +33,7 @@ pub fn mount<D: Disk, P: AsRef<Path>, F: FnMut()>(filesystem: FileSystem<D>, mou ...@@ -33,7 +33,7 @@ pub fn mount<D: Disk, P: AsRef<Path>, F: FnMut()>(filesystem: FileSystem<D>, mou
let mut packet = Packet::default(); let mut packet = Packet::default();
match socket.read(&mut packet) { match socket.read(&mut packet) {
Ok(_ok) => (), Ok(_ok) => (),
Err(err) => if err.kind() == ErrorKind::Interrupted { Err(err) => if err.kind() == io::ErrorKind::Interrupted {
continue; continue;
} else { } else {
break Err(err); break Err(err);
...@@ -48,12 +48,5 @@ pub fn mount<D: Disk, P: AsRef<Path>, F: FnMut()>(filesystem: FileSystem<D>, mou ...@@ -48,12 +48,5 @@ pub fn mount<D: Disk, P: AsRef<Path>, F: FnMut()>(filesystem: FileSystem<D>, mou
break Err(err); break Err(err);
} }
} }
};
{
let mut fs = scheme.fs.borrow_mut();
fs.close().map_err(|e| Error::new(ErrorKind::Interrupted,format!("{}",e)))?;
} }
res
} }
...@@ -89,7 +89,7 @@ impl Fmaps { ...@@ -89,7 +89,7 @@ impl Fmaps {
pub struct FileScheme<D: Disk> { pub struct FileScheme<D: Disk> {
name: String, name: String,
pub(crate) fs: RefCell<FileSystem<D>>, 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>
......
Supports Markdown
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