Chapter 14:檔案系統 === :::info 這是讀書筆記 ![679544](https://hackmd.io/_uploads/HJB-ZFKV-l.jpg =30%x) 作者:鄭鋼 出版社:佳魁資訊股份有限公司 出版日期:2017/05/31 ::: >[time=2025-08-05] --- # 檔案系統概念簡介 * EBR * Super Block * Block bitmap * inode bitmap * inode table(array):指向一個 inode 結構。 * root directory # 建立檔案系統 ## Source Code https://github.com/yifengyou/os-elephant/tree/master/code/c14/b ## Result partition format ![截圖 2025-07-30 凌晨3.14.07](https://hackmd.io/_uploads/Sk0h65IDgl.png) mount ![截圖 2025-07-30 凌晨3.16.28](https://hackmd.io/_uploads/B1uXR9Iweg.png) # 檔案描述符:file descriptor PCB 中新增 fd table。 # 檔案操作基礎函數及建立檔案 ## Source Code https://github.com/yifengyou/os-elephant/tree/master/code/c14/c ## Result ![截圖 2025-07-31 凌晨1.37.24](https://hackmd.io/_uploads/BkA9uCwvee.png) ![截圖 2025-07-31 凌晨1.42.02](https://hackmd.io/_uploads/S1dcK0DPxe.png) # 檔案的開啟和關閉 ## Source Code https://github.com/yifengyou/os-elephant/tree/master/code/c14/d ## Result ![截圖 2025-08-04 下午2.53.17](https://hackmd.io/_uploads/HypeFApDxg.png) # 檔案寫入 ## Source Code https://github.com/yifengyou/os-elephant/tree/master/code/c14/e * 先計算所需的所有 blocks。 * 更新 bitmap。 * 然後再寫入硬碟。 ## Result ![截圖 2025-08-04 下午3.52.45](https://hackmd.io/_uploads/BJWxw1APel.png) 0x2AB(sector number) * 512(sector size) = 349696 ```shell xxd -s +349696 -l 512 sr_hd80m.img ``` ![截圖 2025-08-04 下午3.57.58](https://hackmd.io/_uploads/B12mOyCPel.png) # 讀取檔案 ## Source Code https://github.com/yifengyou/os-elephant/tree/master/code/c14/f ## Result ![截圖 2025-08-04 下午4.25.19](https://hackmd.io/_uploads/r1k9Ck0Dgx.png) # 檔案讀寫指標定位 ## Source Code https://github.com/yifengyou/os-elephant/tree/master/code/c14/g ## Result ![截圖 2025-08-04 下午4.33.03](https://hackmd.io/_uploads/rypLgg0Deg.png) # 檔案刪除 ## Source Code https://github.com/yifengyou/os-elephant/tree/master/code/c14/h ## Result ![截圖 2025-08-04 下午5.18.58](https://hackmd.io/_uploads/BJtmigRPlx.png) # 建立目錄 ## Source Code https://github.com/yifengyou/os-elephant/tree/master/code/c14/i ## Result ![截圖 2025-08-05 清晨5.17.24](https://hackmd.io/_uploads/ryUY7oCwgg.png) # 目錄的讀取 ## Source Code https://github.com/yifengyou/os-elephant/tree/master/code/c14/k ## Result ![截圖 2025-08-05 清晨5.32.12](https://hackmd.io/_uploads/Sk0lwi0vle.png) # 刪除目錄 ## Source Code https://github.com/yifengyou/os-elephant/tree/master/code/c14/l ## Result ![截圖 2025-08-05 下午2.37.12](https://hackmd.io/_uploads/rkvhI7k_eg.png) # 工作目錄:Current Working Directory(cwd) ## Source Code https://github.com/yifengyou/os-elephant/tree/master/code/c14/m ## Result ![截圖 2025-08-05 下午3.29.07](https://hackmd.io/_uploads/S1VJX41ugl.png) # 檔案屬性 ## Source Code https://github.com/yifengyou/os-elephant/tree/master/code/c14/n ## Result ![截圖 2025-08-05 下午3.35.43](https://hackmd.io/_uploads/BkYuVVJdxe.png)