Example #1
0
func (n *rootsDir) Remove(ctx context.Context, req *fuse.RemoveRequest) error {
	if n.isRO() {
		return fuse.EPERM
	}
	n.mu.Lock()
	defer n.mu.Unlock()

	if err := n.condRefresh(ctx); 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)
	delete(n.children, req.Name)

	return nil
}
Example #2
0
// SetAttrValues sets multi-valued attribute.
func (o *Object) SetAttrValues(key string, attrs []string) error {
	exists := asSet(o.Attrs(key))
	actual := asSet(attrs)
	o.mu.Lock()
	defer o.mu.Unlock()
	// add new values
	for v := range actual {
		if exists[v] {
			delete(exists, v)
			continue
		}
		_, err := o.h.upload(schema.NewAddAttributeClaim(o.pn, key, v))
		if err != nil {
			return err
		}
	}
	// delete unneeded values
	for v := range exists {
		_, err := o.h.upload(schema.NewDelAttributeClaim(o.pn, key, v))
		if err != nil {
			return err
		}
	}
	if o.attr == nil {
		o.attr = make(map[string][]string)
	}
	o.attr[key] = attrs
	return nil
}
Example #3
0
// &RenameRequest{Header:fuse.Header{Conn:(*fuse.Conn)(0xc210048180), ID:0x2, Node:0x8, Uid:0xf0d4, Gid:0x1388, Pid:0x5edb}, NewDir:0x8, OldName:"1", NewName:"2"}
func (n *mutDir) Rename(req *fuse.RenameRequest, newDir fuse.Node, intr fuse.Intr) fuse.Error {
	n2, ok := newDir.(*mutDir)
	if !ok {
		log.Printf("*mutDir newDir node isn't a *mutDir; is a %T; can't handle. returning EIO.", newDir)
		return fuse.EIO
	}

	var wg syncutil.Group
	wg.Go(n.populate)
	wg.Go(n2.populate)
	if err := wg.Err(); err != nil {
		log.Printf("*mutDir.Rename src dir populate = %v", err)
		return fuse.EIO
	}

	n.mu.Lock()
	target, ok := n.children[req.OldName]
	n.mu.Unlock()
	if !ok {
		log.Printf("*mutDir.Rename src name %q isn't known", req.OldName)
		return fuse.ENOENT
	}

	now := time.Now()

	// Add a camliPath:name attribute to the dest permanode before unlinking it from
	// the source.
	claim := schema.NewSetAttributeClaim(n2.permanode, "camliPath:"+req.NewName, target.permanodeString())
	claim.SetClaimDate(now)
	_, err := n.fs.client.UploadAndSignBlob(claim)
	if err != nil {
		log.Printf("Upload rename link error: %v", err)
		return fuse.EIO
	}

	delClaim := schema.NewDelAttributeClaim(n.permanode, "camliPath:"+req.OldName, "")
	delClaim.SetClaimDate(now)
	_, err = n.fs.client.UploadAndSignBlob(delClaim)
	if err != nil {
		log.Printf("Upload rename src unlink error: %v", err)
		return fuse.EIO
	}

	// TODO(bradfitz): this locking would be racy, if the kernel
	// doesn't do it properly. (It should) Let's just trust the
	// kernel for now. Later we can verify and remove this
	// comment.
	n.mu.Lock()
	if n.children[req.OldName] != target {
		panic("Race.")
	}
	delete(n.children, req.OldName)
	n.mu.Unlock()
	n2.mu.Lock()
	n2.children[req.NewName] = target
	n2.mu.Unlock()

	return nil
}
Example #4
0
func (n *mutDir) Remove(req *fuse.RemoveRequest, intr fuse.Intr) fuse.Error {
	// Remove the camliPath:name attribute from the directory permanode.
	claim := schema.NewDelAttributeClaim(n.permanode, "camliPath:"+req.Name)
	_, err := n.fs.client.UploadAndSignBlob(claim)
	if err != nil {
		log.Println("mutDir.Create:", err)
		return fuse.EIO
	}
	// Remove child from map.
	n.mu.Lock()
	if n.children != nil {
		delete(n.children, req.Name)
	}
	n.mu.Unlock()
	return nil
}
Example #5
0
func (x *xattr) remove(req *fuse.RemovexattrRequest) fuse.Error {
	log.Printf("%s.Removexattr(%q)", x.typeName, req.Name)

	claim := schema.NewDelAttributeClaim(x.permanode, xattrPrefix+req.Name, "")
	_, err := x.fs.client.UploadAndSignBlob(claim)

	if err != nil {
		log.Printf("Error removing xattr: %v", err)
		return fuse.EIO
	}

	x.mu.Lock()
	delete(*x.xattrs, req.Name)
	x.mu.Unlock()

	return nil
}
Example #6
0
func (n *mutDir) Remove(req *fuse.RemoveRequest, intr fs.Intr) fuse.Error {
	// Remove the camliPath:name attribute from the directory permanode.
	claim := schema.NewDelAttributeClaim(n.permanode, "camliPath:"+req.Name, "")
	_, err := n.fs.client.UploadAndSignBlob(claim)
	if err != nil {
		log.Println("mutDir.Remove:", err)
		return fuse.EIO
	}
	// Remove child from map.
	n.mu.Lock()
	if n.children != nil {
		if removed, ok := n.children[req.Name]; ok {
			removed.invalidate()
			delete(n.children, req.Name)
			log.Printf("Removed %v from %p", removed, n)
		}
	}
	n.mu.Unlock()
	return nil
}
Example #7
0
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
}
Example #8
0
func (id *IndexDeps) DelAttribute(permaNode *blobref.BlobRef, attr string) *blobref.BlobRef {
	m := schema.NewDelAttributeClaim(permaNode, attr)
	m.SetClaimDate(id.advanceTime())
	return id.uploadAndSign(m)
}
Example #9
0
func (id *IndexDeps) DelAttribute(permaNode blob.Ref, attr, value string) blob.Ref {
	m := schema.NewDelAttributeClaim(permaNode, attr, value)
	m.SetClaimDate(id.advanceTime())
	return id.uploadAndSign(m)
}