Commit 57cb4ccd authored by Aaron Jacobs's avatar Aaron Jacobs

Outlined memFS.RmDir.

parent 63408f6a
......@@ -294,6 +294,29 @@ func (fs *memFS) MkDir(
return
}
func (fs *memFS) RmDir(
ctx context.Context,
req *fuse.RmDirRequest) (resp *fuse.RmDirResponse, err error) {
resp = &fuse.RmDirResponse{}
fs.mu.Lock()
defer fs.mu.Unlock()
// Grab the parent, which we will update shortly.
parent := fs.getInodeForModifyingOrDie(req.Parent)
defer parent.mu.Unlock()
// TODO(jacobsa): Check for empty. (Make sure we have a failing test first.)
// Remove the entry within the parent.
parent.RemoveChild(req.Name)
// TODO(jacobsa): Remove the child when it's forgotten. (Can we get a failing
// test by looking at inode ID allocation?)
return
}
func (fs *memFS) OpenDir(
ctx context.Context,
req *fuse.OpenDirRequest) (resp *fuse.OpenDirResponse, err error) {
......
......@@ -158,6 +158,13 @@ func (inode *inode) AddChild(
inode.entries = append(inode.entries, e)
}
// Remove an entry for a child.
//
// REQUIRES: inode.dir
// REQUIRES: An entry for the given name exists.
// EXCLUSIVE_LOCKS_REQUIRED(inode.mu)
func (inode *inode) RemoveChild(name string)
// 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