From: Ben Pfaff Date: Fri, 19 May 2006 02:45:13 +0000 (+0000) Subject: Fix race in dir_reopen(). X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ad4fa177fa9b3931c5460dc47cb8b62630c01705;p=pintos-anon Fix race in dir_reopen(). Thanks to Godmar Back for pointing this out (twice). --- diff --git a/solutions/p4.patch b/solutions/p4.patch index 9e11e25..7ab0046 100644 --- a/solutions/p4.patch +++ b/solutions/p4.patch @@ -726,7 +726,7 @@ diff -u src/filesys/directory.c~ src/filesys/directory.c return dir != NULL; } -@@ -61,22 +99,34 @@ dir_open_root (struct dir **dirp) +@@ -61,22 +99,36 @@ dir_open_root (struct dir **dirp) return dir_open (inode_open (ROOT_DIR_SECTOR), dirp); } @@ -734,7 +734,9 @@ diff -u src/filesys/directory.c~ src/filesys/directory.c +bool +dir_reopen (struct dir *dir) +{ ++ lock_acquire (&dir->dir_lock); + dir->open_cnt++; ++ lock_release (&dir->dir_lock); + return true; +} +