Truncating An Inode's Data Blocks
This function is used both when deleting the inode, and when a user invokes
a "truncate" operation (with a given offset) on a file, so it uses the
inode's size field in order to know where to start truncating from:
- Read the inode's block index from disk.
- Calculate the entry of this index, from which we need to fully truncate
blocks.
- Scan the index from that point until its end, freeing each block
(possibly adding it to the free list), and mark the entry as empty.
- Update accounting data (e.g. number of blocks used by the inode).
- Note: when we support files with data, we will need to get back to
this function.
Now, here is the persistent STAMFS code.
Originally written by
guy keren