Wrote the skeleton for memFS.MkDir.

geesefs-0-30-9
Aaron Jacobs 2015-03-03 09:30:25 +11:00
parent 1f5f17b07e
commit ea2038ef5e
1 changed files with 20 additions and 1 deletions

View File

@ -192,7 +192,26 @@ func (fs *memFS) MkDir(
fs.mu.Lock()
defer fs.mu.Unlock()
panic("TODO")
// Grab the parent, which we will update shortly.
parent := fs.getInodeForModifying(req.Parent)
defer parent.mu.Unlock()
// Allocate a child.
childID, child := fs.allocateInode(req.Mode)
defer child.mu.Unlock()
// Add an entry in the parent.
parent.AddEntry(childID, req.Name, fuseutil.DT_Directory)
// Fill in the response.
resp.Entry.Attributes = child.attributes
// We don't spontaneously mutate, so the kernel can cache as long as it wants
// (since it also handles invalidation).
resp.Entry.AttributesExpiration = fs.clock.Now().Add(365 * 24 * time.Hour)
resp.Entry.EntryExpiration = resp.Entry.EntryExpiration
return
}
func (fs *memFS) OpenDir(