Fixed some build errors.
parent
ea2038ef5e
commit
2cf18ad9a5
|
@ -112,8 +112,23 @@ func (fs *memFS) Init(
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// Find the supplied inode and return it with its lock held for reading. Panic
|
// Find the given inode and return it with its lock held. Panic if it doesn't
|
||||||
// if it doesn't exist.
|
// 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_LOCKS_REQUIRED(fs.mu)
|
||||||
// SHARED_LOCK_FUNCTION(inode.mu)
|
// SHARED_LOCK_FUNCTION(inode.mu)
|
||||||
|
@ -127,6 +142,13 @@ func (fs *memFS) getInodeForReadingOrDie(id fuse.InodeID) (inode *inode) {
|
||||||
return
|
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(
|
func (fs *memFS) LookUpInode(
|
||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
req *fuse.LookUpInodeRequest) (resp *fuse.LookUpInodeResponse, err error) {
|
req *fuse.LookUpInodeRequest) (resp *fuse.LookUpInodeResponse, err error) {
|
||||||
|
@ -193,7 +215,7 @@ func (fs *memFS) MkDir(
|
||||||
defer fs.mu.Unlock()
|
defer fs.mu.Unlock()
|
||||||
|
|
||||||
// Grab the parent, which we will update shortly.
|
// Grab the parent, which we will update shortly.
|
||||||
parent := fs.getInodeForModifying(req.Parent)
|
parent := fs.getInodeForModifyingOrDie(req.Parent)
|
||||||
defer parent.mu.Unlock()
|
defer parent.mu.Unlock()
|
||||||
|
|
||||||
// Allocate a child.
|
// Allocate a child.
|
||||||
|
@ -201,7 +223,7 @@ func (fs *memFS) MkDir(
|
||||||
defer child.mu.Unlock()
|
defer child.mu.Unlock()
|
||||||
|
|
||||||
// Add an entry in the parent.
|
// 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.
|
// Fill in the response.
|
||||||
resp.Entry.Attributes = child.attributes
|
resp.Entry.Attributes = child.attributes
|
||||||
|
|
|
@ -134,6 +134,15 @@ func (inode *inode) LookUpChild(name string) (id fuse.InodeID, ok bool) {
|
||||||
return
|
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.
|
// Serve a ReadDir request.
|
||||||
//
|
//
|
||||||
// REQUIRED: inode.dir
|
// REQUIRED: inode.dir
|
||||||
|
|
Loading…
Reference in New Issue