Ejemplo n.º 1
0
	// mu protects the fields below.
	mu sync.Mutex

	name    string
	blob    *blobs.Blob
	dirty   dirtiness
	handles uint32

	// when was this entry last changed
	// TODO: written time.Time
}

var _ = node(&file{})
var _ = fs.Node(&file{})
var _ = fs.NodeForgetter(&file{})
var _ = fs.NodeOpener(&file{})
var _ = fs.NodeSetattrer(&file{})
var _ = fs.NodeFsyncer(&file{})
var _ = fs.HandleFlusher(&file{})
var _ = fs.HandleReader(&file{})
var _ = fs.HandleWriter(&file{})
var _ = fs.HandleReleaser(&file{})

func (f *file) setName(name string) {
	f.mu.Lock()
	defer f.mu.Unlock()
	f.name = name
}

func (f *file) marshalInternal() (*wire.Dirent, error) {
	de := &wire.Dirent{
Ejemplo n.º 2
0
	"syscall"

	"bazil.org/bazil/fs/snap/wire"
	"bazil.org/bazil/util/env"
	"bazil.org/fuse"
	fusefs "bazil.org/fuse/fs"
	"golang.org/x/net/context"
)

type fuseFile struct {
	de  *wire.Dirent
	rat io.ReaderAt
}

var _ = fusefs.Node(fuseFile{})
var _ = fusefs.NodeOpener(fuseFile{})
var _ = fusefs.Handle(fuseFile{})
var _ = fusefs.HandleReader(fuseFile{})

func (e fuseFile) Attr(ctx context.Context, a *fuse.Attr) error {
	a.Mode = 0444
	a.Uid = env.MyUID
	a.Gid = env.MyGID
	a.Size = e.de.File.Manifest.Size
	// a.Mtime = e.Meta.Written.UTC()
	// a.Ctime = e.Meta.Written.UTC()
	// a.Crtime = e.Meta.Written.UTC()
	a.Blocks = statBlocks(e.de.File.Manifest.Size) // TODO .Space?
	return nil
}
Ejemplo n.º 3
0
// RecordedMknod returns information about the Mknod request.
// If no request was seen, returns a zero value.
func (r *Mknods) RecordedMknod() fuse.MknodRequest {
	val := r.rec.Recorded()
	if val == nil {
		return fuse.MknodRequest{}
	}
	return *(val.(*fuse.MknodRequest))
}

// Opens records a Open request and its fields.
type Opens struct {
	rec RequestRecorder
}

var _ = fs.NodeOpener(&Opens{})

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

// RecordedOpen returns information about the Open request.
// If no request was seen, returns a zero value.
func (r *Opens) RecordedOpen() fuse.OpenRequest {
	val := r.rec.Recorded()
	if val == nil {
		return fuse.OpenRequest{}
Ejemplo n.º 4
0
			return err
		}

		a.Size = uint64(fi.Size())
		a.Mode = 0777
		if config_params.uid != 0 {
			a.Uid = uint32(config_params.uid)
		}
		if config_params.gid != 0 {
			a.Gid = uint32(config_params.gid)
		}
	}
	return nil
}

var _ = fs.NodeOpener(&File{})

func (f *File) Open(ctx context.Context, req *fuse.OpenRequest, resp *fuse.OpenResponse) (fs.Handle, error) {
	glog.Infof("Entered Open with file name: %s.\n", f.name)

	if f.name == ".description" {
		return &FileHandle{r: nil, f: f}, nil
	}

	if f.name[0] == '.' {
		return nil, fuse.EPERM
	}

	if runtime.GOOS == "darwin" {
		resp.Flags |= fuse.OpenDirectIO
	}
Ejemplo n.º 5
0
	return nil, fuse.ENOENT
}

func (benchDir) ReadDir(intr fs.Intr) ([]fuse.Dirent, fuse.Error) {
	l := []fuse.Dirent{
		{Inode: 2, Name: "bench", Type: fuse.DT_File},
	}
	return l, nil
}

type benchFile struct {
	conf *benchConfig
}

var _ = fs.Node(benchFile{})
var _ = fs.NodeOpener(benchFile{})
var _ = fs.NodeFsyncer(benchFile{})
var _ = fs.Handle(benchFile{})
var _ = fs.HandleReader(benchFile{})
var _ = fs.HandleWriter(benchFile{})

func (benchFile) Attr() fuse.Attr {
	return fuse.Attr{Inode: 2, Mode: 0644, Size: 9999999999999999}
}

func (f benchFile) Open(req *fuse.OpenRequest, resp *fuse.OpenResponse, intr fs.Intr) (fs.Handle, fuse.Error) {
	if f.conf.directIO {
		resp.Flags |= fuse.OpenDirectIO
	}
	// TODO configurable?
	resp.Flags |= fuse.OpenKeepCache
Ejemplo n.º 6
0
	if err := e.fsys.Store.Move(e.path, newPath, true); err != nil {
		log.Warningf("fuse: entry: mv: %v", err)
		return err
	}

	return nil
}

//
// Compile time checks to see which interfaces we implement:
// Please update this list when modifying code here.
var _ = fs.Node(&Entry{})
var _ = fs.NodeFsyncer(&Entry{})
var _ = fs.NodeGetxattrer(&Entry{})
var _ = fs.NodeListxattrer(&Entry{})
var _ = fs.NodeOpener(&Entry{})
var _ = fs.NodeSetattrer(&Entry{})

// var _ = fs.NodeRenamer(&Entry{})

//var _ = fs.NodeReadlinker(&Entry{})
//var _ = fs.NodeRemover(&Entry{})
//var _ = fs.NodeRemovexattrer(&Entry{})
// var _ = fs.NodeRequestLookuper(&Entry{})
// var _ = fs.NodeAccesser(&Entry{})
// var _ = fs.NodeForgetter(&Entry{})

//var _ = fs.NodeGetattrer(&Entry{})

//var _ = fs.NodeLinker(&Entry{})