Closed elliott-beach closed 6 years ago
For helping my memory: https://digital-forensics.sans.org/blog/2008/12/24/understanding-indirect-blocks-in-unix-file-systems.
All we need to change for this are setBlockAddress
and getBlockAddress
:
https://github.com/elliott-beach/project3/blob/6c7e23a2061096ff245885463943947b27e24641/IndexNode.cc#L102-L141
For reading the indrect block, we may have to use or modify FileDescriptor::readBlock
It should be something like:
getBlockAddress(n)
if n > limit
block = FileDescriptor::readBock(indirectBlock)
blockAddr = block[n - limit]
return blockAddr
setBlockAddress (n, a)
if n > limit
block = FileDescriptor::readBock(indirectBlock)
block[n - limit] = a
FileDescriptor::writeBlock(indirectBlock)
Also IndexNode::read
and write
must change.
It also looks like this will require making inode
know about FileSystem
, which mutilates the OO hierarchy a little.
Enhance the file system simulator to support indirect blocks; you are not required but may also implement double- and triple-indirect blocks if you wish.