Supporting Files With Data
Supporting files with data is simpler then it looks, because we leave most
of the work to the page cache, and the VFS's generic page-handling
functions.
We simply need to map all address-space operations to functions that invoke
the VFS generic page-handling functions, and implement a single function -
stamfs_get_block():
- Translate the block offset parameter to the matching disk block number.
- If we succeeded, just return this block number.
- Otherwise - if we were told NOT to allocate a new block, return an error.
- Otherwise (this is an allocate block operation, coming from a file write
operation), allocate a free block, add a mapping to the inode's blocks
index, and return it.
Originally written by
guy keren