update to 2018 edition

master
WangRunji 6 years ago
parent 24a51faff2
commit 919545b2ae

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

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

@ -1,5 +1,5 @@
use util::*; use crate::util::*;
use vfs::Device; use crate::vfs::Device;
/// Device which can only R/W in blocks /// Device which can only R/W in blocks
pub trait BlockedDevice: Send { 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}; use alloc::{sync::Arc, string::String};
pub struct File { pub struct File {

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

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

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

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

Loading…
Cancel
Save