Пример #1
0
// RecordedSymlink returns information about the Symlink request.
// If no request was seen, returns a zero value.
func (r *Symlinks) RecordedSymlink() fuse.SymlinkRequest {
	val := r.rec.Recorded()
	if val == nil {
		return fuse.SymlinkRequest{}
	}
	return *(val.(*fuse.SymlinkRequest))
}

// Links records a Link request and its fields.
type Links struct {
	rec RequestRecorder
}

var _ = fs.NodeLinker(&Links{})

// Link records the request and returns an error. Most callers should
// wrap this call in a function that returns a more useful result.
func (r *Links) Link(req *fuse.LinkRequest, old fs.Node, intr fs.Intr) (fs.Node, fuse.Error) {
	tmp := *req
	r.rec.RecordRequest(&tmp)
	return nil, fuse.EIO
}

// RecordedLink returns information about the Link request.
// If no request was seen, returns a zero value.
func (r *Links) RecordedLink() fuse.LinkRequest {
	val := r.rec.Recorded()
	if val == nil {
		return fuse.LinkRequest{}
Пример #2
-1
			dd, err := ctx.Dir(d.path)
			if err == nil {
				targetDir = dd
			} else {
				return err
			}
		}
		err = targetDir.Put(req.NewName, data)
		if err != nil {
			return err
		}
		return b.Delete(req.OldName)
	})
}

var _ = fs.NodeLinker(&Dir{})

func (d *Dir) Link(c context.Context, req *fuse.LinkRequest, old fs.Node) (l fs.Node, err error) {
	defer log.Debugln("link:", req, "err=", err)
	l = old
	err = d.fs.backend.Update(c, func(ctx Context) error {
		b, err := ctx.Dir(d.path)
		if err != nil {
			return err
		}
		tf := old.(*File) // panics if not
		lf := new(File)
		*lf = *tf
		lf.link = true
		if err = b.Put(req.NewName, lf); err == nil {
			tf.links++