Update fs module

master
Harry Cheng 5 years ago
parent 804d6254f9
commit b9911a58ac

14
kernel/Cargo.lock generated

@ -393,8 +393,8 @@ dependencies = [
"pc-keyboard 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
"pci 0.0.1 (git+https://github.com/rcore-os/pci-rs)",
"raw-cpuid 6.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"rcore-fs 0.1.0 (git+https://github.com/rcore-os/rcore-fs)",
"rcore-fs-sfs 0.1.0 (git+https://github.com/rcore-os/rcore-fs)",
"rcore-fs 0.1.0 (git+https://github.com/chengyuhui/rcore-fs)",
"rcore-fs-sfs 0.1.0 (git+https://github.com/chengyuhui/rcore-fs)",
"rcore-memory 0.1.0",
"rcore-thread 0.1.0 (git+https://github.com/rcore-os/rcore-thread)",
"riscv 0.5.0 (git+https://github.com/rcore-os/riscv)",
@ -409,7 +409,7 @@ dependencies = [
[[package]]
name = "rcore-fs"
version = "0.1.0"
source = "git+https://github.com/rcore-os/rcore-fs#ee0d0b31a1cea4c905100cef501a3bc522ded00d"
source = "git+https://github.com/chengyuhui/rcore-fs#91365dcfa889ef1f20f4559ed4a9d08d21476ed8"
dependencies = [
"spin 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
@ -417,11 +417,11 @@ dependencies = [
[[package]]
name = "rcore-fs-sfs"
version = "0.1.0"
source = "git+https://github.com/rcore-os/rcore-fs#ee0d0b31a1cea4c905100cef501a3bc522ded00d"
source = "git+https://github.com/chengyuhui/rcore-fs#91365dcfa889ef1f20f4559ed4a9d08d21476ed8"
dependencies = [
"bitvec 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
"rcore-fs 0.1.0 (git+https://github.com/rcore-os/rcore-fs)",
"rcore-fs 0.1.0 (git+https://github.com/chengyuhui/rcore-fs)",
"spin 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)",
"static_assertions 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
@ -732,8 +732,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
"checksum rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7a6fdeb83b075e8266dcc8762c22776f6877a63111121f5f8c7411e5be7eed4b"
"checksum rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d0e7a549d590831370895ab7ba4ea0c1b6b011d106b5ff2da6eee112615e6dc0"
"checksum raw-cpuid 6.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "30a9d219c32c9132f7be513c18be77c9881c7107d2ab5569d205a6a0f0e6dc7d"
"checksum rcore-fs 0.1.0 (git+https://github.com/rcore-os/rcore-fs)" = "<none>"
"checksum rcore-fs-sfs 0.1.0 (git+https://github.com/rcore-os/rcore-fs)" = "<none>"
"checksum rcore-fs 0.1.0 (git+https://github.com/chengyuhui/rcore-fs)" = "<none>"
"checksum rcore-fs-sfs 0.1.0 (git+https://github.com/chengyuhui/rcore-fs)" = "<none>"
"checksum rcore-thread 0.1.0 (git+https://github.com/rcore-os/rcore-thread)" = "<none>"
"checksum rdrand 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "678054eb77286b51581ba43620cc911abf02758c91f93f479767aed0f90458b2"
"checksum register 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "e10f31b6d2299e5620986ad9fcdd66463e125ad72af4f403f9aedf7592d5ccdb"

@ -65,8 +65,8 @@ smoltcp = { git = "https://github.com/rcore-os/smoltcp", default-features = fals
bitmap-allocator = { git = "https://github.com/rcore-os/bitmap-allocator" }
rcore-memory = { path = "../crate/memory" }
rcore-thread = { git = "https://github.com/rcore-os/rcore-thread" }
rcore-fs = { git = "https://github.com/rcore-os/rcore-fs" }
rcore-fs-sfs = { git = "https://github.com/rcore-os/rcore-fs" }
rcore-fs = { git = "https://github.com/chengyuhui/rcore-fs" }
rcore-fs-sfs = { git = "https://github.com/chengyuhui/rcore-fs" }
[target.'cfg(target_arch = "x86_64")'.dependencies]
bootloader = { git = "https://github.com/rcore-os/bootloader", branch = "vga" }

@ -124,7 +124,7 @@ impl FileHandle {
self.inode.lookup_follow(path, max_follow)
}
pub fn read_entry(&mut self) -> Result<String> {
pub fn read_entry(&mut self) -> Result<(usize, String)> {
if !self.options.read {
return Err(FsError::InvalidParam); // FIXME: => EBADF
}

@ -79,7 +79,7 @@ macro_rules! impl_inode {
fn link(&self, _name: &str, _other: &Arc<dyn INode>) -> Result<()> { Err(FsError::NotDir) }
fn move_(&self, _old_name: &str, _target: &Arc<dyn INode>, _new_name: &str) -> Result<()> { Err(FsError::NotDir) }
fn find(&self, _name: &str) -> Result<Arc<dyn INode>> { Err(FsError::NotDir) }
fn get_entry(&self, _id: usize) -> Result<String> { Err(FsError::NotDir) }
fn get_entry(&self, _id: usize) -> Result<(usize, String)> { Err(FsError::NotDir) }
fn io_control(&self, _cmd: u32, _data: usize) -> Result<()> { Err(FsError::NotSupported) }
fn fs(&self) -> Arc<dyn FileSystem> { unimplemented!() }
fn as_any_ref(&self) -> &dyn Any { self }

@ -31,7 +31,7 @@ macro_rules! impl_inode {
fn link(&self, _name: &str, _other: &Arc<dyn INode>) -> Result<()> { Err(FsError::NotDir) }
fn move_(&self, _old_name: &str, _target: &Arc<dyn INode>, _new_name: &str) -> Result<()> { Err(FsError::NotDir) }
fn find(&self, _name: &str) -> Result<Arc<dyn INode>> { Err(FsError::NotDir) }
fn get_entry(&self, _id: usize) -> Result<String> { Err(FsError::NotDir) }
fn get_entry(&self, _id: usize) -> Result<(usize, String)> { Err(FsError::NotDir) }
fn io_control(&self, _cmd: u32, _data: usize) -> Result<()> { Err(FsError::NotSupported) }
fn fs(&self) -> Arc<dyn FileSystem> { unimplemented!() }
fn as_any_ref(&self) -> &dyn Any { self }

@ -66,7 +66,7 @@ macro_rules! impl_inode {
fn link(&self, _name: &str, _other: &Arc<dyn INode>) -> Result<()> { Err(FsError::NotDir) }
fn move_(&self, _old_name: &str, _target: &Arc<dyn INode>, _new_name: &str) -> Result<()> { Err(FsError::NotDir) }
fn find(&self, _name: &str) -> Result<Arc<dyn INode>> { Err(FsError::NotDir) }
fn get_entry(&self, _id: usize) -> Result<String> { Err(FsError::NotDir) }
fn get_entry(&self, _id: usize) -> Result<(usize, String)> { Err(FsError::NotDir) }
fn io_control(&self, cmd: u32, data: usize) -> Result<()> {
match cmd as usize {
TCGETS | TIOCGWINSZ | TIOCSPGRP => {

@ -19,7 +19,7 @@ macro_rules! impl_inode {
fn link(&self, _name: &str, _other: &Arc<dyn INode>) -> Result<()> { Err(FsError::NotDir) }
fn move_(&self, _old_name: &str, _target: &Arc<dyn INode>, _new_name: &str) -> Result<()> { Err(FsError::NotDir) }
fn find(&self, _name: &str) -> Result<Arc<dyn INode>> { Err(FsError::NotDir) }
fn get_entry(&self, _id: usize) -> Result<String> { Err(FsError::NotDir) }
fn get_entry(&self, _id: usize) -> Result<(usize, String)> { Err(FsError::NotDir) }
fn fs(&self) -> Arc<dyn FileSystem> { unimplemented!() }
fn as_any_ref(&self) -> &dyn Any { self }
};

@ -496,12 +496,11 @@ impl Syscall<'_> {
}
let mut writer = DirentBufWriter::new(buf);
loop {
let name = match file.read_entry() {
let entry = match file.read_entry() {
Err(FsError::EntryNotFound) => break,
r => r,
}?;
// TODO: get ino from dirent
let ok = writer.try_write(0, DirentType::from_type(&info.type_).bits(), &name);
let ok = writer.try_write(entry.0 as u64, DirentType::from_type(&info.type_).bits(), &entry.1);
if !ok {
break;
}
@ -951,6 +950,8 @@ impl From<FsError> for SysError {
FsError::IOCTLError => SysError::EINVAL,
FsError::NoDevice => SysError::EINVAL,
FsError::Again => SysError::EAGAIN,
FsError::Busy => SysError::EBUSY,
FsError::SymLoop => SysError::ELOOP,
}
}
}

@ -473,6 +473,7 @@ pub enum SysError {
ENOLCK = 37,
ENOSYS = 38,
ENOTEMPTY = 39,
ELOOP = 40,
ENOTSOCK = 80,
ENOPROTOOPT = 92,
EPFNOSUPPORT = 96,

Loading…
Cancel
Save