Skip to content

Commit d0fa94b

Browse files
authored
Merge pull request #38 from RoyWFHuang/bug_fix
Fix rm hard link problem and resolve cache leak
2 parents d6f3656 + 6958909 commit d0fa94b

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

inode.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -472,7 +472,8 @@ static int simplefs_remove_from_dir(struct inode *dir, struct dentry *dentry)
472472
}
473473
/* Remove file from parent directory */
474474
for (fi = 0; fi < SIMPLEFS_FILES_PER_BLOCK; fi++) {
475-
if (dblock->files[fi].inode == inode->i_ino) {
475+
if (dblock->files[fi].inode == inode->i_ino &&
476+
!strcmp(dblock->files[fi].filename, dentry->d_name.name) ) {
476477
found = true;
477478
if (fi != SIMPLEFS_FILES_PER_BLOCK - 1) {
478479
memmove(dblock->files + fi, dblock->files + fi + 1,
@@ -896,6 +897,7 @@ static int simplefs_link(struct dentry *old_dentry,
896897
brelse(bh);
897898

898899
inode_inc_link_count(inode);
900+
ihold(inode);
899901
d_instantiate(dentry, inode);
900902
return ret;
901903

0 commit comments

Comments
 (0)