A simple filesystem implementation for the rCore tutorial operating system.
- 提供教学友好的简化文件系统实现(EasyFS)。
- 让章节内核在
no_std环境中具备“文件 + 目录 + 管道”基础能力。 - 统一块设备抽象,便于接入 virtio-block 或镜像构建工具。
- 设备层:
BlockDevicetrait。 - 缓存层:块缓存与同步机制。
- 布局层:位图、inode、目录项等磁盘格式定义。
- 接口层:
EasyFileSystemInodeFileHandlePipeReader/PipeWriter
- 块设备抽象(默认 512B block)。
- inode 风格文件系统结构。
- 块缓存 + 位图分配。
- 支持 pipe IPC。
- 可用于内核运行期与构建期镜像准备(
build.rs)。
- 文件系统元数据与数据块均通过块缓存统一读写。
- inode 提供目录查找、文件读写、清理等高层接口。
- 管道使用独立读写端对象,服务进程间流式通信。
- trait:
BlockDevice
- 常量:
BLOCK_SZ
- 核心类型:
EasyFileSystemInodeFileHandlePipeReader,PipeWriter
- 函数:
make_pipe()get_block_cache(...)block_cache_sync_all()
use tg_easy_fs::{EasyFileSystem, BlockDevice};
fn open_fs(dev: alloc::sync::Arc<dyn BlockDevice>) {
let _efs = EasyFileSystem::open(dev);
}- 章节内真实用法:
tg-rcore-tutorial-ch6/src/fs.rs中进行文件系统与文件接口调用。tg-rcore-tutorial-ch6/build.rs、tg-rcore-tutorial-ch7/build.rs、tg-rcore-tutorial-ch8/build.rs用于准备镜像内容。
- 直接依赖章节:
tg-rcore-tutorial-ch6到tg-rcore-tutorial-ch8(含build-dependencies)。 - 关键职责:提供文件系统、文件描述符与管道能力。
- 关键引用文件:
tg-rcore-tutorial-ch6/Cargo.tomltg-rcore-tutorial-ch6/src/fs.rstg-rcore-tutorial-ch6/build.rstg-rcore-tutorial-ch8/src/main.rs
Licensed under either of MIT license or Apache License, Version 2.0 at your option.