Esempio n. 1
0
// RecordedMkdir returns information about the Mkdir request.
// If no request was seen, returns a zero value.
func (r *Mkdirs) RecordedMkdir() fuse.MkdirRequest {
	val := r.rec.Recorded()
	if val == nil {
		return fuse.MkdirRequest{}
	}
	return *(val.(*fuse.MkdirRequest))
}

// Symlinks records a Symlink request and its fields.
type Symlinks struct {
	rec RequestRecorder
}

var _ = fs.NodeSymlinker(&Symlinks{})

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

// 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{}
Esempio n. 2
0
		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++
		}
		return err
	})
	return
}

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

func (d *Dir) Symlink(c context.Context, req *fuse.SymlinkRequest) (l fs.Node, err error) {
	defer log.Debugln("symlink:", req, l, "err=", err)
	f := &File{
		dir:    d,
		name:   req.NewName,
		link:   true,
		target: req.Target,
	}

	err = d.fs.backend.Update(c, func(ctx Context) error {
		b, err := ctx.Dir(d.path)
		if err != nil {
			return err
		}