elliott-beach / project3

http://www-users.cselabs.umn.edu/classes/Fall-2017/csci5103/PROJECT/PROJECT3/project3.pdf
0 stars 0 forks source link

Support Indirect Blocks #3

Closed elliott-beach closed 6 years ago

elliott-beach commented 6 years ago

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.

elliott-beach commented 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.

elliott-beach commented 6 years ago

It also looks like this will require making inode know about FileSystem, which mutilates the OO hierarchy a little.