Switched to an array of inodes for memfs, like a real file system.
parent
23b398bc83
commit
3379842d1e
|
@ -25,20 +25,21 @@ type memFS struct {
|
||||||
|
|
||||||
mu syncutil.InvariantMutex
|
mu syncutil.InvariantMutex
|
||||||
|
|
||||||
// The next inode to issue.
|
// The collection of all inodes that have ever been created, indexed by inode
|
||||||
|
// ID. Some inodes are not in use if they have been unlinked, and no inode
|
||||||
|
// with ID less than fuse.RootInodeID is ever used.
|
||||||
//
|
//
|
||||||
// INVARIANT: nextInode > 0
|
// INVARIANT: len(inodes) > fuse.RootInodeID
|
||||||
nextInode fuse.InodeID // GUARDED_BY(mu)
|
// INVARIANT: For all i < fuse.RootInodeID, inodes[i].impl == nil
|
||||||
|
// INVARIANT: inodes[fuse.RootInodeID].impl is of type *memDir
|
||||||
|
inodes []inode // GUARDED_BY(mu)
|
||||||
|
|
||||||
// A map from inode number to file or directory with that inode.
|
// A list of inode IDs within inodes available for reuse, not including the
|
||||||
|
// reserved IDs less than fuse.RootInodeID.
|
||||||
//
|
//
|
||||||
// INVARIANT: inodeIndex[fuse.RootInodeID] != nil
|
// INVARIANT: This is all and only indices i of inodes such that i >
|
||||||
// INVARIANT: For all keys k, k > 0
|
// fuse.RootInodeID and inodes[i].impl == nil
|
||||||
// INVARIANT: For all keys k, k < nextInode
|
freeInodes []fuse.InodeID // GUARDED_BY(mu)
|
||||||
// INVARIANT: For all keys k, inodeIndex[k] is *memFile or *memDir
|
|
||||||
// INVARIANT: For all keys k, inodeIndex[k].inode == k
|
|
||||||
// INVARIANT: For all dirs d, all of d's children are in the map.
|
|
||||||
inodeIndex map[fuse.InodeID]interface{} // GUARDED_BY(mu)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create a file system that stores data and metadata in memory.
|
// Create a file system that stores data and metadata in memory.
|
||||||
|
|
|
@ -0,0 +1,13 @@
|
||||||
|
// Copyright 2015 Google Inc. All Rights Reserved.
|
||||||
|
// Author: jacobsa@google.com (Aaron Jacobs)
|
||||||
|
|
||||||
|
package memfs
|
||||||
|
|
||||||
|
// Common attributes for files and directories.
|
||||||
|
type inode struct {
|
||||||
|
// The *memFile or *memDir for this inode, or nil if the inode is available
|
||||||
|
// for reuse.
|
||||||
|
//
|
||||||
|
// INVARIANT: impl is nil, or of type *memFile or *memDir
|
||||||
|
impl interface{}
|
||||||
|
}
|
Loading…
Reference in New Issue