1 / 31

Linux File System

Linux File System. Li-Shien Chen. 基本概念. 檔案屬性. Inode. Link. 何謂連結 ? 將檔案取另一個名字 Hardlink ln /a/os1.txt /b/os2.txt. Hard Link. Hard Link 缺點. 不許應用在目錄上 會造成循環連結 不能跨檔案系統 會使得 Inode number 不唯一. Symbolic Link. Ln –s /a/os1.txt /b/os2.txt 與 Hard Link 的不同

Download Presentation

Linux File System

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Linux File System Li-Shien Chen

  2. 基本概念

  3. 檔案屬性

  4. Inode

  5. Link • 何謂連結? 將檔案取另一個名字 • Hardlink ln /a/os1.txt /b/os2.txt

  6. Hard Link

  7. Hard Link 缺點 • 不許應用在目錄上 會造成循環連結 • 不能跨檔案系統 會使得Inode number不唯一

  8. Symbolic Link • Ln –s /a/os1.txt /b/os2.txt • 與Hard Link的不同 有自己的Inode節點

  9. Symbolic Link

  10. 傳統Unix系統 • 支援某一種特定檔案系統 • 無法存取其他的檔案系統 • 如何同時支援多個檔案系統

  11. 傳統Unix系統缺點

  12. 方案一

  13. 方案一的問題 • Kernel與檔案系統相依程度太高 • 造成應用程式的負擔 • 方案二 :為kernel與檔案系統提供一個標 準的連結介面

  14. 方案二

  15. Linux File System • 真正的檔案系統 • 如Ext2,FAT…等等 • Cache • 加快讀取檔案系統的速度 • Virtual File System Switch(VFS) • Kernel與真正檔案系統的介面

  16. Linux File System 架構

  17. The Buffer Cache

  18. The States of the Cache • Locked • Buffers that are locked, waiting to be written • Dirty • Dirty buffers. These contain new, valid data, and will be written but so far have not been scheduled to write

  19. The States of the Cache • Share • Shared buffers • Unshared • Buffers that were once shared but which are now not shared

  20. 檔案系統的表示 • Disk and Patition Layout • 在Linux裡, 檔案放的位置是以一個partition為單位的 • 在VFS裡, 每一個檔案系統是由其superblock來表示的

  21. VFS Superblock • Super_block結構 struct list_heads s_list; kdev_t s_dev; unsigned long s_blocksize; unsigned char s_blocksize_bits; unsigned char s_rd_only; unsigned char s_dirt;

  22. VFS Superblock struct file_system_type *type; unsigned long s_flags; unsigned long s_magic; struct dentry *s_root; struct super_operations *s_op

  23. 檔案的表示 • 使用者觀點: 絕對路徑 如 usr/src/linux/fs/file.c • VFS:以vfs inode(vnode)來表示

  24. Device Inode Number Mode User id times block size inode operations a pointer to a block of routine addresses count lock dirty file system specific VFS inode

  25. Registering the File Systems • Build Linux kernel : supported file systems • Build file systems as module

  26. 掛上檔案系統 • 利用 mount 或 mount_root() • 利用read_super()來初始superblock • $mount -t ext2 /dev/hda3 /mnt

  27. Example

  28. Mounting a File System • $mount -t iso9600 -o ro /dev/cdrom /mnt/cdrom • Search for the file system types( iso9600) • Allocate a VFS superblock and pass it the mount information to the superblock read routine

  29. A Mounted File System

  30. Unmount a File System • Check whether someone is using the FS • Check if the File System is dirty • write back • Return VFS superblock to kernel’s pool • vfsmount is unlinked fromvfsmntlist

  31. Reference • The Linux Kernel • Linux 核心研究篇 • http://www.linpus.com.tw • http://cat.ice.ntnu.edu.tw

More Related