Skip to content
GitLab
Explore
Projects
Groups
Topics
Snippets
Projects
Groups
Topics
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
educg-net-22024-2210153
OSKernel2024-chaos-3141
Commits
c0d5cc1b
Commit
c0d5cc1b
authored
1 year ago
by
我一定要参加系统内核赛
Browse files
Options
Download
Patches
Plain Diff
docs: 更新文件系统相关
parent
2e2b366c
main
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
docs/文件系统.md
+44
-0
docs/文件系统.md
docs/文件系统架构图.md
+0
-61
docs/文件系统架构图.md
docs/资料.md
+39
-0
docs/资料.md
with
83 additions
and
61 deletions
+83
-61
docs/文件系统.md
0 → 100644
+
44
−
0
View file @
c0d5cc1b
# 文件系统
为了更方便地支持更多的文件系统,以及为了将文件系统与内核解耦合,chaos 利用 rust 的 trait 特性,将内核所需要的文件系统提供的功能抽象成
`trait Inode`
。任何实现了该 trait 的类型都可以被视为一个受支持的文件系统。
chaos 目前实现了基础的 FAT32 文件系统的支持,对应模块位于
`os/fs/fat32`
下。
## 架构图
```
mermaid
graph TB;
osi[OSInode];
inode[trait Inode];
fat32[Fat32Inode];
dentry[Fat32Dentry]
fs[Fat32FS];
bdev[trait BlockDevice];
fat[FAT];
sb[Fat32SuperBlock];
osi --> inode;
inode -.-> fat32;
fat32 --> dentry;
fat32 --> fs;
fat32 --> bdev;
fat --> sb;
fs --> sb;
dentry --> bdev;
fs --> bdev;
dentry --> fat;
fs --> fat;
fat --> bdev;
inode -.-> OtherInode...
```
## 改进
chaos 目前的文件系统架构其实对于多文件系统的支持不是很好,无法做到将一个文件系统 mount 到另一个文件系统上。
改进目标参考 Linux 的 vfs 设计。
\ No newline at end of file
This diff is collapsed.
Click to expand it.
docs/文件系统架构图.md
deleted
100644 → 0
+
0
−
61
View file @
2e2b366c
## 文件系统挂载流程
所有的磁盘相关操作都需要经过
`block_cache`
,这样才能保证同步。
## Fat32 BPB 结构

注意:标注
*
号表示无用。
|标识|长度|介绍|值|
|---|---|---|---|
|BytesPerSec|2字节|每扇区字节数,通常为512、1024、2048、4096|0x00 0x02|
|SecPerClus|1字节|每簇扇区数,这个值不能为0,而且必须是2的整数次方,比如1、2、4、8、16、32、64、128|0x08|
|ResdSecCnt|2字节|保留扇区数|0x5E 0x06|
|NumFATs|1字节|FAT表数目|0x02|
|
*
RootEntCnt|2字节|FAT32固定为0|0x00 0x00|
|
*
TotSec16|2字节|FAT32固定为0|0x00 0x00|
|
*
Media|1字节|存储介质,0xF8标准值,可移动存储介质|0xf8|
|
*
FATSz16|2字节|FAT32固定为0|0x00 0x00|
|
*
SecPerTrk|2字节|磁道扇区数|0x3f 0x00|
|
*
NumHeads|2字节|磁头数|0xff 0x00|
|
*
HiddSec|4字节|FAT区前隐藏扇区数|0x00 0x08 0x00 0x00|
|TotSec32|4字节|总扇区数|0x00 0xC0 0xF3 0x00|
|FATSz32|4字节|一个FAT表扇区数|0xd1 0x3c 0x00 0x00|
|
*
ExtFlags|2字节|FAT32持有|0x00 0x00|
|
*
FSVer|2字节|FAT32持有|0x00 0x00|
|RootClus|4字节|第一个目录的簇号|0x02 0x00 0x00 0x00|
|
*
FSInfo|2字节|保留扇区数,FSINFO(文件系统信息扇区)扇区号是1,该扇区为操作系统提供关于空簇总数及下一可用簇的信息|0x01 0x00|
|
*
BkBootSec|2字节|通常为6|0x06 0x00|
|
*
Reserved|12字节|用以扩展|0x00 0x00 … 0x00|
|
*
DrvNum|1字节|驱动器号|0x80|
|
*
Reserved1|1字节|保留|0x00|
|
*
BootSig|1字节|扩展引导标签|0x29|
|
*
VolID|4字节|分区序列|0x24 0x09 0x88 0x8a|
|
*
FileSysType|11字节|卷标|略|
|
*
FilSysType1|8字节|系统ID|略|
## 文件系统架构图
```
mermaid
graph TB;
fs[trait FileSystem];
sb[Super Block];
bdev[Block Device]
fat32fs[Fat32FS];
devfs[DevFS];
procfs[ProcFS];
fsmeta[FileSystemMeta]
fs --> fat32fs;
fs --> devfs;
fs --> procfs;
sb -->|Arc<dyn FileSystem>| fs;
sb -->|Arc<dyn BlockDevice>| bdev;
sb --> fsmeta;
```
\ No newline at end of file
This diff is collapsed.
Click to expand it.
docs/资料.md
+
39
−
0
View file @
c0d5cc1b
...
...
@@ -4,3 +4,41 @@
-
Fat32 文件系统详解:https://blog.csdn.net/weixin_43839785/article/details/111057973
-
Fat32 长短文件名详解:https://blog.csdn.net/u010650845/article/details/60780979
-
比赛需要实现的 syscalls:https://github.com/oscomp/testsuits-for-oskernel/blob/main/oscomp_syscalls.md
## 文件系统
### Fat32 BPB 结构

