Commit 2cf18ad9 authored by Aaron Jacobs's avatar Aaron Jacobs

Fixed some build errors.

parent ea2038ef
......@@ -112,8 +112,23 @@ func (fs *memFS) Init(
return
}
// Find the supplied inode and return it with its lock held for reading. Panic
// if it doesn't exist.
// Find the given inode and return it with its lock held. Panic if it doesn't
// exist.
//
// SHARED_LOCKS_REQUIRED(fs.mu)
// EXCLUSIVE_LOCK_FUNCTION(inode.mu)
func (fs *memFS) getInodeForModifyingOrDie(id fuse.InodeID) (inode *inode) {
inode = fs.inodes[id]
if inode == nil {
panic(fmt.Sprintf("Unknown inode: %v", id))
}
inode.mu.Lock()
return
}
// Find the given inode and return it with its lock held for reading. Panic if
// it doesn't exist.
//
// SHARED_LOCKS_REQUIRED(fs.mu)
// SHARED_LOCK_FUNCTION(inode.mu)
......@@ -127,6 +142,13 @@ func (fs *memFS) getInodeForReadingOrDie(id fuse.InodeID) (inode *inode) {
return
}
// Allocate a new inode, assigning it an ID that is not in use. Return it with
// its lock held.
//
// EXCLUSIVE_LOCKS_REQUIRED(fs.mu)
// EXCLUSIVE_LOCK_FUNCTION(inode.mu)
func (fs *memFS) allocateInode(mode os.FileMode) (id fuse.InodeID, inode *inode)
func (fs *memFS) LookUpInode(
ctx context.Context,
req *fuse.LookUpInodeRequest) (resp *fuse.LookUpInodeResponse, err error) {
......@@ -193,7 +215,7 @@ func (fs *memFS) MkDir(
defer fs.mu.Unlock()
// Grab the parent, which we will update shortly.
parent := fs.getInodeForModifying(req.Parent)
parent := fs.getInodeForModifyingOrDie(req.Parent)
defer parent.mu.Unlock()
// Allocate a child.
......@@ -201,7 +223,7 @@ func (fs *memFS) MkDir(
defer child.mu.Unlock()
// Add an entry in the parent.
parent.AddEntry(childID, req.Name, fuseutil.DT_Directory)
parent.AddChild(childID, req.Name, fuseutil.DT_Directory)
// Fill in the response.
resp.Entry.Attributes = child.attributes
......
......@@ -134,6 +134,15 @@ func (inode *inode) LookUpChild(name string) (id fuse.InodeID, ok bool) {
return
}
// Add an entry for a child.
//
// REQUIRES: inode.dir
// EXCLUSIVE_LOCKS_REQUIRED(inode.mu)
func (inode *inode) AddChild(
id fuse.InodeID,
name string,
dt fuseutil.DirentType)
// Serve a ReadDir request.
//
// REQUIRED: inode.dir
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment