<aside> ✏️ 從使用者的角度去看
</aside>
File 也是抽像的概念。
<aside> 📖 File (Data): a logical storage unit created by OS
</aside>
Physical storage unit in disk
File attributes (Metadata)
File operations
Open-File Tables
注意他存的是 metadata,不是 data
Per-process table
Tracking all files opened by this process
跟操作這個 file 有關的資訊(independent 的)
File pointer → process 操作這個檔案到的位置
裡面還有一個 pointer 指到 file 的 System-wide table
⇒ 這樣就可以避免資料一致性的問題,所以才不要 duplicate 一份到 Per-process table 裡面
System-wide table
- 不管誰操作都要看到的資訊(share 的)
- File size, disk location
Open File Attributes
File types
是以使用者的角度來看:
Sequential access
fread
, fwrite
Direct (relative) access a.k.a random access
DB
用 index 去存取資料
Index: contains pointers to blocks of a file
With a large file → index could become too large
To find a record in a file: