Optimization of Directory Structure
As mentioned earlier, we implemented a modern dictionary based directory system. This in some ways is equivalent to the UNIX file descriptor table. But it differs from it in a lot of ways, example, it does not use duplication of file tables.
Following is snapshot of the directory structure of our file system. As you can see that it starts with the root directory and is nested with other folders. A file is the last node of the each i.e. which has no child.
''' Contains the directory structure in the form of a object'''
file_table = {
'root': {
'folderA': {
'file1':{
'inode': 12,
'type': 'txt',
'rseek': 0,
'wseek': 0
},
'file2':{
'inode': 13,
'type': 'txt',
'rseek': 0,
'wseek': 0
}
},
'folderB': { ... }
}
}
Benefits and Improvements
- With the data stored as a dictionary accessing a file is of the order O(1) in a directory. This reduces the inode overhead for lookup
- Maintenance of hierarchy and permissions is very easy.
- Traversing and group deletions become easy, as deleting the parent will clear all the children.