From ea2038ef5e224d04602a75892d0cca3691e34a0f Mon Sep 17 00:00:00 2001 From: Aaron Jacobs Date: Tue, 3 Mar 2015 09:30:25 +1100 Subject: [PATCH] Wrote the skeleton for memFS.MkDir. --- samples/memfs/fs.go | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/samples/memfs/fs.go b/samples/memfs/fs.go index ddf8966..c1a373f 100644 --- a/samples/memfs/fs.go +++ b/samples/memfs/fs.go @@ -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(