rename 'sfs-c' to 'rcore-fs-ucore', update to Rust 2018

master
WangRunji 6 years ago
parent 066cd14cce
commit f7c75234de

@ -13,7 +13,6 @@ required-features = ["std"]
bit-vec = { default-features = false, git = "https://github.com/AltSysrq/bit-vec.git" } # default-features contains 'std'
static_assertions = "0.3"
spin = "0.4"
time = "0.1"
[features]
std = []

@ -25,15 +25,21 @@ impl<T: vfs::FileSystem> VfsWrapper<T> {
inodes.insert(1, fs.root_inode());
VfsWrapper { fs, inodes }
}
fn trans_time(time: vfs::Timespec) -> Timespec {
Timespec {
sec: time.sec,
nsec: time.nsec,
}
}
fn trans_attr(info: vfs::FileInfo) -> FileAttr {
FileAttr {
ino: info.inode as u64,
size: info.size as u64,
blocks: info.blocks as u64,
atime: info.atime,
mtime: info.mtime,
ctime: info.ctime,
crtime: Timespec::new(0, 0),
atime: Self::trans_time(info.atime),
mtime: Self::trans_time(info.mtime),
ctime: Self::trans_time(info.ctime),
crtime: Timespec { sec: 0, nsec: 0 },
kind: Self::trans_type(info.type_),
perm: info.mode,
nlink: info.nlinks as u32,

@ -1,7 +1,8 @@
[package]
name = "sfs-c"
version = "0.0.1"
name = "rcore-fs-ucore"
version = "0.1.0"
authors = ["WangRunji <wangrunji0408@163.com>"]
edition = "2018"
[lib]
crate-type = ["staticlib"]
@ -11,7 +12,10 @@ panic = 'abort' # prevent `_Unwind_Resume` link error
[dependencies]
bitflags = "1.0"
static_assertions = "0.2.5"
static_assertions = "0.3"
simple-filesystem = { path = ".." }
spin = "0.4"
lazy_static = { version = "1.1", features = ["spin_no_std"] }
lazy_static = { version = "1.2", features = ["spin_no_std"] }
[features]
debug_print = []

@ -1,5 +1,5 @@
ucore:
rustup override set nightly
rustup override set nightly-2019-01-28
cargo xbuild --target ucore.json --release
install-rust:

@ -3,42 +3,32 @@
//! NOTE: Must link these sections:
//! `*.got.*` `*.data.*` `*.rodata.*`
#![feature(allocator_api)]
#![feature(lang_items)]
#![feature(alloc)]
#![feature(panic_info_message)]
#![feature(compiler_builtins_lib)]
#![no_std]
#[macro_use]
extern crate alloc;
extern crate simple_filesystem;
#[macro_use]
extern crate bitflags;
#[macro_use]
extern crate static_assertions;
#[macro_use]
extern crate lazy_static;
extern crate spin;
#[macro_use]
extern crate static_assertions;
use alloc::{sync::Arc, boxed::Box, collections::BTreeMap};
use core::cell::RefCell;
use core::slice;
use core::ops::Deref;
use core::cmp::Ordering;
use alloc::{boxed::Box, collections::BTreeMap, sync::Arc};
use core::alloc::{GlobalAlloc, Layout};
use core::mem::{size_of, self};
use core::ptr;
use simple_filesystem as sfs;
use simple_filesystem as vfs;
use vfs::FileSystem;
use core::mem;
use core::ops::Deref;
use core::slice;
use simple_filesystem::{sfs, vfs};
use spin::Mutex;
/// Lang items for bare lib
mod lang {
use alloc::fmt;
use core::panic::PanicInfo;
use core::alloc::Layout;
use core::panic::PanicInfo;
#[lang = "eh_personality"]
#[no_mangle]
@ -52,7 +42,7 @@ mod lang {
#[panic_handler]
#[no_mangle]
extern fn panic_fmt(info: &PanicInfo) -> ! {
extern fn panic(info: &PanicInfo) -> ! {
use super::ucore::__panic;
let location = info.location().unwrap();
let message = info.message().unwrap();
@ -120,7 +110,6 @@ mod libc {
#[no_mangle]
pub extern fn sfs_do_mount(dev: *mut Device, fs_store: &mut *mut Fs) -> ErrorCode {
use sfs;
let fs = unsafe { ucore::create_fs_for_sfs(&FS_OPS) };
debug_assert!(!dev.is_null());
let mut device = unsafe { Box::from_raw(dev) }; // TODO: fix unsafe
@ -521,7 +510,7 @@ static INODE_OPS: INodeOps = {
let pos = pos as usize;
let info = inode.info().unwrap();
if pos > info.size {
inode.resize(pos);
inode.resize(pos).unwrap();
}
return ErrorCode::Ok;
}

@ -24,15 +24,11 @@ mod structs;
#[cfg(test)]
mod tests;
pub use crate::sfs::*;
pub use crate::vfs::*;
pub use crate::blocked_device::BlockedDevice;
#[cfg(any(test, feature = "std"))]
pub mod std_impl {
use std::fs::File;
use std::io::{Read, Write, Seek, SeekFrom};
use super::Device;
use super::vfs::Device;
impl Device for File {
fn read_at(&mut self, offset: usize, buf: &mut [u8]) -> Option<usize> {
@ -51,4 +47,4 @@ pub mod std_impl {
}
}
}
}
}

@ -6,12 +6,11 @@ use core::slice;
use bit_vec::BitVec;
use spin::{Mutex, RwLock};
use time::Timespec;
use crate::dirty::Dirty;
use crate::structs::*;
use crate::util::*;
use crate::vfs::{self, Device, FileSystem, FsError, INode};
use crate::vfs::{self, Device, FileSystem, FsError, INode, Timespec};
impl Device {
fn read_block(&mut self, id: BlockId, offset: usize, buf: &mut [u8]) -> vfs::Result<()> {
@ -277,9 +276,9 @@ impl vfs::INode for INodeImpl {
mode: 0o777,
type_: vfs::FileType::from(disk_inode.type_.clone()),
blocks: disk_inode.blocks as usize,
atime: Timespec::new(0, 0),
mtime: Timespec::new(0, 0),
ctime: Timespec::new(0, 0),
atime: Timespec { sec: 0, nsec: 0 },
mtime: Timespec { sec: 0, nsec: 0 },
ctime: Timespec { sec: 0, nsec: 0 },
nlinks: disk_inode.nlinks as usize,
uid: 0,
gid: 0,

@ -1,7 +1,7 @@
use alloc::{vec::Vec, string::String, sync::Arc};
use core::any::Any;
use core::result;
use time::Timespec;
pub use super::blocked_device::BlockedDevice;
/// Interface for FS to read & write
/// TODO: use std::io::{Read, Write}
@ -111,6 +111,12 @@ pub struct FileInfo {
pub gid: usize,
}
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Debug, Hash)]
pub struct Timespec {
pub sec: i64,
pub nsec: i32
}
#[derive(Debug, Eq, PartialEq)]
pub enum FileType {
File,

Loading…
Cancel
Save