fix some bugs (I think) in direntry implementation

This commit is contained in:
Ziao 2023-11-21 15:55:29 -08:00
parent c49c1d2302
commit ffc1703edd

View File

@ -160,6 +160,7 @@ TreeNode *fischl_init_entry(int new_inode_number, const char *fileName, INode *n
newFile->name = strdup(fileName); newFile->name = strdup(fileName);
newFile->inode_number = new_inode_number; newFile->inode_number = new_inode_number;
newFile->permissions = new_inode->permissions; newFile->permissions = new_inode->permissions;
newFile->subdirectory = newDir;
newDir->self_info = newFile; newDir->self_info = newFile;
return newDir; return newDir;
} }
@ -212,7 +213,10 @@ FileNode *fischl_find_entry(TreeNode *root, const char *path){
current = current->parent; current = current->parent;
if (current == NULL) { if (current == NULL) {
// If there's no parent, we've reached the top of the tree, but root itself is same // If there's no parent, we've reached the top of the tree, but root itself is same
file = NULL;
break; break;
} else {
file = current->self_info;
} }
} else if (strcmp(segment, ".") == 0) { } else if (strcmp(segment, ".") == 0) {
// Stay in the current directory (no action needed) // Stay in the current directory (no action needed)