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

parent d53fc6af
Pipeline #2148 passed with stages
in 45 seconds
//#![deny(warnings)]
#![deny(warnings)]
#![cfg_attr(unix, feature(libc))]
#[cfg(unix)]
......@@ -10,22 +10,19 @@ extern crate syscall;
extern crate redoxfs;
extern crate uuid;
use redoxfs::{DiskCache, DiskFile, mount};
use std::env;
use std::fs::File;
use std::io::{Read, Write};
use std::os::unix::io::FromRawFd;
use std::process;
use std::sync::atomic::Ordering;
use uuid::Uuid;
#[cfg(target_os = "redox")]
use syscall::{sigaction, SigAction, SIGTERM};
use redoxfs::IS_UMT;
use redoxfs::{DiskCache, DiskFile, mount};
use uuid::Uuid;
#[cfg(target_os = "redox")]
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")]
......@@ -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
//send it a sigkill, it shuts off the filesystem
fn setsig() {
use syscall::{sigaction, SigAction, SIGTERM};
let sig_action = SigAction {
sa_handler: unmount_handler,
sa_mask: [0,0],
......
......@@ -19,8 +19,6 @@ 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)?;
......@@ -38,12 +36,6 @@ 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> {
Self::create_reserved(disk, &[], ctime, ctime_nsec)
......
......@@ -20,10 +20,8 @@ pub struct Header {
pub root: u64,
/// Block of free space node
pub free: u64,
/// True if the filesystem is currently mounted
pub dirty: bool,
/// Padding
pub padding: [u8; BLOCK_SIZE as usize - 57]
pub padding: [u8; BLOCK_SIZE as usize - 56]
}
impl Header {
......@@ -35,8 +33,7 @@ impl Header {
size: 0,
root: 0,
free: 0,
dirty:false,
padding: [0; BLOCK_SIZE as usize - 57]
padding: [0; BLOCK_SIZE as usize - 56]
}
}
......@@ -49,8 +46,7 @@ impl Header {
size: size,
root: root,
free: free,
dirty:false,
padding: [0; BLOCK_SIZE as usize - 57]
padding: [0; BLOCK_SIZE as usize - 56]
}
}
......
......@@ -4,7 +4,6 @@ extern crate time;
use std::cmp;
use std::ffi::OsStr;
use std::io;
use std::io::{ErrorKind, Error};
use std::os::unix::ffi::OsStrExt;
use std::path::Path;
use std::time::{SystemTime, UNIX_EPOCH};
......@@ -28,10 +27,7 @@ pub fn mount<D: Disk, P: AsRef<Path>, F: FnMut()>(filesystem: filesystem::FileSy
callback();
session.run()?;
session.filesystem.fs.close().map_err(|e| Error::new(ErrorKind::Interrupted,format!("{}",e)))
session.run()
}
pub struct Fuse<D: Disk> {
......
......@@ -3,7 +3,7 @@ extern crate spin;
use syscall;
use syscall::{Packet, Scheme};
use std::fs::File;
use std::io::{Error, ErrorKind, Read, Result, Write};
use std::io::{self, Read, Write};
use std::path::Path;
use std::sync::atomic::Ordering;
......@@ -16,7 +16,7 @@ use self::scheme::FileScheme;
pub mod resource;
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 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
syscall::setrens(0, 0).expect("redoxfs: failed to enter null namespace");
let scheme = FileScheme::new(format!("{}", mountpoint.display()), filesystem);
let res = loop {
loop {
if IS_UMT.load(Ordering::SeqCst) > 0 {
break Ok(());
}
......@@ -33,7 +33,7 @@ pub fn mount<D: Disk, P: AsRef<Path>, F: FnMut()>(filesystem: FileSystem<D>, mou
let mut packet = Packet::default();
match socket.read(&mut packet) {
Ok(_ok) => (),
Err(err) => if err.kind() == ErrorKind::Interrupted {
Err(err) => if err.kind() == io::ErrorKind::Interrupted {
continue;
} else {
break Err(err);
......@@ -48,12 +48,5 @@ pub fn mount<D: Disk, P: AsRef<Path>, F: FnMut()>(filesystem: FileSystem<D>, mou
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 {
pub struct FileScheme<D: Disk> {
name: String,
pub(crate) fs: RefCell<FileSystem<D>>,
fs: RefCell<FileSystem<D>>,
next_id: AtomicUsize,
files: Mutex<BTreeMap<usize, Box<Resource<D>>>>,
fmaps: Mutex<Fmaps>
......
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