10 - File System Organization
Class: CSCE-313
Notes:
...
The file system abstraction
Notes:
- It gives you main hierarchical data
- All that you have on a disk are tracks and sectors
- In some sense you have a linear sequence of sectors
- Think of it as counting from the inside to the outside
- Somehow your filesystem is going to construct a hierarchical namespace out of this linear structure
- This gives you abstraction to be able to organized your files well
- But under the hood it is just a linear structure mapping
Example:
- Imagine that you are trying to create a new file:
- consider what you filesystem needs to do
- The entire metadata for a file goes into an inode
- The entire sequence of bytes will go to that inode
- Once an inode is allocated, it needs to mark an inode as unavailable
- It has to go search for and find free data blocks to assign to that inode, and then it needs to write the entry for that file into a directory
- An entry is nothing more than inode-name pairs
- It better not fail anything in between, it better do this atomically, because otherwise you will need to use
fseekingto recover your filesystem which takes a lot of time
- Your filesystem not only is building this hierarchical abstraction, but it is doing it very reliable and giving you the illusion of all or nothing meaning either this things all happen or none of it happen.
- Somewhere in the file metadata is our permission bits that allow someone to read/write, etc.
- Somehow if you try to reach a particular file, you need to be able to go from the directories on top of it (from
/tofooand then fromfootoa) - Your filesystem looks up that inode, and in that inode tells you the exact sequence of disk blocks corresponding to that file, and now you can read the exact blocks in order to read the file.
- For you it is just a byte offset within the file, but underneath, the system is reading blocks and returning bytes to you