diff --git a/Cargo.toml b/Cargo.toml index 55440d9..0c5472a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,6 +2,7 @@ name = "simple-filesystem" version = "0.0.1" authors = ["WangRunji "] +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] diff --git a/src/bin/mksfs.rs b/src/bin/mksfs.rs index cfee1a8..63ccf46 100644 --- a/src/bin/mksfs.rs +++ b/src/bin/mksfs.rs @@ -1,5 +1,3 @@ -extern crate simple_filesystem; - use std::env; use std::fs; use std::io::{Read, Write, Result}; diff --git a/src/blocked_device.rs b/src/blocked_device.rs index 98e1bf2..5e1ff0a 100644 --- a/src/blocked_device.rs +++ b/src/blocked_device.rs @@ -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 { diff --git a/src/file.rs b/src/file.rs index 6c1886e..6cc6684 100644 --- a/src/file.rs +++ b/src/file.rs @@ -1,4 +1,4 @@ -use vfs::{INode, Result, FileInfo}; +use crate::vfs::{INode, Result, FileInfo}; use alloc::{sync::Arc, string::String}; pub struct File { diff --git a/src/lib.rs b/src/lib.rs index 94ae27b..f2f4a73 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -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 { diff --git a/src/sfs.rs b/src/sfs.rs index 41bdcf4..37c4214 100644 --- a/src/sfs.rs +++ b/src/sfs.rs @@ -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"); } } diff --git a/src/structs.rs b/src/structs.rs index e5e14a0..ed4a7d7 100644 --- a/src/structs.rs +++ b/src/structs.rs @@ -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)] diff --git a/src/tests.rs b/src/tests.rs index 1cbbe5a..98efd35 100644 --- a/src/tests.rs +++ b/src/tests.rs @@ -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 { fs::copy("sfs.img", "test.img").expect("failed to open sfs.img");