From f9b9e39f6fd9d63e6126379f8f518308efdccee9 Mon Sep 17 00:00:00 2001 From: Dustin Sallings Date: Wed, 18 Dec 2013 23:08:10 -0800 Subject: [PATCH] Support removing roots from FUSE Change-Id: I6929d416a6bbdad396da01210e86cb78b1f0c90b --- pkg/fs/roots.go | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/pkg/fs/roots.go b/pkg/fs/roots.go index 3854055b4..b91848194 100644 --- a/pkg/fs/roots.go +++ b/pkg/fs/roots.go @@ -63,6 +63,30 @@ func (n *rootsDir) ReadDir(intr fuse.Intr) ([]fuse.Dirent, fuse.Error) { return ents, nil } +func (n *rootsDir) Remove(req *fuse.RemoveRequest, intr fuse.Intr) fuse.Error { + n.mu.Lock() + defer n.mu.Unlock() + + if err := n.condRefresh(); err != nil { + return err + } + br := n.m[req.Name] + if !br.Valid() { + return fuse.ENOENT + } + + claim := schema.NewDelAttributeClaim(br, "camliRoot", "") + _, err := n.fs.client.UploadAndSignBlob(claim) + if err != nil { + log.Println("rootsDir.Remove:", err) + return fuse.EIO + } + + delete(n.m, req.Name) + + return nil +} + func (n *rootsDir) Lookup(name string, intr fuse.Intr) (fuse.Node, fuse.Error) { log.Printf("fs.roots: Lookup(%q)", name) n.mu.Lock()