1. A journey of file system
on JOS
Name :wayling
Date: 2012/09/11
2. Who am I?
●JuluOSDev 星系001
● virtual file system (2011-12-20 )
● http://www.juluos.org/home/files
● 出沒於TOSSUG & H4
●waylingII@gmail.com
wayling
3. Introduction JOS
●MIT 6.828 Operating System Engineering
●JOS是一個有基本雛形的作業系統,擁有傳統unix-like
functiom(fork, exec…) ,但是實作方式是exokernel style(實作
的unix-like functiom大部份皆為user level的函式,不實作於
kernel level) 。
●主要部份:
● Booting
● Memory management
● User-level environments
● Preemptive multitasking
● File system and spawn
● A shell
Lectures:
Frans Kaashoek
Robert Morris
4. JOS File System
●Part1 : File system struct
● In-memory and On-disk struct
●Part 2: Client/Server file system access
● Remote procedure call (RPC) base on IPC +
process
5. JOS File System
●Part1 : File system struct
● In-memory and On-disk struct
●Part 2: Client/Server File System Access
● remote procedure call (RPC) base on IPC +
process
6. The File System
●File system是memory跟disk操作結合
而成的,意及我們在存取檔案時,memory
跟disk都需要有對應的struct來存放表示。
●static + dynamic組成file system
● Static : 格式化硬碟成特有檔案系統格式 ex:
ext2、ext3。
● Dynamic :runtime時作業系統保存對應的資料
結構,藉此操作disk,提供檔案操作給使用者。
7. JOS file system item(1/2)
●Sectors and Blocks
● Sector :Disk 實體磁區 (512 B) 。
● Block : file system 存取單位 (4KB) 。
●Superblocks (disk & memory)
● 保存block size、 disk size 、 以及其他meta-data
用於尋找到root directory 。
●Block Bitmap (disk & memory)
● 管理 free disk blocks 。
8. JOS file system item(2/2)
●File Meta-data
● 保存”檔案”的必要資訊,檔名、大小、 以及
block pointer(direct/indirect) 。
●Directories versus Regular Files
● Directories主要保存多個file struct 。
● Regular Files保存data block 。
9. JOS file system struct overview
File/Directory struct level
Block struct level
Disk struct (sector) level
User access
12. JOS file system
●Disk access
● user-level file system - IDE disk driver 實做於user
space 。
● polling vs interrupt-driven 。
●The Block Cache
● 運用虛擬記憶體的特性,當程式存取檔案時轉換為對其
地址空間做存取 (0x10000000 - 0xD000000, 3GB) 。
●File operations
● Open/Read/Write ,基本檔案操作。
13. Format a file system (1/2)
#fsformat fs.img 1024 init newmotd motd
struct File
struct File
struct File
struct File
struct File
/
init
newmode
mode
init
dir
reg
reg
reg
reg
data block
data block
……
=>請參閱source code
14. struct File
Name : “/”
Size : 54321
Direct block pointers:
11
12
13
14
struct File
struct File
Name : “init”
Size : 54321
Name : “newmode”
Size : 54321
struct File
Name : “init”
Size : 54321
21
22
23
35
36
37
38
52
53
54
55
Format a file system (2/2)
#fs.img (block view)
使用block bitmap紀錄block
分配狀況(不一定連續分配) 。
15. JOS file system service
●Part1 : File system struct
● In-memory and On-disk struct
●Part 2: Client/Server file system access
● remote procedure call (RPC) base on IPC +
process
17. Client/Server file system access
●JOS使用IPC機制實作client/server架構的file
system service。
●File system Server (FSServ) :
● 作為user space porcess,提供檔案操作服務, 藉由IPC
提供其他process所需之請求。
●Client :
● 透過FSServ來存取檔案。
●FSServ 特徵:
● Process id 1。
● Block cache。
● 回應client的IPC request。