Outlined memFS.RmDir.
parent
63408f6a0d
commit
57cb4ccda3
|
@ -294,6 +294,29 @@ func (fs *memFS) MkDir(
|
||||||
return
|
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(
|
func (fs *memFS) OpenDir(
|
||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
req *fuse.OpenDirRequest) (resp *fuse.OpenDirResponse, err error) {
|
req *fuse.OpenDirRequest) (resp *fuse.OpenDirResponse, err error) {
|
||||||
|
|
|
@ -158,6 +158,13 @@ func (inode *inode) AddChild(
|
||||||
inode.entries = append(inode.entries, e)
|
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.
|
// Serve a ReadDir request.
|
||||||
//
|
//
|
||||||
// REQUIRED: inode.dir
|
// REQUIRED: inode.dir
|
||||||
|
|
Loading…
Reference in New Issue