### FAT32 SuperBlock
注意:标注
*
号表示无用。
|标识|长度|介绍|值|
|---|---|---|---|
|BytesPerSec|2字节|每扇区字节数,通常为512、1024、2048、4096|0x00 0x02|
|SecPerClus|1字节|每簇扇区数,这个值不能为0,而且必须是2的整数次方,比如1、2、4、8、16、32、64、128|0x08|
|ResdSecCnt|2字节|保留扇区数|0x5E 0x06|
|NumFATs|1字节|FAT表数目|0x02|
|
*
RootEntCnt|2字节|FAT32固定为0|0x00 0x00|
|
*
TotSec16|2字节|FAT32固定为0|0x00 0x00|
|
*
Media|1字节|存储介质,0xF8标准值,可移动存储介质|0xf8|
|
*
FATSz16|2字节|FAT32固定为0|0x00 0x00|
|
*
SecPerTrk|2字节|磁道扇区数|0x3f 0x00|
|
*
NumHeads|2字节|磁头数|0xff 0x00|
|
*
HiddSec|4字节|FAT区前隐藏扇区数|0x00 0x08 0x00 0x00|
|TotSec32|4字节|总扇区数|0x00 0xC0 0xF3 0x00|
|FATSz32|4字节|一个FAT表扇区数|0xd1 0x3c 0x00 0x00|
|
*
ExtFlags|2字节|FAT32持有|0x00 0x00|
|
*
FSVer|2字节|FAT32持有|0x00 0x00|
|RootClus|4字节|第一个目录的簇号|0x02 0x00 0x00 0x00|
|
*
FSInfo|2字节|保留扇区数,FSINFO(文件系统信息扇区)扇区号是1,该扇区为操作系统提供关于空簇总数及下一可用簇的信息|0x01 0x00|
|
*
BkBootSec|2字节|通常为6|0x06 0x00|
|
*
Reserved|12字节|用以扩展|0x00 0x00 … 0x00|
|
*
DrvNum|1字节|驱动器号|0x80|
|
*
Reserved1|1字节|保留|0x00|
|
*
BootSig|1字节|扩展引导标签|0x29|
|
*
VolID|4字节|分区序列|0x24 0x09 0x88 0x8a|
|
*
FileSysType|11字节|卷标|略|
|
*
FilSysType1|8字节|系统ID|略|
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment
Menu
Explore
Projects
Groups
Topics
Snippets