update to 2018 edition

master
WangRunji 6 years ago
parent 24a51faff2
commit 919545b2ae

@ -2,6 +2,7 @@
name = "simple-filesystem"
version = "0.0.1"
authors = ["WangRunji <wangrunji0408@163.com>"]
edition = "2018"
[[bin]]
name = "mksfs"
@ -10,7 +11,7 @@ required-features = ["std"]
[dependencies]
bit-vec = { default-features = false, git = "https://github.com/AltSysrq/bit-vec.git" } # default-features contains 'std'
static_assertions = "0.2.5"
static_assertions = "0.3"
spin = "0.4"
[features]

@ -1,5 +1,3 @@
extern crate simple_filesystem;
use std::env;
use std::fs;
use std::io::{Read, Write, Result};

@ -1,5 +1,5 @@
use util::*;
use vfs::Device;
use crate::util::*;
use crate::vfs::Device;
/// Device which can only R/W in blocks
pub trait BlockedDevice: Send {

@ -1,4 +1,4 @@
use vfs::{INode, Result, FileInfo};
use crate::vfs::{INode, Result, FileInfo};
use alloc::{sync::Arc, string::String};
pub struct File {

@ -1,17 +1,10 @@
#![cfg_attr(not(any(test, feature = "std")), no_std)]
#![feature(alloc)]
#![feature(const_fn)]
#![feature(nll)]
#![cfg_attr(target_arch = "riscv", feature(match_default_bindings))]
#![no_std]
#![feature(extern_crate_item_prelude)]
#[cfg(any(test, feature = "std"))]
#[macro_use]
extern crate std;
extern crate alloc;
extern crate bit_vec;
#[macro_use]
extern crate static_assertions;
extern crate spin;
#[cfg(not(test))]
macro_rules! eprintln {
@ -30,9 +23,9 @@ mod structs;
#[cfg(test)]
mod tests;
pub use sfs::*;
pub use vfs::*;
pub use blocked_device::BlockedDevice;
pub use crate::sfs::*;
pub use crate::vfs::*;
pub use crate::blocked_device::BlockedDevice;
#[cfg(any(test, feature = "std"))]
pub mod std_impl {

@ -4,11 +4,11 @@ use core::mem::uninitialized;
use core::slice;
use core::fmt::{Debug, Formatter, Error};
use core::any::Any;
use dirty::Dirty;
use structs::*;
use vfs::{self, Device, INode, FileSystem};
use util::*;
use spin::{Mutex, RwLock};
use crate::dirty::Dirty;
use crate::structs::*;
use crate::vfs::{self, Device, INode, FileSystem};
use crate::util::*;
impl Device {
fn read_block(&mut self, id: BlockId, offset: usize, buf: &mut [u8]) -> vfs::Result<()> {
@ -622,7 +622,7 @@ impl vfs::FileSystem for SimpleFileSystem {
impl Drop for SimpleFileSystem {
/// Auto sync when drop
fn drop(&mut self) {
use vfs::FileSystem;
use crate::vfs::FileSystem;
self.sync().expect("failed to sync");
}
}

@ -4,6 +4,7 @@ use core::slice;
use core::mem::{size_of_val, size_of};
use core::fmt::{Debug, Formatter, Error};
use alloc::str;
use static_assertions::const_assert;
/// On-disk superblock
#[repr(C)]

@ -3,10 +3,10 @@ use std::io::{Read, Write, Seek, SeekFrom};
use std::boxed::Box;
use std::sync::Arc;
use std::mem::uninitialized;
use super::sfs::*;
use super::vfs::*;
use super::vfs::INode;
use super::structs::{DiskEntry, AsBuf};
use crate::sfs::*;
use crate::vfs::*;
use crate::vfs::INode;
use crate::structs::{DiskEntry, AsBuf};
fn _open_sample_file() -> Arc<SimpleFileSystem> {
fs::copy("sfs.img", "test.img").expect("failed to open sfs.img");

Loading…
Cancel
Save