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

// Creates records a Create request and its fields.
type Creates struct {
	rec RequestRecorder
}

var _ = fs.NodeCreater(&Creates{})

// Create records the request and returns an error. Most callers should
// wrap this call in a function that returns a more useful result.
func (r *Creates) Create(ctx context.Context, req *fuse.CreateRequest, resp *fuse.CreateResponse) (fs.Node, fs.Handle, error) {
	tmp := *req
	r.rec.RecordRequest(&tmp)
	return nil, nil, fuse.EIO
}

// RecordedCreate returns information about the Create request.
// If no request was seen, returns a zero value.
func (r *Creates) RecordedCreate() fuse.CreateRequest {
	val := r.rec.Recorded()
	if val == nil {
		return fuse.CreateRequest{}
Пример #2
0
		if _, err := b.CreateDir(name); err != nil {
			return err
		}
		return nil
	})
	if err != nil {
		return nil, err
	}
	n := &Dir{
		fs:   d.fs,
		path: append(d.path, name),
	}
	return n, nil
}

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

func (d *Dir) Create(c context.Context, req *fuse.CreateRequest, resp *fuse.CreateResponse) (fs.Node, fs.Handle, error) {
	log.Debugln("create:", req)

	name := req.Name
	f := &File{
		dir:     d,
		name:    name,
		writers: 1,
		// file is empty at Create time, no need to set data
	}

	return f, f, d.fs.backend.Update(c, func(ctx Context) error {
		b, err := ctx.Dir(d.path)
		if err != nil {
Пример #3
0
		}
		return child, nil

	default:
		return nil, fmt.Errorf("unknown entry in tree, %v", de)
	}
}

type fuseDir struct {
	chunkStore chunks.Store
	reader     *Reader
}

var _ = fusefs.Node(fuseDir{})
var _ = fusefs.NodeStringLookuper(fuseDir{})
var _ = fusefs.NodeCreater(fuseDir{})
var _ = fusefs.Handle(fuseDir{})
var _ = fusefs.HandleReadDirAller(fuseDir{})

func (d fuseDir) Attr(ctx context.Context, a *fuse.Attr) error {
	a.Mode = os.ModeDir | 0555
	a.Uid = env.MyUID
	a.Gid = env.MyGID
	return nil
}

const _MAX_INT64 = 9223372036854775807

func (d fuseDir) Lookup(ctx context.Context, name string) (fusefs.Node, error) {
	de, err := d.reader.Lookup(name)
	if err != nil {
Пример #4
0
	mu sync.Mutex

	name string

	// each in-memory child, so we can return the same node on
	// multiple Lookups and know what to do on .save()
	//
	// each child also stores its own name; if the value in the child,
	// looked up in this map, does not equal the child, that means the
	// child has been unlinked
	active map[string]node
}

var _ = node(&dir{})
var _ = fs.Node(&dir{})
var _ = fs.NodeCreater(&dir{})
var _ = fs.NodeForgetter(&dir{})
var _ = fs.NodeMkdirer(&dir{})
var _ = fs.NodeRemover(&dir{})
var _ = fs.NodeRenamer(&dir{})
var _ = fs.NodeStringLookuper(&dir{})
var _ = fs.HandleReadDirer(&dir{})

func (d *dir) setName(name string) {
	d.mu.Lock()
	defer d.mu.Unlock()
	d.name = name
}

func (d *dir) Attr() fuse.Attr {
	return fuse.Attr{