-
Notifications
You must be signed in to change notification settings - Fork 465
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
vfs: fix data race over memNode.name
This commit fixes the following data race over memNode.name: - memFile.Stat().Name() reads memNode.name without a lock - MemFS.Rename() writes memNode.name under MemFS.mu The memNode.name field is fundamentally owned by MemFS, so must be accessed under MemFS.mu lock. However, this lock is not accessible from memNode. After this commit, memNode no longer implements os.FileInfo. Instead, the FileInfo role is now played by memFile (which has access to MemFS, and can use its lock to safely access the name field).
- Loading branch information
Showing
1 changed file
with
30 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters