Example #1
0
	host    Host
}

var _ fs.Node = (*Dir)(nil)

func (d *Dir) Attr(ctx context.Context, a *fuse.Attr) error {
	if d.host.address == "" {
		// root directory
		a.Mode = os.ModeDir | 0755
		return nil
	}
	a.Mode = os.ModeNamedPipe | 0755
	return nil
}

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

func (d *Dir) ReadDirAll(ctx context.Context) ([]fuse.Dirent, error) {
	if d.host.address == "" {
		// Always try to add new hosts when ls is run against the root dir
		d.scanner.EnumerateHosts()
	}
	var res []fuse.Dirent
	res = append(res, fuse.Dirent{Type: fuse.DT_Dir, Name: "."})
	res = append(res, fuse.Dirent{Type: fuse.DT_Dir, Name: ".."})
	for addr, _ := range d.scanner.Hosts {
		res = append(res, fuse.Dirent{Type: fuse.DT_File, Name: addr})
	}
	return res, nil
}
Example #2
0
	"github.com/restic/restic"
	"github.com/restic/restic/backend"
	"github.com/restic/restic/repository"

	"golang.org/x/net/context"
)

type SnapshotWithId struct {
	*restic.Snapshot
	backend.ID
}

// These lines statically ensure that a *SnapshotsDir implement the given
// interfaces; a misplaced refactoring of the implementation that breaks
// the interface will be catched by the compiler
var _ = fs.HandleReadDirAller(&SnapshotsDir{})
var _ = fs.NodeStringLookuper(&SnapshotsDir{})

type SnapshotsDir struct {
	repo        *repository.Repository
	ownerIsRoot bool

	// knownSnapshots maps snapshot timestamp to the snapshot
	sync.RWMutex
	knownSnapshots map[string]SnapshotWithId
}

func NewSnapshotsDir(repo *repository.Repository, ownerIsRoot bool) *SnapshotsDir {
	return &SnapshotsDir{
		repo:           repo,
		knownSnapshots: make(map[string]SnapshotWithId),
Example #3
0
File: main.go Project: orivej/ghfs
		return nil, fuse.ENOENT
	}

	r, _, err := u.FS.Client.Repositories.Get(*u.Login, req.Name)
	if err != nil {
		return nil, fuse.ENOENT
	}
	return &Repository{FS: u.FS, Repository: r}, nil
}

type Repository struct {
	*github.Repository
	FS *FS
}

var _ = fs.HandleReadDirAller(&Repository{})

func (r *Repository) Attr(ctx context.Context, attr *fuse.Attr) error {
	attr.Mode = os.ModeDir | 0755
	return nil
}

func (r *Repository) Lookup(ctx context.Context, req *fuse.LookupRequest, resp *fuse.LookupResponse) (fs.Node, error) {
	if strings.HasPrefix(req.Name, ".") {
		return nil, fuse.ENOENT
	}

	fileContent, directoryContent, _, err := r.FS.Client.Repositories.GetContents(*r.Owner.Login, *r.Name, req.Name, nil)
	if err != nil {
		return nil, fuse.ENOENT
	}
Example #4
0
	"bazil.org/bazil/util/env"
	"bazil.org/fuse"
	"bazil.org/fuse/fs"
	"github.com/golang/protobuf/proto"
	"golang.org/x/net/context"
)

type listSnaps struct {
	fs *Volume
}

var _ = fs.Node(&listSnaps{})
var _ = fs.NodeMkdirer(&listSnaps{})
var _ = fs.NodeStringLookuper(&listSnaps{})
var _ = fs.Handle(&listSnaps{})
var _ = fs.HandleReadDirAller(&listSnaps{})

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

var _ = fs.NodeStringLookuper(&listSnaps{})

func (d *listSnaps) Lookup(ctx context.Context, name string) (fs.Node, error) {
	var ref wire.SnapshotRef
	lookup := func(tx *db.Tx) error {
		bucket := d.fs.bucket(tx).SnapBucket()
Example #5
0
	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 {
		if os.IsNotExist(err) {
			return nil, fuse.ENOENT
Example #6
0
}

var _ = fs.FS(benchFS{})

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

type benchDir struct {
	conf *benchConfig
}

var _ = fs.Node(benchDir{})
var _ = fs.NodeStringLookuper(benchDir{})
var _ = fs.Handle(benchDir{})
var _ = fs.HandleReadDirAller(benchDir{})

func (benchDir) Attr(ctx context.Context, a *fuse.Attr) error {
	a.Inode = 1
	a.Mode = os.ModeDir | 0555
	return nil
}

func (d benchDir) Lookup(ctx context.Context, name string) (fs.Node, error) {
	if name == "bench" {
		return benchFile{conf: d.conf}, nil
	}
	return nil, fuse.ENOENT
}

func (benchDir) ReadDirAll(ctx context.Context) ([]fuse.Dirent, error) {
Example #7
0
	"bazil.org/fuse"
	"bazil.org/fuse/fs"
	"golang.org/x/net/context"
)

type StupidDir struct {
	// I hate this, but I can't figure out a better alternative.
	// I wanted to only have one map, Children, which themselves either have a
	//Children property signifying a StupidDir, or a Content property
	//signifying a StupidFile.
	Files *map[string]fs.Node
	Dirs  *map[string]*StupidDir
}

var _ = fs.Node(&StupidDir{})
var _ = fs.HandleReadDirAller(&StupidDir{})

func NewStupidDir() *StupidDir {
	files := make(map[string]fs.Node)
	dirs := make(map[string]*StupidDir)

	return &StupidDir{
		Files: &files,
		Dirs:  &dirs,
	}
}

func filesToStupidDir(files []*alpm.File) *StupidDir {
	// We need to parse this slice of path strings:
	/*
		etc/