From 826e9def70f38a25b68f51f6d463c811506f7e0b Mon Sep 17 00:00:00 2001 From: Aaron Jacobs Date: Fri, 6 Mar 2015 05:51:49 +1100 Subject: [PATCH] Implemented memFS.SetInodeAttributes. --- samples/memfs/fs.go | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/samples/memfs/fs.go b/samples/memfs/fs.go index b65bc26..730636f 100644 --- a/samples/memfs/fs.go +++ b/samples/memfs/fs.go @@ -267,6 +267,32 @@ func (fs *memFS) GetInodeAttributes( return } +func (fs *memFS) SetInodeAttributes( + ctx context.Context, + req *fuse.SetInodeAttributesRequest) ( + resp *fuse.SetInodeAttributesResponse, err error) { + resp = &fuse.SetInodeAttributesResponse{} + + fs.mu.RLock() + defer fs.mu.RUnlock() + + // Grab the inode. + inode := fs.getInodeForModifyingOrDie(req.Inode) + defer inode.mu.Unlock() + + // Handle the request. + inode.SetAttributes(req.Size) + + // Fill in the response. + resp.Attributes = inode.attributes + + // We don't spontaneously mutate, so the kernel can cache as long as it wants + // (since it also handles invalidation). + resp.AttributesExpiration = fs.clock.Now().Add(365 * 24 * time.Hour) + + return +} + func (fs *memFS) MkDir( ctx context.Context, req *fuse.MkDirRequest) (resp *fuse.MkDirResponse, err error) {