Linux: Virtual File System
Virtual File System (VFS) 虛擬檔案系統,以下的說明節錄自Understanding the Linux Kernel。
The Virtual Filesystem is a kernel software layer that handles all system calls related to a standard Unix filesystem. Its main strength is providing a common interface to several kinds of filesystems.
從上面的說明可以知道虛擬檔案系統就是提供使用者一個共同的介面可以同時操作和管理不同類型的File System(檔案系統),參考鳥哥文章中的圖,示意如下:
User Application (User Space)
|
|
-----------------------------------------------------------------------------------------------------------
System Call Interface (Kernel Space)
|
|
Virtual File System
|
|
----------------------------------------------------------------------------
| | | |
Minix FS DOS FS Ext2/Ext3 FS xxx FS
所謂的同時管理和操作就是如上圖所示,User不需要去管底層的FS是那種類型,只需要知道用哪些System Call可以達成目的即可,如此做來也有點OO的概念在裡面,把一些東西抽象化起來了。
從user space是如何切換到kernel space進而利用VFS提供的API繼續往下執行?看來應該是透過軟體中斷方式,User Space無法直接access Kernel Space,必須透過cpu的特殊指令產生軟體中斷來切換使用模式,才能進入Kernel Space繼續往下執行。
The Virtual Filesystem is a kernel software layer that handles all system calls related to a standard Unix filesystem. Its main strength is providing a common interface to several kinds of filesystems.
從上面的說明可以知道虛擬檔案系統就是提供使用者一個共同的介面可以同時操作和管理不同類型的File System(檔案系統),參考鳥哥文章中的圖,示意如下:
User Application (User Space)
|
|
-----------------------------------------------------------------------------------------------------------
System Call Interface (Kernel Space)
|
|
Virtual File System
|
|
----------------------------------------------------------------------------
| | | |
Minix FS DOS FS Ext2/Ext3 FS xxx FS
所謂的同時管理和操作就是如上圖所示,User不需要去管底層的FS是那種類型,只需要知道用哪些System Call可以達成目的即可,如此做來也有點OO的概念在裡面,把一些東西抽象化起來了。
從user space是如何切換到kernel space進而利用VFS提供的API繼續往下執行?看來應該是透過軟體中斷方式,User Space無法直接access Kernel Space,必須透過cpu的特殊指令產生軟體中斷來切換使用模式,才能進入Kernel Space繼續往下執行。
留言
張貼留言