Virtual file system (VFS)
-
Upload
waylin-ch -
Category
Engineering
-
view
42 -
download
5
description
Transcript of Virtual file system (VFS)
1
Virtual FileSystem(VFS)
Wayling
2011.12.20
2
Outline
• Introduce VFS
• VFS implement
• Ramfs
• Vfs/ramfs to Bos
3
virtual file system(1/2)
ls mkdir mount
libc
VFS
cpiofs
procfs
arfs
devfs
tarfs
ramfs filesystem
4
virtual file system(2/2)
• vfs framework – vnode / file / dirent struct
– mount / mkdir
• no file I/O – device model
– file block struct
– read / write
• no lock – no Synchronized
5
VFS implement (call trace)
• mount->sys_mount->ramfs_mount
• mkdir->sys_mkdir->ramfs_mkdir
• open_dir->sys_opendir->ramfs_opendir
• read->sys_read->ramfs_read
• write->sys_write->ramfs_write
6
VFS implement (vnode)
7
vfs 轉換
• 轉換vnode 到個別檔案系統的節點
– namei / lookup
• 找到對應filesystem,root point
• 分解路徑
• 轉換
/test/test1
/ /test /test/test1
Filesystem 相關
8
mount
• “/” ,根目錄比較特別,需要直接用mount建立,其他目錄皆需用mkdir 創建
• sys_mount掛載一個檔案系統,所有操作皆會被轉為此檔案系統各自的操作
/
ramfs
/test
ext2
9
mkdir
• sys_mkdir建立vnode 轉為個別檔案系統的節點之操作
依據路徑
轉換vnode
是否存在 目錄存在
建vnode,
呼叫對應檔案系統之mkdir
10
vnode 查詢
• vnode查詢頻繁,故使用hash function查詢
vnode_table
11
ramfs(1/2)
• vnode -> ramfs_node
• ramfs 自我組織
/
/test1
/test2
/test
12
ramfs 填填看(2/2)
13
vfs/ramfs to Bos
• Porting from prex/xboot
• Github https://github.com/benwei/bos/tree/feature-vfs
• fs
– vfs
– ramfs
• ls command
14
reference
• [vfs-feature]
• https://github.com/benwei/bos/tree/feature-vfs
• [xboot]
• https://github.com/jerryjianjun/xboot
• [prex]
• https://github.com/AndrewD/prex