Open ghost opened 6 years ago
1) I don't think this works because when I use rm
after this change and then fsck
, it shows that none of the blocks got freed.
2) There is a conflict that confused me to resolve.
Another thought, why do we need to support multiple programs using the kernel simultaneously? Because the kernel is just a simple C program that you include, that isn't actually possible with the current architecture. It's true I could have thought of that when you mentioned it the first time.
That's a good question. Now that I take a closer look at it, this isn't even possible with the current FileDescriptor structure. In order to tell if the same file is open, not just an inode, the FileDescriptor would need to contain the path name of the file. Otherwise we could only compare inodes which is not what unlink is supposed to do.
But in order to include the pathname of the file, we would need to change every place where the constructor is called.
Given that it’s a requirement for the project, we can make it happen somehow.
FIleDescriptor has a short IndexNodeNumber
which we can use.
But the same indexNodeNumber could correspond to 2 different files. Unlink should only apply to filenames not to inodes. It shouldn't delete an inode
We only do the removal stuff when nlinks is decremented to zero. In that case, the inode is 1to1 with the file, so I still think we can use the inode number
I used the IndexNode::free() function from your pending pull request in Kernel::close