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