]> Devi Nivas Git - cs3210-lab0.git/commitdiff
inode reuse bug.
authorrsc <rsc>
Sun, 31 May 2009 01:34:46 +0000 (01:34 +0000)
committerrsc <rsc>
Sun, 31 May 2009 01:34:46 +0000 (01:34 +0000)
Suppose an inode has been used and freed.
It is left marked I_VALID (the bug).
Now ialloc comes along and reuses the
inode.  It writes the new inode type to disk
and returns iget(dev, inum) to get the
cache entry.  Iget sees that the inode is valid
and doesn't bother refreshing from disk.
Now when the caller iupdates, it will write
out a zero type and the file or directory has
disappeared.

fs.c

diff --git a/fs.c b/fs.c
index 49a736d77d405ac1c350e2052c5d45170c7feffb..abd7c0bfef736adc9abdb1d5b863f4997fa9b4dc 100644 (file)
--- a/fs.c
+++ b/fs.c
@@ -227,7 +227,7 @@ iunlock(struct inode *ip)
     panic("iunlock");
 
   acquire(&icache.lock);
-  ip->flags &= ~I_BUSY;
+  ip->flags = 0;
   wakeup(ip);
   release(&icache.lock);
 }