Outlined memFS.RmDir.

geesefs-0-30-9
Aaron Jacobs 2015-03-03 11:28:41 +11:00
parent 63408f6a0d
commit 57cb4ccda3
2 changed files with 30 additions and 0 deletions

View File

@ -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) {

View File

@ -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