Exemplo n.º 1
0
	"testing"

	"camlistore.org/third_party/bazil.org/fuse"
	"camlistore.org/third_party/bazil.org/fuse/fs"
	"camlistore.org/third_party/bazil.org/fuse/fs/fstestutil"
)

type benchConfig struct {
	directIO bool
}

type benchFS struct {
	conf *benchConfig
}

var _ = fs.FS(benchFS{})
var _ = fs.FSIniter(benchFS{})

func (benchFS) Init(req *fuse.InitRequest, resp *fuse.InitResponse, intr fs.Intr) fuse.Error {
	resp.MaxReadahead = 64 * 1024 * 1024
	resp.Flags |= fuse.InitAsyncRead
	return nil
}

func (f benchFS) Root() (fs.Node, fuse.Error) {
	return benchDir{conf: f.conf}, nil
}

type benchDir struct {
	conf *benchConfig
}
Exemplo n.º 2
0
	// caller may set cwd, so we can't rely on relative paths
	executable, err := filepath.Abs(os.Args[0])
	if err != nil {
		return nil, err
	}
	testName = regexp.QuoteMeta(testName)
	cmd := exec.Command(executable, "-test.run=^"+testName+"$", "-fuse.internal.childmode")
	cmd.Stdout = os.Stdout
	cmd.Stderr = os.Stderr
	return cmd, nil
}

// childMapFS is an FS with one fixed child named "child".
type childMapFS map[string]fs.Node

var _ = fs.FS(childMapFS{})
var _ = fs.Node(childMapFS{})
var _ = fs.NodeStringLookuper(childMapFS{})

func (f childMapFS) Attr() fuse.Attr {
	return fuse.Attr{Inode: 1, Mode: os.ModeDir | 0777}
}

func (f childMapFS) Root() (fs.Node, fuse.Error) {
	return f, nil
}

func (f childMapFS) Lookup(name string, intr fs.Intr) (fs.Node, fuse.Error) {
	child, ok := f[name]
	if !ok {
		return nil, fuse.ENOENT
Exemplo n.º 3
0
package fstestutil

import (
	"os"

	"camlistore.org/third_party/bazil.org/fuse"
	"camlistore.org/third_party/bazil.org/fuse/fs"
)

// SimpleFS is a trivial FS that just implements the Root method.
type SimpleFS struct {
	Node fs.Node
}

var _ = fs.FS(SimpleFS{})

func (f SimpleFS) Root() (fs.Node, fuse.Error) {
	return f.Node, nil
}

// File can be embedded in a struct to make it look like a file.
type File struct{}

func (f File) Attr() fuse.Attr { return fuse.Attr{Mode: 0666} }

// Dir can be embedded in a struct to make it look like a directory.
type Dir struct{}

func (f Dir) Attr() fuse.Attr { return fuse.Attr{Mode: os.ModeDir | 0777} }